ALTER TABLE RENAME fix

From: Brent Verner <brent(at)rcfile(dot)org>
To: pgsql-patches(at)postgresql(dot)org
Subject: ALTER TABLE RENAME fix
Date: 2001-11-10 10:58:17
Message-ID: 20011110055817.A69633@rcfile.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

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

Attachment Content-Type Size
pgsql-1.diff text/plain 1.4 KB
pgsql-2.diff text/plain 9.2 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2001-11-10 19:21:30 Re: ALTER TABLE RENAME fix
Previous Message Klaus Naumann 2001-11-09 21:02:38 Re: Patch for Makefile race against current cvs