Index: pg_dump.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v retrieving revision 1.226 diff -c -r1.226 pg_dump.c *** pg_dump.c 2001/08/27 01:09:59 1.226 --- pg_dump.c 2001/08/27 13:21:37 *************** *** 400,475 **** if (fout->remoteVersion >= 70100) { ! appendPQExpBuffer(q, "SELECT * FROM ONLY %s", fmtId(classname, force_quotes)); } else { ! appendPQExpBuffer(q, "SELECT * FROM %s", fmtId(classname, force_quotes)); } res = PQexec(g_conn, q->data); if (!res || ! PQresultStatus(res) != PGRES_TUPLES_OK) { write_msg(NULL, "dumpClasses(): SQL command failed\n"); write_msg(NULL, "Error message from server: %s", PQerrorMessage(g_conn)); write_msg(NULL, "The command was: %s\n", q->data); exit_nicely(); } ! for (tuple = 0; tuple < PQntuples(res); tuple++) ! { ! archprintf(fout, "INSERT INTO %s ", fmtId(classname, force_quotes)); ! if (attrNames == true) { ! resetPQExpBuffer(q); ! appendPQExpBuffer(q, "("); ! for (field = 0; field < PQnfields(res); field++) ! { ! if (field > 0) ! appendPQExpBuffer(q, ","); ! appendPQExpBuffer(q, fmtId(PQfname(res, field), force_quotes)); ! } ! appendPQExpBuffer(q, ") "); ! archprintf(fout, "%s", q->data); } ! archprintf(fout, "VALUES ("); ! for (field = 0; field < PQnfields(res); field++) { ! if (field > 0) ! archprintf(fout, ","); ! if (PQgetisnull(res, tuple, field)) { ! archprintf(fout, "NULL"); ! continue; } ! switch (PQftype(res, field)) { ! case INT2OID: ! case INT4OID: ! case OIDOID: /* int types */ ! case FLOAT4OID: ! case FLOAT8OID:/* float types */ ! /* These types are printed without quotes */ ! archprintf(fout, "%s", ! PQgetvalue(res, tuple, field)); ! break; ! case BITOID: ! case VARBITOID: ! archprintf(fout, "B'%s'", ! PQgetvalue(res, tuple, field)); ! break; ! default: ! ! /* ! * All other types are printed as string literals, ! * with appropriate escaping of special characters. ! */ ! resetPQExpBuffer(q); ! formatStringLiteral(q, PQgetvalue(res, tuple, field), CONV_ALL); ! archprintf(fout, "%s", q->data); ! break; } } ! archprintf(fout, ");\n"); ! } PQclear(res); destroyPQExpBuffer(q); return 1; --- 400,489 ---- if (fout->remoteVersion >= 70100) { ! appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR SELECT * FROM ONLY %s", fmtId(classname, force_quotes)); } else { ! appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR SELECT * FROM %s", fmtId(classname, force_quotes)); } res = PQexec(g_conn, q->data); if (!res || ! PQresultStatus(res) != PGRES_COMMAND_OK) { write_msg(NULL, "dumpClasses(): SQL command failed\n"); write_msg(NULL, "Error message from server: %s", PQerrorMessage(g_conn)); write_msg(NULL, "The command was: %s\n", q->data); exit_nicely(); } ! ! do { ! PQclear(res); ! res = PQexec(g_conn, "FETCH 1000 FROM _pg_dump_cursor"); ! if (!res || ! PQresultStatus(res) != PGRES_TUPLES_OK) { ! write_msg(NULL, "dumpClasses(): SQL command failed\n"); ! write_msg(NULL, "Error message from server: %s", PQerrorMessage(g_conn)); ! write_msg(NULL, "The command was: FETCH 1000 FROM _pg_dump_cursor\n"); ! exit_nicely(); } ! ! for (tuple = 0; tuple < PQntuples(res); tuple++) { ! archprintf(fout, "INSERT INTO %s ", fmtId(classname, force_quotes)); ! if (attrNames == true) { ! resetPQExpBuffer(q); ! appendPQExpBuffer(q, "("); ! for (field = 0; field < PQnfields(res); field++) ! { ! if (field > 0) ! appendPQExpBuffer(q, ","); ! appendPQExpBuffer(q, fmtId(PQfname(res, field), force_quotes)); ! } ! appendPQExpBuffer(q, ") "); ! archprintf(fout, "%s", q->data); } ! archprintf(fout, "VALUES ("); ! for (field = 0; field < PQnfields(res); field++) { ! if (field > 0) ! archprintf(fout, ","); ! if (PQgetisnull(res, tuple, field)) ! { ! archprintf(fout, "NULL"); ! continue; ! } ! switch (PQftype(res, field)) ! { ! case INT2OID: ! case INT4OID: ! case OIDOID: /* int types */ ! case FLOAT4OID: ! case FLOAT8OID:/* float types */ ! /* These types are printed without quotes */ ! archprintf(fout, "%s", ! PQgetvalue(res, tuple, field)); ! break; ! case BITOID: ! case VARBITOID: ! archprintf(fout, "B'%s'", ! PQgetvalue(res, tuple, field)); ! break; ! default: ! ! /* ! * All other types are printed as string literals, ! * with appropriate escaping of special characters. ! */ ! resetPQExpBuffer(q); ! formatStringLiteral(q, PQgetvalue(res, tuple, field), CONV_ALL); ! archprintf(fout, "%s", q->data); ! break; ! } } + archprintf(fout, ");\n"); } ! } while( PQntuples(res) ); PQclear(res); destroyPQExpBuffer(q); return 1;