]> granicus.if.org Git - postgresql/commitdiff
Fix brain fade in previous pg_dump patch.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 10 Feb 2012 19:09:25 +0000 (14:09 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 10 Feb 2012 19:09:25 +0000 (14:09 -0500)
In pre-7.3 databases, pg_attribute.attislocal doesn't exist.  The easiest
way to make sure the new inheritance logic behaves sanely is to assume it's
TRUE, not FALSE.  This will result in printing child columns even when
they're not really needed.  We could work harder at trying to reconstruct a
value for attislocal, but there is little evidence that anyone still cares
about dumping from such old versions, so just do the minimum necessary to
have a valid dump.

I had this correct in the original draft of the patch, but for some
unaccountable reason decided it wasn't necessary to change the value.
Testing against an old server shows otherwise...

src/bin/pg_dump/pg_dump.c

index 880d1415f12d7294e61fde12f49f14f1c57733ad..6afb800a6d1d46487a0e5fc1143787b183bc4b55 100644 (file)
@@ -5674,13 +5674,13 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
                         * explicitly set or was just a default.
                         *
                         * attislocal doesn't exist before 7.3, either; in older databases
-                        * we just assume that inherited columns had no local definition.
+                        * we assume it's TRUE, else we'd fail to dump non-inherited atts.
                         */
                        appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, "
                                                          "-1 AS attstattarget, a.attstorage, "
                                                          "t.typstorage, a.attnotnull, a.atthasdef, "
                                                          "false AS attisdropped, a.attlen, "
-                                                         "a.attalign, false AS attislocal, "
+                                                         "a.attalign, true AS attislocal, "
                                                          "format_type(t.oid,a.atttypmod) AS atttypname, "
                                                          "'' AS attoptions, 0 AS attcollation "
                                                          "FROM pg_attribute a LEFT JOIN pg_type t "
@@ -5698,7 +5698,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
                                                          "attstorage, attstorage AS typstorage, "
                                                          "attnotnull, atthasdef, false AS attisdropped, "
                                                          "attlen, attalign, "
-                                                         "false AS attislocal, "
+                                                         "true AS attislocal, "
                                                          "(SELECT typname FROM pg_type WHERE oid = atttypid) AS atttypname, "
                                                          "'' AS attoptions, 0 AS attcollation "
                                                          "FROM pg_attribute a "