Skip site navigation (1) Skip section navigation (2)

Overlap operators for ARRAY and NULLs

From: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Overlap operators for ARRAY and NULLs
Date: 2010-11-17 11:33:55
Message-ID: AANLkTikL_DRkvwWPtigkR-UU-f5+Et_XDdJU+C7XLX7z@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
There might be inconsistency in overlap operators for array
types ( <@, @>, and && ) when the argument arrays contain NULLs.

- SELECT 2 = ANY (ARRAY[1, NULL])   => NULL
- SELECT ARRAY[2] <@ ARRAY[1, NULL] => false

NULL means "unknown" in definition, so should it return NULL
rather than false?

I found the issue when I read spec of MULTISET. In the SQL
standard, the following expression returns NULL. I was thinking
to make SUBMULTISET OF to be an alias of <@ operator, but
they seems to be incompatible.

- MULTISET[2] SUBMULTISET OF MULTISET[1, NULL] => NULL

Will we change the operator's behavior? It would be more
consistent, but incompatible with older server versions.
If impossible, I'll add separated submultiset_of() function
instead of <@ operator for MULTISET supports.

-- 
Itagaki Takahiro

Responses

pgsql-hackers by date

Next:From: Alvaro HerreraDate: 2010-11-17 12:27:06
Subject: Re: changing MyDatabaseId
Previous:From: Markus WannerDate: 2010-11-17 11:32:43
Subject: Re: changing MyDatabaseId

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group