Re: Domain breakage - Mailing list pgsql-hackers

From Kevin Brown
Subject Re: Domain breakage
Date
Msg-id 20030331083509.GJ1833@filer
Whole thread Raw
In response to Domain breakage  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> A different line of attack would be to modify the operator/function
> resolution rules to take account of domain relationships explicitly,
> making the binding of domain to base type stronger than mere binary
> equivalence.  But I'm not clear how that might work.
> 
> Any ideas?

In oper_select_candidate(), where it checks whether or not the input
type is binary coercible , you could change the "best match"
computation (line 454 of CVS tip as of now) to read as follows:

nmatch = 0;
for (i = 0; i < nargs; i++)
{   if (input_typeids[i] != UNKNOWNOID)   {       if (IsBinaryCoercible(input_typeids[i], current_typeids[i]))
nmatch += nargs;if (IsDomainBaseTypeFor(input_typeids[i], current_typeids[i]) ||
IsDomainBaseTypeFor(current_typeids[i],input_typeids[i]))           nmatch++;   }
 
}


And then define a function, IsDomainBaseTypeFor(), which returns a
bool indicating whether or not the first argument is the domain base
type for the second argument (if we already have a function that will
do this job, we can use it instead).

The idea here is that a domain binding will increase the "score" of
the entry, but the maximum number of such bindings can never outweigh
an additional binary coercible argument.  That relative weighting may
be too extreme, but would definitely serve to handle the example
problem you provided.


-- 
Kevin Brown                          kevin@sysexperts.com



pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: A few questions:
Next
From: Kevin Brown
Date:
Subject: Re: Detecting corrupted pages earlier