1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-07 12:02:30 +03:00

Code review for domain-constraints patch. Use a new ConstraintTest node

type for runtime constraint checks, instead of misusing the parse-time
Constraint node for the purpose.  Fix some damage introduced into type
coercion logic; in particular ensure that a coerced expression tree will
read out the correct result type when inspected (patch had broken some
RelabelType cases).  Enforce domain NOT NULL constraints against columns
that are omitted from an INSERT.
This commit is contained in:
Tom Lane
2002-08-31 22:10:48 +00:00
parent 1440acd703
commit 845a6c3acc
19 changed files with 335 additions and 176 deletions

View File

@@ -41,8 +41,7 @@ select * from basictest;
(2 rows)
-- check that domains inherit operations from base types
-- XXX shouldn't have to quote the constant here
select testtext || testvarchar as concat, testnumeric + '42' as sum
select testtext || testvarchar as concat, testnumeric + 42 as sum
from basictest;
concat | sum
-----------+--------
@@ -99,7 +98,7 @@ create table nulltest
, col4 dnull
);
INSERT INTO nulltest DEFAULT VALUES;
ERROR: ExecInsert: Fail to add null value in not null attribute col3
ERROR: Domain dnotnull does not allow NULL values
INSERT INTO nulltest values ('a', 'b', 'c', 'd'); -- Good
INSERT INTO nulltest values (NULL, 'b', 'c', 'd');
ERROR: Domain dnotnull does not allow NULL values
@@ -147,7 +146,7 @@ create table defaulttest
, col5 ddef1 NOT NULL DEFAULT NULL
, col6 ddef2 DEFAULT '88'
, col7 ddef4 DEFAULT 8000
, col8 ddef5
, col8 ddef5
);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'defaulttest_pkey' for table 'defaulttest'
insert into defaulttest default values;

View File

@@ -38,8 +38,7 @@ INSERT INTO basictest values ('88', 'haha', 'short', '123.1212'); -- Truncate
select * from basictest;
-- check that domains inherit operations from base types
-- XXX shouldn't have to quote the constant here
select testtext || testvarchar as concat, testnumeric + '42' as sum
select testtext || testvarchar as concat, testnumeric + 42 as sum
from basictest;
drop table basictest;