Re: [HACKERS] Domains and type coercion

2002-03-21 Thread Tom Lane
"Rod Taylor" <[EMAIL PROTECTED]> writes: > It would be fairly straight forward to simply copy the domain base > type into the atttypid, then create an atttypdomain (normally 0, > except in the case of a domain). Everything would use the attypid, > except for \d and pg_dump which could use the do

Re: [HACKERS] Domains and type coercion

2002-03-21 Thread Rod Taylor
> If we take the hard SQL99 line that domains *are* the base type plus > constraints, then we could reduce domains to base types before we start > the entire matching process, and this issue would go away. This would > prevent declaring any specialized operators or functions for a domain. > (In f

Re: [HACKERS] Domains and type coercion

2002-03-21 Thread Fernando Nasser
Tom Lane wrote: > > If we take the hard SQL99 line that domains *are* the base type plus > constraints, then we could reduce domains to base types before we start > the entire matching process, and this issue would go away. This would > prevent declaring any specialized operators or functions fo

Re: [HACKERS] Domains and type coercion

2002-03-21 Thread Tom Lane
Thomas Lockhart <[EMAIL PROTECTED]> writes: >> We could treat exact and binary-compatible matches alike (doesn't seem >> good), or put a special case into the operator selection rules to reduce >> domains to their basetypes before making the "exact match" test. > There could also be an explicit h

Re: [HACKERS] Domains and type coercion

2002-03-21 Thread Thomas Lockhart
... > The problem seems to be that when parse_func looks for "exact match" > operators, it doesn't consider numeric to be an exact match for mydom. > So that heuristic fails and we're left with no unique best choice for > the operator. Sure. At the moment there is no reason for parse_func to thin

Re: [HACKERS] Domains and type coercion

2002-03-20 Thread Fernando Nasser
Tom Lane wrote: > > Any thoughts? > As we are talking about CAST, if one CASTs to a domain, SQL99 says we have to check the constraints and issue a "integrity constraint violation" if appropriate (6.22, GR 21). -- Fernando Nasser Red Hat - Toronto E-Mail: [EMAIL PROTE

Re: [HACKERS] Domains and type coercion

2002-03-20 Thread Fernando Nasser
Tom Lane wrote: > > (...) or put a special case into the operator selection rules to reduce > domains to their basetypes before making the "exact match" test. By definition, which I believe should be read as "A domain is a set of permissible values (of a data type)". What I am trying to sa

Re: [HACKERS] Domains and type coercion

2002-03-20 Thread Tom Lane
I wrote: > I am thinking that a non-broken approach would involve (1) treating > a domain as binary-compatible with its base type, and therefore with > all other domains on the same base type, and (2) allowing a coercion > function that produces the base type to be used to produce the domain > typ

Re: [HACKERS] Domains and type coercion

2002-03-19 Thread Rod Taylor
> I am thinking that a non-broken approach would involve (1) treating > a domain as binary-compatible with its base type, and therefore with > all other domains on the same base type, and (2) allowing a coercion > function that produces the base type to be used to produce the domain > type. (The

[HACKERS] Domains and type coercion

2002-03-19 Thread Tom Lane
The DOMAIN patch is completely broken when it comes to type coercion behavior. For one thing, it doesn't know that any operators or functions on a domain's base type can be used with a domain: domain=# create domain zip as char(2); CREATE domain=# create table foo (f1 zip); CREATE domain=# selec