BUG #4888: Removed brackets from Check Constraints expressions
BUG #4888: Removed brackets from Check Constraints expressions
От:
"stalker" <chimera@bk.ru>
Дата:
The following bug has been logged online: Bug reference: 4888 Logged by: stalker Email address: chimera@bk.ru PostgreSQL version: 8.3.7 Operating system: Debian 4.0 (etch) Description: Removed brackets from Check Constraints expressions Details: I try to create Check Constraints for DB with Nested Set data model. When I write complex validation rule with OR-operator - result Description is incorrect. CREATE TABLE Catalog ( id integer, id_lft integer, -- nested set id_rgt integer, ); ALTER TABLE Catalog ADD CONSTRAINT ctg_check_ns CHECK (id_lft > id_rgt OR (id_lft = 0 AND id_lft = 0)); Result: 'ctg_check_ns' Definition == "id_lft > id_rgt OR id_lft = 0 AND id_lft = 0".
Re: BUG #4888: Removed brackets from Check Constraints expressions
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"stalker" writes: > I try to create Check Constraints for DB with Nested Set data model. When I > write complex validation rule with OR-operator - result Description is > incorrect. > ALTER TABLE Catalog > ADD CONSTRAINT ctg_check_ns CHECK (id_lft > id_rgt OR (id_lft = 0 AND > id_lft = 0)); > Result: > 'ctg_check_ns' Definition == "id_lft > id_rgt OR id_lft = 0 AND id_lft = > 0". Looks perfectly correct to me. AND binds more tightly than OR. regards, tom lane