aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-06-27 02:18:14 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-06-27 02:18:14 +0000
commitddfbdd46d8c2fb50f245e25ad7fdf4c5ac493fd5 (patch)
tree019eb582db58d686e14b91b04e1b90543db562d0
parent894889ecc43a1503c48f88f9da21cc53b5b29f3f (diff)
downloadpostgresql-ddfbdd46d8c2fb50f245e25ad7fdf4c5ac493fd5.tar.gz
postgresql-ddfbdd46d8c2fb50f245e25ad7fdf4c5ac493fd5.zip
Modify pg_dump to assume that a check constraint is inherited if its
name matches the name of any parent-table constraint, without looking at the constraint text. This is a not-very-bulletproof workaround for the problem exhibited by Berend Tober last month. We really ought to record constraint inheritance status in pg_constraint, but it's looking like that may not get done for 8.1 --- and even if it does, we will need this kluge for dumping from older servers.
-rw-r--r--src/bin/pg_dump/common.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 64090639256..f4ae06e86f3 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.85 2004/12/31 22:03:07 pgsql Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.85.4.1 2005/06/27 02:18:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -347,8 +347,14 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
/*
* Check for inherited CHECK constraints. We assume a constraint
- * is inherited if its expression matches the parent and the name
- * is the same, *or* both names start with '$'.
+ * is inherited if its name matches the name of any constraint in
+ * the parent. Originally this code tried to compare the expression
+ * texts, but that can fail if the parent and child tables are in
+ * different schemas, because reverse-listing of function calls may
+ * produce different text (schema-qualified or not) depending on
+ * search path. We really need a more bulletproof way of detecting
+ * inherited constraints --- pg_constraint should record this
+ * explicitly!
*/
for (j = 0; j < tbinfo->ncheck; j++)
{
@@ -363,14 +369,9 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
parent = parents[k];
for (l = 0; l < parent->ncheck; l++)
{
- ConstraintInfo *pconstr;
-
- pconstr = &(parent->checkexprs[l]);
- if (strcmp(pconstr->condef, constr->condef) != 0)
- continue;
- if (strcmp(pconstr->dobj.name, constr->dobj.name) == 0 ||
- (pconstr->dobj.name[0] == '$' &&
- constr->dobj.name[0] == '$'))
+ ConstraintInfo *pconstr = &(parent->checkexprs[l]);
+
+ if (strcmp(pconstr->dobj.name, constr->dobj.name) == 0)
{
constr->coninherited = true;
break;