From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Alexander M(dot) Pravking" <fduch(at)antar(dot)bryansk(dot)ru> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: Problems renaming referencing column |
Date: | 2004-07-17 17:30:51 |
Message-ID: | 15516.1090085451@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
"Alexander M. Pravking" <fduch(at)antar(dot)bryansk(dot)ru> writes:
> In 7.4.3, if I rename a column which references another table,
> constraint trigger fails on update or delete from main table.
The following patch (against 7.4.*) appears to fix this problem.
regards, tom lane
Index: tablecmds.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/commands/tablecmds.c,v
retrieving revision 1.91
diff -c -r1.91 tablecmds.c
*** tablecmds.c 13 Oct 2003 22:47:15 -0000 1.91
--- tablecmds.c 17 Jul 2004 17:16:36 -0000
***************
*** 1534,1539 ****
--- 1534,1553 ----
CatalogUpdateIndexes(tgrel, tuple);
+ /*
+ * Invalidate trigger's relation's relcache entry so that other
+ * backends (and this one too!) are sent SI message to make them
+ * rebuild relcache entries. (Ideally this should happen
+ * automatically...)
+ *
+ * We can skip this for triggers on relid itself, since that
+ * relcache flush will happen anyway due to the table or column
+ * rename. We just need to catch the far ends of RI relationships.
+ */
+ pg_trigger = (Form_pg_trigger) GETSTRUCT(tuple);
+ if (pg_trigger->tgrelid != relid)
+ CacheInvalidateRelcache(pg_trigger->tgrelid);
+
/* free up our scratch memory */
pfree(newtgargs);
heap_freetuple(tuple);
From | Date | Subject | |
---|---|---|---|
Next Message | PostgreSQL Bugs List | 2004-07-18 14:12:07 | BUG #1195: foreignkey-bug |
Previous Message | Tom Lane | 2004-07-17 16:12:00 | Re: Problems renaming referencing column |