Weirdness in CHECK?

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Pgsql-Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Weirdness in CHECK?
Date: 2001-01-04 05:06:36
Message-ID: NEBBIOAJBMEENKACLNPCOEMNCCAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-01-04 05:19:33 Re: Please review TODO list
Previous Message Philip Warner 2001-01-04 03:01:03 Re: Please review TODO list