aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/common.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-10-09 16:20:25 +0000
committerBruce Momjian <bruce@momjian.us>2002-10-09 16:20:25 +0000
commitba8e20a6dd1de393e2eeab9e6cb70edd8115ca61 (patch)
treeb1c4f8cc1f3d535bf3188675b35752e223b0daef /src/bin/pg_dump/common.c
parentd015dcbe4eeaebe6084983945ef68a642c38e0e1 (diff)
downloadpostgresql-ba8e20a6dd1de393e2eeab9e6cb70edd8115ca61.tar.gz
postgresql-ba8e20a6dd1de393e2eeab9e6cb70edd8115ca61.zip
> Alvaro Herrera <alvherre@atentus.com> writes:
> > I'm looking at pg_dump/common.c:flagInhAttrs() and suspect that it can > > be more or less rewritten completely, and probably should to get rigth > > all the cases mentioned in the past attisinherited discussion. Is this > > desirable for 7.3? It can probably be hacked around and the rewrite > > kept for 7.4, but I think it will be much simpler after the rewrite. > > If it's a bug then it's fair game to fix in 7.3. But keep in mind that > pg_dump has to behave at least somewhat sanely when called against older > servers ... will your rewrite behave reasonably if the server does not > offer attinhcount values? Nah. I don't think it's worth it: I had forgotten that older versions should be supported. I just left the code as is and added a version-specific test. This patch allows pg_dump to dump correctly local definition of columns. In particular, CREATE TABLE p1 (f1 int, f2 int); CREATE TABLE p2 (f1 int); CREATE TABLE c () INHERITS (p1, p2); ALTER TABLE ONLY p1 DROP COLUMN f1; CREATE TABLE p3 (f1 int); CREATE TABLE c2 (f1 int) INHERITS (p3); Will be dumped as CREATE TABLE p1 (f2 int); CREATE TABLE p2 (f1 int); CREATE TABLE c (f1 int) INHERITS (p1, p2); CREATE TABLE c2 (f1 int) INHERITS (p3); (Previous version will dump CREATE TABLE c () INHERITS (p1, p2) CREATE TABLE c2 () INHERITS (p3) ) Alvaro Herrera
Diffstat (limited to 'src/bin/pg_dump/common.c')
-rw-r--r--src/bin/pg_dump/common.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index bd7b1a0c009..7870a0d66d2 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.70 2002/09/04 20:31:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.71 2002/10/09 16:20:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -284,16 +284,18 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
if (numParents == 0)
continue; /* nothing to see here, move along */
- /*
+ /*----------------------------------------------------------------
* For each attr, check the parent info: if no parent has an attr
* with the same name, then it's not inherited. If there *is* an
* attr with the same name, then only dump it if:
*
- * - it is NOT NULL and zero parents are NOT NULL OR - it has a
- * default value AND the default value does not match all parent
- * default values, or no parents specify a default.
+ * - it is NOT NULL and zero parents are NOT NULL
+ * OR
+ * - it has a default value AND the default value does not match
+ * all parent default values, or no parents specify a default.
*
* See discussion on -hackers around 2-Apr-2001.
+ *----------------------------------------------------------------
*/
for (j = 0; j < tblinfo[i].numatts; j++)
{
@@ -359,6 +361,12 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
tblinfo[i].inhAttrs[j] = false;
tblinfo[i].inhNotNull[j] = false;
}
+
+ /* Clear it if attr has local definition */
+ if (g_fout->remoteVersion >= 70300 && tblinfo[i].attislocal[j])
+ {
+ tblinfo[i].inhAttrs[j] = false;
+ }
}
}
}