Tom Lane wrote: > Works for me: > > regression=# create domain dint as int not null; > CREATE DOMAIN > regression=# create table t1 (f1 dint); > CREATE TABLE > regression=# create view v1 as select * from t1; > CREATE VIEW > regression=# create rule r1 as on insert to v1 do instead > regression-# insert into t1 values(new.f1); > CREATE RULE > regression=# insert into v1 values(1); > INSERT 0 1 > regression=# insert into v1 values(null); > ERROR: domain dint does not allow null values > regression=# > > How about a test case? > > regards, tom lane > >
You need to modify your test case slightly. test=# create domain dint as int not null; CREATE DOMAIN test=# create table t1 (f1 dint, f2 dint); CREATE TABLE test=# create view v1 as select * from t1; CREATE VIEW test=# create rule r1 as on insert to v1 do instead test-# insert into t1 values (new.f1, new.f2); CREATE RULE test=# insert into v1 values( 1 ); INSERT 0 1 test=# select * from v1; f1 | f2 ----+---- 1 | (1 row) Notice that f2 has a null value even though the domain constraint should forbid it. Now try this: test=# delete from t1; DELETE 1 test=# alter table t1 alter column f2 set not null; ALTER TABLE test=# insert into v1 values( 1 ); ERROR: null value in column "f2" violates not-null constraint Having the constraint on the column correctly forbids the NULL value. For now I have tagged all columns with the NOT NULL constraint individually, but I think this should be fixed. John Supplee ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match