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                                           [EMAIL PROTECTED]


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to