Re: [BUGS] BUG #5053: domain constraints still leak

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Sam Mason" <sam(at)samason(dot)me(dot)uk>, "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [BUGS] BUG #5053: domain constraints still leak
Date: 2009-09-15 03:20:59
Message-ID: 26177.1252984859@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

[ probably time to move this thread to -hackers ]

There is some moderately interesting reading material in section
4.17.4 "Domain constraints" of SQL:2008. In particular, it appears to
me that the standard goes out of its way to NOT claim that every value
that "is of" a domain type satisfies the domain's constraints. It looks
to me that the implementation they have in mind is that domain
constraints are to be checked:

(1) when a value is assigned to a *table* column having that domain type;

(2) when a value is converted to that domain type by an *explicit*
cast construct;

(3) nowhere else.

If I'm reading this right, it sidesteps most of the concerns we have
been worrying about here, at the cost of being perhaps more surprising
and less useful than one would expect. It would also mean that a lot
of our existing domain behavior is wrong. I think there is ammunition
here for an argument that, in effect, values "in flight" in expression
or query evaluation should always be considered to be of base types,
and domain constraints should only be checked when assigning to a
persistent storage location such as a table field or plpgsql variable
(plus the special case for CAST constructs).

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Gierth 2009-09-15 04:13:21 Re: [BUGS] BUG #5053: domain constraints still leak
Previous Message Robert Haas 2009-09-15 02:51:28 Re: BUG #5056: SQLDescribeColW for function returning a result set incorrectly setting sql_nullable

Browse pgsql-hackers by date

  From Date Subject
Next Message Itagaki Takahiro 2009-09-15 03:49:49 Re: Encoding issues in console and eventlog on win32
Previous Message Robert Haas 2009-09-15 03:15:17 Re: Resjunk sort columns, Heikki's index-only quals patch, and bug #5000