BUG #1433: domain check constraint not checked when adding new column

Started by craigpabout 21 years ago3 messagesbugs
Jump to latest
#1craigp
craigp98072@yahoo.com

The following bug has been logged online:

Bug reference: 1433
Logged by: craig perras
Email address: craigp98072@yahoo.com
PostgreSQL version: 8.0 release
Operating system: win2000
Description: domain check constraint not checked when adding new
column
Details:

Domain check constraint not checked when adding new column.

repro:
add domain 'string' of base type text with non-null constraint
add column of type 'string' to table with existing rows
works; all rows have new column's value set to null

expected:
error: cannot add column due to non-null constraint in domain 'string'

notes:
could not insert a new row with non-null value for 'string' column (as
expected)
trying to add a column of type text with non-null constraint produces
expected error message

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: craigp (#1)
Re: BUG #1433: domain check constraint not checked when adding new column

"craig perras" <craigp98072@yahoo.com> writes:

Domain check constraint not checked when adding new column.

Hmm. It does work for cases like

regression=# create domain posint int check (value > 0);
CREATE DOMAIN
regression=# alter table foo add column f5 posint default 0;
ERROR: value for domain posint violates check constraint "posint_check"

I think the issue is that when you don't specify any default, the scan
of the table gets optimized away.

regards, tom lane

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: craigp (#1)
Re: BUG #1433: domain check constraint not checked when adding new column

"craig perras" <craigp98072@yahoo.com> writes:

add domain 'string' of base type text with non-null constraint
add column of type 'string' to table with existing rows
works; all rows have new column's value set to null

Fixed for 8.0.1.

regards, tom lane