Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c3be085

Browse files
committed
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.
1 parent fc72240 commit c3be085

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/bin/pg_dump/common.c

+12-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.85 2004/12/31 22:03:07 pgsql Exp $
14+
* $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.86 2005/06/27 02:17:47 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -347,8 +347,14 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
347347

348348
/*
349349
* Check for inherited CHECK constraints. We assume a constraint
350-
* is inherited if its expression matches the parent and the name
351-
* is the same, *or* both names start with '$'.
350+
* is inherited if its name matches the name of any constraint in
351+
* the parent. Originally this code tried to compare the expression
352+
* texts, but that can fail if the parent and child tables are in
353+
* different schemas, because reverse-listing of function calls may
354+
* produce different text (schema-qualified or not) depending on
355+
* search path. We really need a more bulletproof way of detecting
356+
* inherited constraints --- pg_constraint should record this
357+
* explicitly!
352358
*/
353359
for (j = 0; j < tbinfo->ncheck; j++)
354360
{
@@ -363,14 +369,9 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
363369
parent = parents[k];
364370
for (l = 0; l < parent->ncheck; l++)
365371
{
366-
ConstraintInfo *pconstr;
367-
368-
pconstr = &(parent->checkexprs[l]);
369-
if (strcmp(pconstr->condef, constr->condef) != 0)
370-
continue;
371-
if (strcmp(pconstr->dobj.name, constr->dobj.name) == 0 ||
372-
(pconstr->dobj.name[0] == '$' &&
373-
constr->dobj.name[0] == '$'))
372+
ConstraintInfo *pconstr = &(parent->checkexprs[l]);
373+
374+
if (strcmp(pconstr->dobj.name, constr->dobj.name) == 0)
374375
{
375376
constr->coninherited = true;
376377
break;

0 commit comments

Comments
 (0)