Re: [SQL] ARRAY() returning NULL instead of ARRAY[] resp. {} - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [SQL] ARRAY() returning NULL instead of ARRAY[] resp. {}
Date
Msg-id 25974.1118069089@sss.pgh.pa.us
Whole thread Raw
In response to Re: [SQL] ARRAY() returning NULL instead of ARRAY[] resp. {}  (Markus Bertheau ☭ <twanger@bluetwanger.de>)
Responses Re: [SQL] ARRAY() returning NULL instead of ARRAY[] resp. {}
Re: [SQL] ARRAY() returning NULL instead of ARRAY[] resp. {}
List pgsql-hackers
Markus Bertheau ☭ <twanger@bluetwanger.de> writes:
> By analogy, array_upper('{}'::TEXT[], 1) should return 0 instead of
> NULL.

No, that doesn't follow ... we've traditionally considered '{}' to
denote a zero-dimensional array.  A 1-D array of no elements is
'[1:0]={}', just as Joe shows ... or at least it would be except
for an overenthusiastic error check:

regression=# select '[1:0]={}' :: int[];
ERROR:  upper bound cannot be less than lower bound

I think this should be a legal boundary case.  In general, it should be
possible to form zero-size arrays of any number of dimensions.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Jaime Casanova
Date:
Subject: Re: thw rewriter and default values, again
Next
From: "Jonah H. Harris"
Date:
Subject: Re: Solution proposal for TODO item "Clients: sequences"