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 491AFD38.2030106@gmx.net
Whole thread Raw
In response to Re: So what's an "empty" array anyway?  ("Robert Haas" <robertmhaas@gmail.com>)
Responses Re: So what's an "empty" array anyway?  ("Robert Haas" <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas wrote:
>> 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.
> 
> I think it's actually more correct to say that {} has an undefined
> number of dimensions.

That is your opinion, but not my argument above.
> The || operator is valid only if the dimensions
> of the two arrays are equal (in which case it appends them) or if the
> dimension of one of the arrays is one less than the other (in which
> case, if legal, it treats the array of lesser dimension as a new
> element to be added to the other array).
> 
> But {}, and ONLY {}, can be concatenated with an array of any number
> of dimensions.

Which doesn't necessarily make much sense ...


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: array_length()
Next
From: "Alex Hunsaker"
Date:
Subject: Re: SSL cleanups/hostname verification