Patch for ALTER TABLE / TYPE

From: NAKANO Yoshihisa <nakano(dot)yosihisa(at)jp(dot)fujitsu(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Patch for ALTER TABLE / TYPE
Date: 2006-01-27 13:49:12
Message-ID: 43DA24D8.2050407@jp.fujitsu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Hi,

Please find the patch attached. This is for the bug which is posted to
hackers before.
http://archives.postgresql.org/pgsql-hackers/2005-06/msg01442.php

We can see a problem by this bug in following way.

CREATE TABLE pktable (a int primary key);
CREATE TABLE fktable (b int references pktable);
ALTER TABLE pktable ALTER COLUMN a TYPE bigint; -- succeed
REINDEX TABLE pg_depend;
ALTER TABLE pktable ALTER COLUMN a TYPE int; -- fail
NOTICE: constraint fktable_b_fkey on table fktable depends on index
pktable_pkey
ERROR: cannot drop constraint pktable_pkey on table pktable because
other objects depend on it
HINT: Use DROP ... CASCADE to drop the dependent objects too.

I changed the order of constraints list to delete foreign key
constraints first.

Any comments are welcome.

Regards,
Nakano

Attachment Content-Type Size
tablecmds.c.patch text/plain 3.2 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-01-27 15:09:00 Re: Adding a --quiet option to initdb
Previous Message Junji TERAMOTO 2006-01-27 10:38:37 BTree vacuum before page splitting