From 6f28e879dd8630187b7640096978839ed204ce21 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 9 May 2008 22:37:47 +0000 Subject: [PATCH] Fix an ancient oversight in change_varattnos_of_a_node: it neglected to update varoattno along with varattno. This resulted in having Vars that were not seen as equal(), causing inheritance of the "same" constraint from different parent relations to fail. An example is create table pp1 (f1 int check (f1>0)); create table cc1 (f2 text, f3 int) inherits (pp1); create table cc2(f4 float) inherits(pp1,cc1); Backpatch as far as 7.4. (The test case still fails in 7.4, for reasons that I don't feel like investigating at the moment.) This is a backpatch commit only. The fix will be applied in HEAD as part of the upcoming pg_constraint patch. --- src/backend/commands/tablecmds.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index cd36c7c035..e0f8786507 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.174.2.5 2008/04/24 20:18:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.174.2.6 2008/05/09 22:37:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1084,7 +1084,7 @@ change_varattnos_walker(Node *node, const AttrNumber *newattno) * currently. */ Assert(newattno[var->varattno - 1] > 0); - var->varattno = newattno[var->varattno - 1]; + var->varattno = var->varoattno = newattno[var->varattno - 1]; } return false; } -- 2.40.0