From: irina.guberman@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #13665: Foreign Key constraint doesn't work
Date: Tue, 06 Oct 2015 22:42:12 +0000
Message-ID: <20151006224212.632.12147@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 13665
Logged by: Irina
Email address: irina.guberman@gmail.com
PostgreSQL version: 9.4.4
Operating system: Mac
Description:
I can enter rows with null value in a foreign key constrained column. I
ran into this with my own schema, but then tried examples straight out of
PostgreSQL constraints documentation
http://www.postgresql.org/docs/9.4/static/ddl-constraints.html and was able
to reproduce it:
CREATE TABLE products (
product_no integer PRIMARY KEY,
name text,
price numeric
);
CREATE TABLE orders (
order_id integer PRIMARY KEY,
product_no integer REFERENCES products (product_no),
quantity integer
);
-- INSERT order WITHOUT product_no
insert into orders(order_id, quantity) values(123,10)
Query returned successfully: one row affected, 13 ms execution time.
select * from orders;
returns the one row entered above
Despite the documentation (and general sql knowledge):
"Now it is impossible to create orders with non-NULL product_no entries that
do not appear in the products table.
We say that in this situation the orders table is the referencing table and
the products table is the referenced table. Similarly, there are referencing
and referenced columns."
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: irina.guberman@gmail.com
Subject: Re: BUG #13665: Foreign Key constraint doesn't work
In-Reply-To: <20151006224212.632.12147@wrigleys.postgresql.org>
References: <20151006224212.632.12147@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox