Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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: tablecmds.c.patch
Description: text/plain (3.2 KB)

Responses

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group