BUG #2771: NULL values in FOREIGN KEY fields - Mailing list pgsql-bugs

From vincent
Subject BUG #2771: NULL values in FOREIGN KEY fields
Date
Msg-id 200611200942.kAK9gwaK029065@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #2771: NULL values in FOREIGN KEY fields
Re: BUG #2771: NULL values in FOREIGN KEY fields
List pgsql-bugs
The following bug has been logged online:

Bug reference:      2771
Logged by:          vincent
Email address:      vincent@iim.nctu.edu.tw
PostgreSQL version: 8.x
Operating system:   windows2k
Description:        NULL values in FOREIGN KEY fields
Details:

When insert a null value in foreign key fields, an error occurs.

example table
===================
CREATE TABLE TGroup (
  C_Group_ID CHAR(8) NOT NULL,
  C_Group_Name VARCHAR(50),
  C_Group_Parent CHAR(8) NOT NULL,
  CONSTRAINT TGroup_pkey PRIMARY KEY(C_Group_ID),
  CONSTRAINT TGroup_C_Group_Parent_fkey FOREIGN KEY (C_Group_Parent)
    REFERENCES TGroup(C_Group_ID)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
    NOT DEFERRABLE
) WITHOUT OIDS;

The definition of foreign key constraint:

A FOREIGN KEY constraint does not have to be linked only to a PRIMARY KEY
constraint in another table; it can also be defined to reference the columns
of a UNIQUE constraint in another table. A FOREIGN KEY constraint can
contain null values; however, if any column of a composite FOREIGN KEY
constraint contains null values, verification of all values that make up the
FOREIGN KEY constraint is skipped. To make sure that all values of a
composite FOREIGN KEY constraint are verified, specify NOT NULL on all the
participating columns.

ref: http://msdn2.microsoft.com/en-us/library/ms175464.aspx

pgsql-bugs by date:

Previous
From: "Brahma"
Date:
Subject: BUG #2770: tomcat connection pool
Next
From: "Jonathan Ellis"
Date:
Subject: BUG #2760: log_min_duration_statement always logs to stderr