Re: New thoughts about indexing cross-type comparisons

From: Kevin Brown <kevin(at)sysexperts(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: New thoughts about indexing cross-type comparisons
Date: 2003-09-17 20:04:28
Message-ID: 20030917200428.GE3845@filer
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Dave Smith <dave(dot)smith(at)candata(dot)com> writes:
> > My point was that it was inconstant behavour. What exactly are you
> > comparing with int2? To me the case without the cast should should throw
> > the same error as the statement with the cast.
>
> > select * from test where f=1981928928921;
>
> I contend not. The above is perfectly well defined. It will always
> return false if f is int2, but that does not mean it should throw an
> error instead. In any standard programming language, you'd resolve
> the operator by up-converting f to the type of the constant, not by
> trying to down-convert the wider value. PG happens to have
> implementation reasons to wish to use the variable's datatype instead
> of the constant's, but that doesn't excuse us from obeying the ordinary
> laws of arithmetic.

Hmm...but what if the cast were to return NULL in the event that the cast
fails or cannot be done? Would that even be reasonable? I don't know
what the standard says about this so my suggestion may be unreasonable
(and it may break a lot of things as well).

In a way, this would be consistent with the meaning of NULL: "no value",
and would also yield the desired effect in the example select (no
matches).

Of course, I could always be off my rocker here. :-)

--
Kevin Brown kevin(at)sysexperts(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-09-17 21:35:34 Re: New thoughts about indexing cross-type comparisons
Previous Message Tom Lane 2003-09-17 19:03:03 Re: New thoughts about indexing cross-type comparisons