Thread: [Fwd: [HACKERS] Coerce to Domain]
Patch moves evaluation of the domain (seek for list of constraints) out of the parser and into the executor. Note that in the below test the domain isn't on the table -- but is in the view which shows rules are altered appropriately for the domain change. -- Confirm ALTER DOMAIN with RULES. create table domtab (col1 integer); create domain dom as integer; create view domview as select cast(col1 as dom) from domtab; insert into domtab (col1) values (null); insert into domtab (col1) values (5); select * from domview; col1 ------ 5 (2 rows) alter domain dom set not null; select * from domview; -- fail ERROR: Domain dom does not allow NULL values alter domain dom drop not null; select * from domview; col1 ------ 5 (2 rows) alter domain dom add constraint domchkgt6 check(value > 6); select * from domview; --fail ERROR: ExecEvalConstraintTest: Domain dom constraint domchkgt6 failed alter domain dom drop constraint domchkgt6 restrict; select * from domview; col1 ------ 5 (2 rows) -- Rod Taylor <rbt@rbt.ca> PGP Key: http://www.rbt.ca/rbtpub.asc
Attachment
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches I will try to apply it within the next 48 hours. --------------------------------------------------------------------------- Rod Taylor wrote: -- Start of PGP signed section. > Patch moves evaluation of the domain (seek for list of constraints) out > of the parser and into the executor. > > > Note that in the below test the domain isn't on the table -- but is in > the view which shows rules are altered appropriately for the domain > change. > > > > > -- Confirm ALTER DOMAIN with RULES. > create table domtab (col1 integer); > create domain dom as integer; > create view domview as select cast(col1 as dom) from domtab; > insert into domtab (col1) values (null); > insert into domtab (col1) values (5); > select * from domview; > col1 > ------ > > 5 > (2 rows) > > alter domain dom set not null; > select * from domview; -- fail > ERROR: Domain dom does not allow NULL values > alter domain dom drop not null; > select * from domview; > col1 > ------ > > 5 > (2 rows) > > alter domain dom add constraint domchkgt6 check(value > 6); > select * from domview; --fail > ERROR: ExecEvalConstraintTest: Domain dom constraint domchkgt6 failed > alter domain dom drop constraint domchkgt6 restrict; > select * from domview; > col1 > ------ > > 5 > (2 rows) > > > -- > Rod Taylor <rbt@rbt.ca> > > PGP Key: http://www.rbt.ca/rbtpub.asc [ Attachment, skipping... ] -- End of PGP section, PGP failed! -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Tom has applied this patch. Thanks. --------------------------------------------------------------------------- Rod Taylor wrote: -- Start of PGP signed section. > Patch moves evaluation of the domain (seek for list of constraints) out > of the parser and into the executor. > > > Note that in the below test the domain isn't on the table -- but is in > the view which shows rules are altered appropriately for the domain > change. > > > > > -- Confirm ALTER DOMAIN with RULES. > create table domtab (col1 integer); > create domain dom as integer; > create view domview as select cast(col1 as dom) from domtab; > insert into domtab (col1) values (null); > insert into domtab (col1) values (5); > select * from domview; > col1 > ------ > > 5 > (2 rows) > > alter domain dom set not null; > select * from domview; -- fail > ERROR: Domain dom does not allow NULL values > alter domain dom drop not null; > select * from domview; > col1 > ------ > > 5 > (2 rows) > > alter domain dom add constraint domchkgt6 check(value > 6); > select * from domview; --fail > ERROR: ExecEvalConstraintTest: Domain dom constraint domchkgt6 failed > alter domain dom drop constraint domchkgt6 restrict; > select * from domview; > col1 > ------ > > 5 > (2 rows) > > > -- > Rod Taylor <rbt@rbt.ca> > > PGP Key: http://www.rbt.ca/rbtpub.asc [ Attachment, skipping... ] -- End of PGP section, PGP failed! -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073