From: | David Gauthier <davegauthierpg(at)gmail(dot)com> |
---|---|
To: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Why is a check constraint not working ? |
Date: | 2020-04-29 15:17:40 |
Message-ID: | CAMBRECD6TcGxJPzO3WwXZ7m4Kg5qMF+My+mbxtMnwcaqwFFDtA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
psql (9.6.7, server 11.3)
I have a table...
dvdb=# \d+ dvm_events;
Table "dvm.dvm_events"
Column | Type | Modifiers | Storage | Stats
target | Description
------------------+--------------------------+-----------+----------+--------------+----------------------------------------------------------------------
dvm_id | integer | not null | plain |
|
project | character varying | not null | extended |
|
status | character varying | | extended |
|
Check constraints:
"dvm_events_status_check" CHECK (status::text = ANY
(ARRAY['passed'::character varying, 'failed'::character varying,
NULL::character varying]::text[]))
(There's a lot more to the table than what you see here, but I took it out
because it didn't look relevant)
I believe it should disallow an insert with a status of "foo", but...
dvdb=# insert into dvm_events (dvm_id,project,status) values
(99999999,'mero','foo');
INSERT 0 1
This is outside of a transaction and definitely not in a transaction with
deferred constraint checking.
Check constraints seem to work fine if I create a test table having a
constrained column. But this existing table seems to have constraints
disabled for some reason.
What could cause this ?
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2020-04-29 15:19:53 | Re: Why is a check constraint not working ? |
Previous Message | Durgamahesh Manne | 2020-04-29 11:26:15 | Regarding db performance improvement |