Re: BUG #8395: empty aclitem arrays are considered 1-dimensional

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Alexey Bashtanov <bashtanov(at)imap(dot)cc>, Postgres-Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #8395: empty aclitem arrays are considered 1-dimensional
Date: 2014-02-05 14:29:04
Message-ID: CA+TgmoZdDpTJDUVsgzRhoCctidUqLDyO8bdYwgLD5p8DwHtMcQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Jan 31, 2014 at 6:37 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> On Fri, Aug 23, 2013 at 04:17:55PM +0000, bashtanov(at)imap(dot)cc wrote:
>> The following bug has been logged on the website:
>>
>> Bug reference: 8395
>> Logged by: Alexey Bashtanov
>> Email address: bashtanov(at)imap(dot)cc
>> PostgreSQL version: 9.1.9
>> Operating system: Ubuntu linux 12.04
>> Description:
>>
>> Empty aclitem arrays are considered 1-dimensional, but in general empty
>> arrays are 0-dimensional. It leads to the following problems:
>>
>>
>> STEPS TO REPRODUCE
>> 1) install fresh postgres, connect to it
>> 2) select relacl, relacl = '{}'::aclitem[], (select aclexplode(relacl)),
>> array_length(relacl, 1) from pg_class where oid::regclass =
>> 'pg_largeobject'::regclass;
>> 3) select aclexplode('{}'::aclitem[]);
>>
>>
>> EXPECTED
>> 2) {}, false, null, null
>> 3) no error, zero-lines table
>>
>>
>> GOT
>> 2) relacl | ?column? | ?column? | array_length
>> --------+----------+----------+--------------
>> {} | f | | 0
>> 3) ERROR: ACL arrays must be one-dimensional
>>
>>
>> also it can be reproduced on some 9.2 version
>
> Can someone comment on this bug report?

It looks legit on first glance. Probably there's code someplace that
is setting ndims to 1 unconditionally, instead of setting it to 1 when
there are elements and 0 when there are none. On the other hand,
changing that might break things too, because I'm fairly sure we have
code in a variety of places that verifies that arrays in system
catalogs are always 1-D. So fixing this could be quite a chore.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2014-02-05 15:39:47 Re: Update with subselect sometimes returns wrong result
Previous Message Robert Haas 2014-02-05 14:22:18 Re: Update with subselect sometimes returns wrong result