Thread: alter table

alter table

From
"Diego Cattelan"
Date:
template1=3D#create database gesart;
template1=3D#create user xuser;
template1=3D# \c gesart xuser
=20
gesart=3D>create table a(n integer);
=20
CREATE TABLE
gesart=3D>alter table a add column c integer references xxxxxxx(id);
=20
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ALTER TABLE
=20
The table xxxxxxx doesn't exist.
=20
Is that correct or postgreSQL should report an error ?
=20
 PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2
20020903 (Red Hat Linux 8.0 3.2-7)

Re: alter table

From
Tom Lane
Date:
"Diego Cattelan" <netmaniac@libero.it> writes:
> gesart=3D>alter table a add column c integer references xxxxxxx(id);
> =20
> NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
> ALTER TABLE
> =20
> The table xxxxxxx doesn't exist.
> =20
> Is that correct or postgreSQL should report an error ?

It is an error.  7.3.* has a bug with ALTER TABLE ADD COLUMN: any
foreign-key reference clauses are ignored.  This is fixed for 7.3.3.

            regards, tom lane