From: | "Matt Nourse" <matthew(at)nplus1(dot)com(dot)au> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #5477: CREATE DOMAIN NOT NULL constraints not always enforced for INSERT with subquery |
Date: | 2010-05-28 02:53:11 |
Message-ID: | 201005280253.o4S2rBR3022404@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged online:
Bug reference: 5477
Logged by: Matt Nourse
Email address: matthew(at)nplus1(dot)com(dot)au
PostgreSQL version: 8.4
Operating system: Linux (Debian and Red Hat)
Description: CREATE DOMAIN NOT NULL constraints not always enforced
for INSERT with subquery
Details:
Set up:
CREATE DOMAIN test_id_domain INT NOT NULL;
CREATE TABLE test_state(id test_id_domain PRIMARY KEY, display_value
varchar(20) NOT NULL);
CREATE TABLE test_city(state_id test_id_domain REFERENCES test_state(id));
This produces an error as expected:
INSERT INTO test_city(state_id) VALUES (NULL);
This successfully inserts a NULL value into the state_id field:
INSERT INTO test_city(state_id) VALUES ((SELECT id FROM test_state WHERE
display_value = 'Nonexistent state'));
When I use simpler subqueries (eg SELECT 1 WHERE 1 = 0), the NOT NULL
constraint is enforced.
If I remove the test_id_domain domain and replace its use with INT NOT NULL,
the constraint is enforced.
Thanks and regards,
Matt
From | Date | Subject | |
---|---|---|---|
Next Message | Markus | 2010-05-28 04:42:56 | BUG #5478: ILIKE operator returns wrong result |
Previous Message | Stephen Frost | 2010-05-28 00:30:46 | Re: PostgreSQL 9.0b1 - Error when checking table sizes |