Skip site navigation (1) Skip section navigation (2)

Re: Weirdness in CHECK?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
Cc: "Pgsql-Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Weirdness in CHECK?
Date: 2001-01-04 05:27:28
Message-ID: 20072.978586048@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
"Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au> writes:
> 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!

I think some people feel that we ought to raise an error rather than
silently truncating the input.  However, given that we do intend to
truncate the input, it seems to me that applying CHECK constraints
post-truncation is the Right Thing.  In general a CHECK ought to be
applied after any conversion ops needed to create a value of the
destination column type.  For example, if I had "CHECK (foo < 1)"
on a column foo declared NUMERIC(3,2), I'd be unhappy if the input
"0.999" got past the check because it was rounded to 1.00 only after
the CHECK was applied.

			regards, tom lane

In response to

pgsql-hackers by date

Next:From: Tatsuo IshiiDate: 2001-01-04 05:39:12
Subject: Re: Please review TODO list
Previous:From: Christopher Kings-LynneDate: 2001-01-04 05:26:28
Subject: Re: Weirdness in CHECK?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group