Re: comparing rows - Mailing list pgsql-hackers

From Tom Lane
Subject Re: comparing rows
Date
Msg-id 3491.965266598@sss.pgh.pa.us
Whole thread Raw
In response to comparing rows  (Tatsuo Ishii <t-ishii@sra.co.jp>)
List pgsql-hackers
Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> test=# select (1,2,null) = (1,2,null);
> ERROR:  Unable to identify an operator '=' for types 'unknown' and 'unknown'
>     You will have to retype this query using an explicit cast

Well, there's no basis for deciding what the datatype of the third
column is.

The only reason you don't get the same error from the non-row case

regression=# select null = null;?column?
----------t
(1 row)

is that we have an ugly, horrible kluge in the parser to (mis) interpret
"foo = null" as meaning "foo ISNULL", in order to be compatible with
broken Microsoft SQL implementations.  If you try any other operator
you get

regression=# select null <> null;
ERROR:  Unable to identify an operator '<>' for types 'unknown' and 'unknown'       You will have to retype this query
usingan explicit cast
 

I'd certainly not vote to propagate the "= null" kluge into the
row-equality code...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: comparing rows
Next
From: Thomas Swan
Date:
Subject: Re: random() function produces wrong range