Array dimension lost if dimension length is zero

From: Shay Rojansky <roji(at)roji(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Array dimension lost if dimension length is zero
Date: 2016-09-08 17:25:11
Message-ID: CADT4RqDaXBuConyhNiPHPqASFxZWOFYYJsY_=DW03=+2H_-xwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

An Npgsql user has reported an edge case use which seems to be a bug.

When sending a multidimensional array to PostgreSQL, if the length of a
dimension is 0, that dimension is lost. That is, the user sends a
2-dimensional array with 0 for both dimensions; trying to read this back
will return a 1-dimensional array.

It seems that another way to see this problem is this... Running "select
ARRAY[[1], [1]]::integer[]" returns "{{1},{1}}". However, running "select
ARRAY[[], []]::integer[]" returns "{}".

It seems important for the dimensionality of the array to be what was sent
regardless of the lengths; otherwise problems occur as the user expect back
a 2-dimensional array but receive a single-dimensional one...

For reference, the original issue is
https://github.com/npgsql/npgsql/issues/1271

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-09-08 17:32:02 Re: Array dimension lost if dimension length is zero
Previous Message Tom Lane 2016-09-08 15:52:57 Re: BUG #14317: psql \dt not working as expected