Commit 9d45f22e authored by Bruce Momjian's avatar Bruce Momjian

Here is the patch for pg_dump not handling NULL values in 'insert'

mode properly.  This will apply correctly to 1.09 & 2.0 sources.
From David H. Bennett
parent bdb25dba
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.15 1996/11/17 04:56:01 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.16 1996/11/20 22:32:55 momjian Exp $
* *
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
* *
...@@ -1456,6 +1456,10 @@ dumpClasses(TableInfo *tblinfo, int numTables, FILE *fout, const char *onlytable ...@@ -1456,6 +1456,10 @@ dumpClasses(TableInfo *tblinfo, int numTables, FILE *fout, const char *onlytable
fprintf(fout, "values ("); fprintf(fout, "values (");
field=0; field=0;
do { do {
if (PQgetisnull(res,tuple,field)) {
fprintf(fout,"NULL");
}
else {
switch(PQftype(res,field)) { switch(PQftype(res,field)) {
case 21: case 22: case 23: /* int types */ case 21: case 22: case 23: /* int types */
case 810: case 910: /* oldint types */ case 810: case 910: /* oldint types */
...@@ -1482,6 +1486,7 @@ dumpClasses(TableInfo *tblinfo, int numTables, FILE *fout, const char *onlytable ...@@ -1482,6 +1486,7 @@ dumpClasses(TableInfo *tblinfo, int numTables, FILE *fout, const char *onlytable
fprintf(fout, "'%s'", expandbuf); fprintf(fout, "'%s'", expandbuf);
break; break;
} }
}
field++; field++;
if(field != PQnfields(res)) if(field != PQnfields(res))
fprintf(fout, ","); fprintf(fout, ",");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment