Ongoing issues with representation of empty arrays

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Ongoing issues with representation of empty arrays
Date: 2017-04-11 00:57:09
Message-ID: 878tn7x1hn.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The distinction between the standard representation of '{}' as an array
with zero dimensions and nonstandard representations as a 1-dimensional
array with zero elements has come up in a couple of contexts on the IRC
channel recently.

First is contrib/intarray, _AGAIN_ (see past bugs such as #7730):

select array_dims(('{1,2}'::integer[] & '{3}'));
array_dims
------------
[1:0]
(1 row)

regression=# select ('{1,2}'::integer[] & '{3}') = '{}';
?column?
----------
f
(1 row)

Worse, the fact that the fix for #7730 (commit c155f654) only did a
very partial job means that it's now inconsistent:

regression=# select (a - b), (a & c), (a - b) = (a & c)
from (values (array[1,2],array[1,2],array[3])) v(a,b,c);
?column? | ?column? | ?column?
----------+----------+----------
{} | {} | f
(1 row)

I plan to fix this one properly, unless anyone has any objections.

Second is aclitem[], past bug #8395 which was not really resolved; empty
ACLs are actually 1-dim arrays of length 0, and all the ACL functions
insist on that, which means that you can't call aclexplode('{}') for
example:

https://www.postgresql.org/message-id/flat/CA%2BTgmoZdDpTJDUVsgzRhoCctidUqLDyO8bdYwgLD5p8DwHtMcQ%40mail.gmail.com

It's much less clear what to do about this one. Thoughts?

--
Andrew (irc:RhodiumToad)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-04-11 01:25:14 Re: SUBSCRIPTIONS and pg_upgrade
Previous Message Kyotaro HORIGUCHI 2017-04-11 00:56:06 Re: WAL logging problem in 9.4.3?