Inconsistent behavior on Array & Is Null?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Inconsistent behavior on Array & Is Null?
Date: 2004-03-30 19:34:15
Message-ID: 200403301134.15409.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Joe,

First off, pardon me if these are known things which are already fixed in CVS.
Also, let me again thank you for all the work on Arrays in 7.4; I've been
able to tremendously simplify quite a number of procedures in my databases
thanks to the new array support.

Now, the issue:
I'm noticing some inconsistent behavior regarding empty arrays and IS NULL
status. For example:

net_test=# select array_upper('{}'::INT[], 1);
array_upper
-------------

(1 row)

net_test=# select array_upper('{}'::INT[], 1) IS NULL;
?column?
----------
t
(1 row)

net_test=# select '{}'::INT[] IS NULL;
?column?
----------
f
(1 row)

I feel that this is confusing; an empty array should be considered NULL
everywhere or nowhere. For that matter, the new array declaration syntax
does not support empty arrays:

net_test=# select ARRAY[ ]::INT[];
ERROR: syntax error at or near "]" at character 15
net_test=# select ARRAY[]::INT[];
ERROR: syntax error at or near "]" at character 14
net_test=#

--
-Josh Berkus
Aglio Database Solutions
San Francisco

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2004-03-30 19:46:20 Re: Transaction question
Previous Message Joe Conway 2004-03-30 19:12:29 cvs HEAD regression