Update patch for DEFAULT on Views.
authorBruce Momjian <[email protected]>
Wed, 24 Apr 2002 02:42:27 +0000 (02:42 +0000)
committerBruce Momjian <[email protected]>
Wed, 24 Apr 2002 02:42:27 +0000 (02:42 +0000)
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]>

src/bin/pg_dump/pg_dump.c

index 91c377fbc4c90258f82aaa866dad5cb7e66b4472..70d11016f11e4a85a9091f56dbf020506dd2d901 100644 (file)
@@ -4376,10 +4376,12 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
                                 */
                                for (j = 0; j < tblinfo[i].numatts; j++)
                                {
-                                       if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0)
-                                               appendPQExpBuffer(q, "ALTER TABLE %s ALTER COLUMN %s SET DEFAULT %s;\n",
-                                                                                 tblinfo[i].relname, tblinfo[i].attnames[j],
+                                       if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0) {
+                                               appendPQExpBuffer(q, "ALTER TABLE %s ", fmtId(tblinfo[i].relname, force_quotes));
+                                               appendPQExpBuffer(q, "ALTER COLUMN %s SET DEFAULT %s;\n",
+                                                                                 fmtId(tblinfo[i].attnames[j], force_quotes),
                                                                                  tblinfo[i].adef_expr[j]);
+                                       }
                                }
 
                                commentDeps = malloc(sizeof(char *) * 2);