Array dimension lost if dimension length is zero - Mailing list pgsql-bugs

From Shay Rojansky
Subject Array dimension lost if dimension length is zero
Date
Msg-id CADT4RqDaXBuConyhNiPHPqASFxZWOFYYJsY_=DW03=+2H_-xwg@mail.gmail.com
Whole thread Raw
Responses Re: Array dimension lost if dimension length is zero  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #14317: psql \dt not working as expected
Next
From: Tom Lane
Date:
Subject: Re: Array dimension lost if dimension length is zero