Possible Addition of a CREATE TABLE Warning - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject Possible Addition of a CREATE TABLE Warning
Date
Msg-id 200103040250.f242oi364857@hub.org
Whole thread Raw
List pgsql-bugs
Austin C. Brooks (acbrooks@southern.edu) reports a bug with a severity of 4
The lower the number the more severe it is.

Short Description
Possible Addition of a CREATE TABLE Warning

Long Description
The enclosed CREATE TABLE statement attempts to create a not-nullable field that is a foreign key into another table.
Oneof the foreign key constraints, however, is that the field be set null when the referenced tuple is deleted.
Unfortunately,this action is not possible because the field is not-nullable, and thus the foreign key constraint will
failout every time.  This is expected behavior, but it might be helpful to schema designers (or newbies, as I was) if a
warningmessage indicated this possibility (ie, that the DBA would have to manually delete or alter every referencing
tuplein the table before he can delete the referenced tuple).  PostgreSQL 7.0.3 currently processes the table without
complaint,which is fine for people that understand what is happening. 

Sample Code

CREATE TABLE myTable2 (
  ...
  myField int not null,
  ...
  foreign key (myField) references (myTable1) on delete set null,
  -- 'on delete set null' will fail every time
  ...
  );


No file was uploaded with this report

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: 7.1Beta 4&5 - clean build problem with '--with-perl'
Next
From: Tom Lane
Date:
Subject: Re: 7.1Beta 4&5 - clean build problem with '--with-perl'