Date:

Mon Jul 24 18:06:50 PDT 1995

Description

The pg_dump program was not updated to work with the libpq of beta0.03

Thanks to Robert Patrick for discovering the problem.

Fix

Apply this patch. From now on, the pg_dump sources will only work for postgres95 beta0.03 or later. A separate program (pg4_dump) is available that works with postgres v4r2. It is available as '%d'::oid", g_last_builtin_oid); ! res = PQexec(query); ! pbuf = PQparray(res+1); ! ntups = PQntuplesGroup(pbuf,0); *numFuncs = ntups; finfo = (FuncInfo*)malloc(ntups * sizeof(FuncInfo)); ! i_oid = PQfnumberGroup(pbuf,0,"oid"); ! i_proname = PQfnumberGroup(pbuf,0,"proname"); ! i_proowner = PQfnumberGroup(pbuf,0,"proowner"); ! i_prolang = PQfnumberGroup(pbuf,0,"prolang"); ! i_pronargs = PQfnumberGroup(pbuf,0,"pronargs"); ! i_proargtypes = PQfnumberGroup(pbuf,0,"proargtypes"); ! i_prorettype = PQfnumberGroup(pbuf,0,"prorettype"); ! i_proretset = PQfnumberGroup(pbuf,0,"proretset"); ! i_prosrc = PQfnumberGroup(pbuf,0,"prosrc"); ! i_probin = PQfnumberGroup(pbuf,0,"probin"); for (i=0;i '%d'::oid", g_last_builtin_oid); ! res = PQexec(g_conn, query); ! if (!res || ! PQresultStatus(res) != PGRES_TUPLES_OK) { ! fprintf(stderr,"getFuncs(): SELECT failed"); ! exit_nicely(g_conn); ! } + ntups = PQntuples(res); + *numFuncs = ntups; finfo = (FuncInfo*)malloc(ntups * sizeof(FuncInfo)); ! i_oid = PQfnumber(res,"oid"); ! i_proname = PQfnumber(res,"proname"); ! i_proowner = PQfnumber(res,"proowner"); ! i_prolang = PQfnumber(res,"prolang"); ! i_pronargs = PQfnumber(res,"pronargs"); ! i_proargtypes = PQfnumber(res,"proargtypes"); ! i_prorettype = PQfnumber(res,"prorettype"); ! i_proretset = PQfnumber(res,"proretset"); ! i_prosrc = PQfnumber(res,"prosrc"); ! i_probin = PQfnumber(res,"probin"); for (i=0;i 0 order by attnum",tblinfo[i].oid); ! res = PQexec(q); ! pbuf = PQparray(res+1); ! ntups = PQntuplesGroup(pbuf,0); ! i_attname = PQfnumberGroup(pbuf,0,"attname"); ! i_typname = PQfnumberGroup(pbuf,0,"typname"); tblinfo[i].numatts = ntups; tblinfo[i].attnames = (char**) malloc( ntups * sizeof(char*)); --- 737,753 ---- g_comment_end); sprintf(q,"SELECT a.attnum, a.attname, t.typname from pg_attribute a, pg_type t where a.attrelid = '%s' and a.atttypid = t.oid and a.attnum > 0 order by attnum",tblinfo[i].oid); ! res = PQexec(g_conn, q); ! if (!res || ! PQresultStatus(res) != PGRES_TUPLES_OK) { ! fprintf(stderr,"getTableAttrs(): SELECT failed"); ! exit_nicely(g_conn); ! } ! ! ntups = PQntuples(res); ! i_attname = PQfnumber(res,"attname"); ! i_typname = PQfnumber(res,"typname"); tblinfo[i].numatts = ntups; tblinfo[i].attnames = (char**) malloc( ntups * sizeof(char*)); *************** *** 694,704 **** tblinfo[i].parentRels = NULL; tblinfo[i].numParents = 0; for (j=0;j '%d'::oid and t2.relname !~ '^pg_' and t1.relname !~ '^Xinx' ;", g_last_builtin_oid); ! res = PQexec(query); ! pbuf = PQparray(res+1); ! ntups = PQntuplesGroup(pbuf,0); *numIndices = ntups; indinfo = (IndInfo*)malloc(ntups * sizeof (IndInfo)); ! i_indexrelname = PQfnumberGroup(pbuf,0,"indexrelname"); ! i_indrelname = PQfnumberGroup(pbuf,0,"indrelname"); ! i_indamname = PQfnumberGroup(pbuf,0,"indamname"); ! i_indproc = PQfnumberGroup(pbuf,0,"indproc"); ! i_indkey = PQfnumberGroup(pbuf,0,"indkey"); ! i_indclassname = PQfnumberGroup(pbuf,0,"indclassname"); for (i=0;i '%d'::oid and t2.relname !~ '^pg_' and t1.relname !~ '^Xinx' ;", g_last_builtin_oid); ! ! res = PQexec(g_conn, query); ! if (!res || ! PQresultStatus(res) != PGRES_TUPLES_OK) { ! fprintf(stderr,"getIndices(): SELECT failed"); ! exit_nicely(g_conn); ! } ! ! ntups = PQntuples(res); *numIndices = ntups; indinfo = (IndInfo*)malloc(ntups * sizeof (IndInfo)); ! i_indexrelname = PQfnumber(res,"indexrelname"); ! i_indrelname = PQfnumber(res,"indrelname"); ! i_indamname = PQfnumber(res,"indamname"); ! i_indproc = PQfnumber(res,"indproc"); ! i_indkey = PQfnumber(res,"indkey"); ! i_indclassname = PQfnumber(res,"indclassname"); for (i=0;i 0 ) { /* --- 1336,1349 ---- * attributes copied out */ void ! dumpTuples(PGresult *res, FILE *fout, int* attrmap) { int i, j, k; int m, n, t; char **outVals = NULL; /* values to copy out */ ! n = PQntuples(res); ! m = PQnfields(res); if ( m > 0 ) { /* *************** *** 1292,1298 **** for (j = 0; j < n; j++) { for (k = 0; k < m; k++) { ! outVals[attrmap[k]] = PQgetvalue(pbuf, j, k); } for (k = 0; k < m; k++) { char *pval = outVals[k]; --- 1354,1360 ---- for (j = 0; j < n; j++) { for (k = 0; k < m; k++) { ! outVals[attrmap[k]] = PQgetvalue(res, j, k); } for (k = 0; k < m; k++) { char *pval = outVals[k]; *************** *** 1328,1347 **** int findLastBuiltinOid() { ! char *res; ! PortalBuffer* pbuf; int ntups; int last_oid; ! res = PQexec("SELECT oid from pg_database where datname = 'template1';"); ! pbuf = PQparray(res+1); ! ntups = PQntuplesGroup(pbuf,0); if (ntups != 1) { fprintf(stderr,"pg_dump: couldn't find the template1 database. You are really hosed\nGiving up\n"); ! exit(2); } ! return (atoi(PQgetvalue(pbuf,0, PQfnumberGroup(pbuf,0,"oid")))); ! } --- 1390,1414 ---- int findLastBuiltinOid() { ! PGresult* res; int ntups; int last_oid; ! res = PQexec(g_conn, ! "SELECT oid from pg_database where datname = 'template1';"); ! if (res == NULL || ! PQresultStatus(res) != PGRES_TUPLES_OK) { ! fprintf(stderr,"pg_dump error in finding the template1 database"); ! exit_nicely(g_conn); ! } ! ntups = PQntuples(res); if (ntups != 1) { fprintf(stderr,"pg_dump: couldn't find the template1 database. You are really hosed\nGiving up\n"); ! exit_nicely(g_conn); } ! last_oid = atoi(PQgetvalue(res, 0, PQfnumber(res, "oid"))); ! PQclear(res); ! return last_oid; } =================================================================== RCS file: /usr/local/devel/pglite/cvs/src/bin/pg_dump/pg_dump.h,v retrieving revision 1.5 diff -c -r1.5 pg_dump.h *** 1.5 1995/06/28 22:32:36 --- src/bin/pg_dump/pg_dump.h 1995/07/25 00:32:08 *************** *** 183,189 **** TableInfo* tbinfo, int numTables); extern void dumpClasses(TableInfo *tbinfo, int numTables, FILE *fout); ! extern void dumpTuples(char *portalname, FILE *fout, int *attrmap); extern char* checkForQuote(char* s); extern int findLastBuiltinOid(); --- 183,189 ---- TableInfo* tbinfo, int numTables); extern void dumpClasses(TableInfo *tbinfo, int numTables, FILE *fout); ! extern void dumpTuples(PGresult *res, FILE *fout, int *attrmap); extern char* checkForQuote(char* s); extern int findLastBuiltinOid();