Re: Help with casting and comparing. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Help with casting and comparing.
Date
Msg-id 15364.1151507563@sss.pgh.pa.us
Whole thread Raw
In response to Re: Help with casting and comparing.  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Help with casting and comparing.
List pgsql-hackers
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Wed, Jun 28, 2006 at 03:25:57PM +0300, Tzahi Fadida wrote:
>> I need help finding out how to determine if two types are equality compatible
>> and compare them.

> Fortunatly the backend contains functions that do all this already.
> Check out parser/parse_oper.c, in particular oper() and
> compatable_oper().

Note that this still leaves the question of what operator to search for,
and where to look for it.  The current system doesn't really provide an
adequate way of identifying a suitable equality operator; you kind of
have to take it on faith that people won't have made "=" do unexpected
things (an assumption already violated by some builtin datatypes ...).
We've been moving gradually in the direction of relying on btree
operator classes to give us a better understanding of which operators
really act like equality, but it's far from all done.

The most recent thread about fixing this was
http://archives.postgresql.org/pgsql-hackers/2006-02/msg00960.php
Nothing much has been done since then as far as fixing foreign-key
checks, but you might want to look at the code for interpreting row
value comparisons (make_row_comparison_op in parse_expr.c).
SelectSortFunction in tuplesort.c is another example of looking for
btree info to infer the behavior of an operator.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: optimizing constant quals within outer joins
Next
From: Phil Frost
Date:
Subject: Re: optimizing constant quals within outer joins