Re: [HACKERS] DROP COLUMN round 4

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
Cc: "Patches" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] DROP COLUMN round 4
Date: 2002-08-02 18:45:16
Message-ID: 14167.1028313916@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

"Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au> writes:
> OK, in this statement:

> ALTER TABLE child ADD FOREIGN KEY (a) REFERENCES parent(b);

> It does not check that column b is not dropped (it does check "a"). It just
> relies on the UNIQUE constraint not being present on b. This should
> probably be fixed...

This is not really a case of it "relies on" that, it's just that the
check for a key is done before trying to resolve the column names to
numbers, so you get that error first. I'm not sure it's worth trying to
rearrange the code in analyze.c to avoid that. In the self-referential
case,

create table foo (id int primary key,
parent int references foo);

you more or less have to work with column names not numbers.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2002-08-02 18:46:15 Re: WAL file location
Previous Message Tom Lane 2002-08-02 18:39:42 Re: [HACKERS] DROP COLUMN round 4

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2002-08-03 01:07:54 Re: Improve CHECK failure message
Previous Message Tom Lane 2002-08-02 18:39:42 Re: [HACKERS] DROP COLUMN round 4