mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
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
This commit is contained in:
parent
bdb25dbad6
commit
9d45f22e38
@ -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,31 +1456,36 @@ dumpClasses(TableInfo *tblinfo, int numTables, FILE *fout, const char *onlytable
|
|||||||
fprintf(fout, "values (");
|
fprintf(fout, "values (");
|
||||||
field=0;
|
field=0;
|
||||||
do {
|
do {
|
||||||
switch(PQftype(res,field)) {
|
if (PQgetisnull(res,tuple,field)) {
|
||||||
case 21: case 22: case 23: /* int types */
|
fprintf(fout,"NULL");
|
||||||
case 810: case 910: /* oldint types */
|
}
|
||||||
case 1005: case 1006: case 1007: /* _int types */
|
else {
|
||||||
case 700: case 701: /* float types */
|
switch(PQftype(res,field)) {
|
||||||
case 1021: case 1022: /* _float types */
|
case 21: case 22: case 23: /* int types */
|
||||||
fprintf(fout, "%s", PQgetvalue(res,tuple,field));
|
case 810: case 910: /* oldint types */
|
||||||
break;
|
case 1005: case 1006: case 1007: /* _int types */
|
||||||
default:
|
case 700: case 701: /* float types */
|
||||||
|
case 1021: case 1022: /* _float types */
|
||||||
|
fprintf(fout, "%s", PQgetvalue(res,tuple,field));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
/* Before outputing string value, expand all
|
/* Before outputing string value, expand all
|
||||||
single quotes to twin single quotes -
|
single quotes to twin single quotes -
|
||||||
dhb - 6/11/96 */
|
dhb - 6/11/96 */
|
||||||
expsrc=PQgetvalue(res,tuple,field);
|
expsrc=PQgetvalue(res,tuple,field);
|
||||||
expdest=expandbuf;
|
expdest=expandbuf;
|
||||||
while (*expsrc) {
|
while (*expsrc) {
|
||||||
*expdest++=*expsrc;
|
*expdest++=*expsrc;
|
||||||
if (*expsrc == (char)0x27) /*sing. quote*/
|
if (*expsrc == (char)0x27) /*sing. quote*/
|
||||||
*expdest++ = *expsrc;
|
*expdest++ = *expsrc;
|
||||||
expsrc++;
|
expsrc++;
|
||||||
}
|
}
|
||||||
*expdest=*expsrc; /* null term. */
|
*expdest=*expsrc; /* null term. */
|
||||||
|
|
||||||
fprintf(fout, "'%s'", expandbuf);
|
fprintf(fout, "'%s'", expandbuf);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
field++;
|
field++;
|
||||||
if(field != PQnfields(res))
|
if(field != PQnfields(res))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user