Re: Domain breakage

From: Kevin Brown <kevin(at)sysexperts(dot)com>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Domain breakage
Date: 2003-03-31 08:35:09
Message-ID: 20030331083509.GJ1833@filer
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sysexperts(dot)com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Brown 2003-03-31 11:47:08 Re: Roadmap for FE/BE protocol redesign
Previous Message Olleg Samojlov 2003-03-31 07:08:33 Re: Changing behavior of BEGIN...sleep...do something...COMMIT