"Alexander M. Pravking" <[EMAIL PROTECTED]> 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);

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to