Weirdness in CHECK? - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Weirdness in CHECK?
Date
Msg-id NEBBIOAJBMEENKACLNPCOEMNCCAA.chriskl@familyhealth.com.au
Whole thread Raw
Responses Re: Weirdness in CHECK?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I just ran across this recent example:

If you perform the following, you get a truncated input:

test=# create table example (type char(5) NOT NULL);
CREATE
test=# insert into example VALUES ('VOLUME');
INSERT 156884 1
test=# select * from example;type
-------VOLUM
(1 row)

However, if you add CHECK in that checks for a string that is LONGER than
the CHAR(5), you get this:

test=# create table example(type char(5) NOT NULL CHECK (type IN
('MASS','VOLUME')));
CREATE
test=# insert into example VALUES ('VOLUME');
ERROR:  ExecAppend: rejected due to CHECK constraint example_type

Is this correct behaviour?  Perhaps it is, as CHECK is checking the
truncated value - but I just want to make sure it's not a bug!

Chris



pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: Please review TODO list
Next
From: Tom Lane
Date:
Subject: Re: Please review TODO list