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

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: So what's an "empty" array anyway?
Date: 2008-11-12 12:12:19
Message-ID: 491AC823.1090208@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2008-11-12 13:13:57 Re: array_length()
Previous Message Hitoshi Harada 2008-11-12 09:47:12 Re: Windowing Function Patch Review -> NTH_VALUE