is not distinct from any(...)

Started by Robert Haasover 17 years ago2 messagesgeneral
Jump to latest
#1Robert Haas
robertmhaas@gmail.com

I'm trying to write a SQL statement to determine whether a value is an
an array, but I want the comparison to be done using IS NOT DISTINCT
FROM rather than =.

My first thought was that instead of writing:

SELECT value = ANY(array)

...I could simply write:

SELECT value IS NOT DISTINCT FROM ANY(array)

That doesn't seem to work, because IS NOT DISTINCT FROM is not an
operator. So then I tried creating an operator === (anyelement,
anyelement) that just does IS NOT DISTINCT FROM and writing:

select 1 === any(array[1]);

which got me:

ERROR: could not find array type for data type anyelement

Grr... any suggestions?

...Robert

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#1)
Re: is not distinct from any(...)

"Robert Haas" <robertmhaas@gmail.com> writes:

That doesn't seem to work, because IS NOT DISTINCT FROM is not an
operator.

Yah :-(

So then I tried creating an operator === (anyelement,
anyelement) that just does IS NOT DISTINCT FROM and writing:
select 1 === any(array[1]);
which got me:
ERROR: could not find array type for data type anyelement

FWIW, it seems to work in 8.3.

regards, tom lane