These patches fix the problem where an
ALTER TABLE <table> RENAME <oldcolumn> TO <newcolumn>
did not update the RI_ triggers if the oldcolumn was referenced in
a RI constraint. The net effect of these patches is that the following
sql now works.
create table parent (id int UNIQUE);
create table child (id int references parent(id) on update cascade);
alter table parent rename id to hello;
insert into parent values(1);
insert into child values(1);
The first patch (pgsql-1.diff) moves the defines for the RI_ function
args to an include, instead of just being local definitions. It also
changes the name of one of the defines and adds another define so that
all function args in the pg_trigger.tgargs bytea are #defined.
The second patch (pgsql-2.diff) adds a function update_trigger_tgargs().
See comments in the file for explanation. This code could /really/ use
a sanity check by someone with more C-foo than I have, to make sure I'm
not doing anything blatantly wrong. Also, I'm directly creating a
varlena type, which I'm a bit uncomfortable with, so if there is a
utility to create these (without creating a char* for use with
byteain()), I'd appreciate you pointing me towards that, and I'll
resubmit a better patch.
I have not exhaustively tested this code, but everything I've thrown
at it does the right thing, and no regression failures are caused.
I'll work on regression tests after some sleep ;-)
cheers.
brent
--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing." -- Duane Allman