Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2446937

Browse files
committed
Update patch for DEFAULT on Views.
Apparently, you need to make two calls to appendPQExpBuffer() to use fmtId() twice, because it uses a static buffer (thanks for spotting this Tom). Another revision of the patch is attached. Neil Conway <[email protected]>
1 parent 19b31e0 commit 2446937

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.252 2002/04/24 02:38:58 momjian Exp $
25+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.253 2002/04/24 02:42:27 momjian Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -4376,10 +4376,12 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
43764376
*/
43774377
for (j = 0; j < tblinfo[i].numatts; j++)
43784378
{
4379-
if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0)
4380-
appendPQExpBuffer(q, "ALTER TABLE %s ALTER COLUMN %s SET DEFAULT %s;\n",
4381-
tblinfo[i].relname, tblinfo[i].attnames[j],
4379+
if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0) {
4380+
appendPQExpBuffer(q, "ALTER TABLE %s ", fmtId(tblinfo[i].relname, force_quotes));
4381+
appendPQExpBuffer(q, "ALTER COLUMN %s SET DEFAULT %s;\n",
4382+
fmtId(tblinfo[i].attnames[j], force_quotes),
43824383
tblinfo[i].adef_expr[j]);
4384+
}
43834385
}
43844386

43854387
commentDeps = malloc(sizeof(char *) * 2);

0 commit comments

Comments
 (0)