Re: So what's an "empty" array anyway?

From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: "Peter Eisentraut" <peter_e(at)gmx(dot)net>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: So what's an "empty" array anyway?
Date: 2008-11-12 14:46:09
Message-ID: 603c8f070811120646u466ed30q655843f857e35e8a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 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. 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.

...Robert

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sergey Konoplev 2008-11-12 15:23:16 Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)
Previous Message Sergey Konoplev 2008-11-12 14:43:42 Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)