BUG #15259: intarray extension operator "&" produces invalid dimensions [1:0] for empty arrays

Started by PG Bug reporting formalmost 8 years ago1 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 15259
Logged by: Alexey Kryuchkov
Email address: alexey.kruchkov@gmail.com
PostgreSQL version: 10.4
Operating system: verified on Ubuntu 14.04, 17.10
Description:

Intarray extension operator '&' returns empty arrays of invalid size, which
are
not equal to 'normal' empty arrays despite having the same textual
representation:

test=# CREATE TABLE a AS SELECT '{1}'::int[] & '{2}'::int[] AS x;
SELECT 1

test=# SELECT x, x = '{}', ARRAY_DIMS(x) FROM a;
x | ?column? | array_dims
----+----------+------------
{} | f | [1:0]
(1 row)

For comparison, operator '-' behaves correctly:

test=# CREATE TABLE b AS SELECT '{1}'::int[] - '{1}'::int[] AS x;
SELECT 1

test=# SELECT x, x = '{}', ARRAY_DIMS(x) FROM b;
x | ?column? | array_dims
----+----------+------------
{} | t |
(1 row)

This can be reproduced with both Postgres 10.4 and Postgres 11-beta1 (from
Docker library/postgres:11-beta1 image).

test=# SELECT version();
version

-----------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 10.4 (Ubuntu 10.4-2.pgdg14.04+1) on x86_64-pc-linux-gnu,
compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4, 64-bit
(1 row)

postgres=# SELECT version();

version

-----------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 11beta1 (Debian 11~beta1-2.pgdg90+1) on x86_64-pc-linux-gnu,
compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit
(1 row)

Looking through the commit history I've located commit
c155f654b4f755b4111bd9adb60559fe22526a10 from 2013 which seems to address
the
same issue in intarray module, so it might be a regression.

Also there is 716ea626a88ac510523ab3af5bc779d78eeced58 from 2017 which
fixes
the bug in construct_array function. This commit appears to be included in
REL_11_BETA1, therefore it does not fix the problem with intarray module.