From: Tom Lane Date: Sun, 15 Nov 1998 07:09:13 +0000 (+0000) Subject: Fix a couple of bugs involving calling fmtID() twice in X-Git-Tag: REL6_5~964 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0856cdf3f7086156fa9e78cb0c93a62f701bdec0;p=postgresql Fix a couple of bugs involving calling fmtID() twice in a single printf() ... it'd work if fmtId() didn't use a static return area... --- diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 5f022309af..a4bd2a49b8 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.94 1998/11/06 15:54:47 thomas Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.95 1998/11/15 07:09:13 tgl Exp $ * * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * @@ -2563,15 +2563,16 @@ dumpACL(FILE *fout, TableInfo tbinfo) { if (ACLlist[k].privledges != (char *) NULL) { + /* If you change this code, bear in mind fmtId() can be + * used only once per printf() call... + */ + fprintf(fout, + "GRANT %s on %s to ", + ACLlist[k].privledges, fmtId(tbinfo.relname)); if (ACLlist[k].user == (char *) NULL) - fprintf(fout, - "GRANT %s on %s to PUBLIC;\n", - ACLlist[k].privledges, fmtId(tbinfo.relname)); + fprintf(fout, "PUBLIC;\n"); else - fprintf(fout, - "GRANT %s on %s to %s;\n", - ACLlist[k].privledges, fmtId(tbinfo.relname), - fmtId(ACLlist[k].user)); + fprintf(fout, "%s;\n", fmtId(ACLlist[k].user)); } } } @@ -2851,23 +2852,21 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices, strcpy(id1, fmtId(indinfo[i].indexrelname)); strcpy(id2, fmtId(indinfo[i].indrelname)); - sprintf(q, "CREATE %s INDEX %s on %s using %s (", + fprintf(fout, "CREATE %s INDEX %s on %s using %s (", (strcmp(indinfo[i].indisunique, "t") == 0) ? "UNIQUE" : "", id1, id2, indinfo[i].indamname); if (funcname) { - sprintf(q, "%s %s (%s) %s );\n", - q, fmtId(funcname), attlist, fmtId(classname[0])); + /* need 2 printf's here cuz fmtId has static return area */ + fprintf(fout, " %s", fmtId(funcname)); + fprintf(fout, " (%s) %s );\n", attlist, fmtId(classname[0])); free(funcname); free(classname[0]); } else - sprintf(q, "%s %s );\n", - q, attlist); - - fputs(q, fout); + fprintf(fout, " %s );\n", attlist); } }