Re: So what's an "empty" array anyway? - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: So what's an "empty" array anyway?
Date
Msg-id 491AC823.1090208@gmx.net
Whole thread Raw
In response to So what's an "empty" array anyway?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: So what's an "empty" array anyway?  ("Robert Haas" <robertmhaas@gmail.com>)
Re: So what's an "empty" array anyway?  (Sam Mason <sam@samason.me.uk>)
List pgsql-hackers
Tom Lane wrote:
> Seems like we ought to clean this up.  I'm not sure which way to jump
> though: should we decree that arrays of no elements must always have
> zero dimensions, or should we get rid of that and standardize on, say,
> 1-D array with lower bound 1 and upper bound 0?

It was pointed out to me today that a zero-dimensional matrix is a 
scalar.  This makes a bit of sense, if you say that

'{{56}}' is of type int[][], 2 dimensions
'{56}' is of type int[], 1 dimension
'56' is of type int, 0 dimensions

Notice that the number of brace pairs in the literal matches the number 
of bracket pairs in the type declaration.

By that logic, '{}' has one dimension.  I think this also works best in 
practice, for example with array concatenation.


pgsql-hackers by date:

Previous
From: "Hitoshi Harada"
Date:
Subject: Re: Windowing Function Patch Review -> NTH_VALUE
Next
From: Peter Eisentraut
Date:
Subject: Re: array_length()