From: | Simon Riggs <simon(at)2ndQuadrant(dot)com> |
---|---|
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-10-21 19:08:51 |
Message-ID: | 1224616131.27145.175.camel@ebony.2ndQuadrant |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, 2008-10-21 at 13:50 -0400, Tom Lane wrote:
> Currently, the constructs
> '{}'::arraytype
> ARRAY[]::arraytype
> return zero-dimensional arrays, as does the underlying function
> construct_empty_array(). I can't immediately find any way at SQL
> level to produce an empty array with one or more dimensions.
> However, construct_array and construct_md_array will happily build
> zero-length arrays of dimension 1 or higher, leading to weirdnesses
> such as illustrated here:
> http://archives.postgresql.org/pgsql-general/2008-10/msg00915.php
>
> 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?
>
> A somewhat related issue that I noticed while poking at this is that
> array_dims() returns NULL for a zero-dimension array. That seems a bit
> bogus too; wouldn't an empty string be saner? Of course the issue
> goes away if we get rid of zero-dimension arrays.
Please remove zero-dimension arrays.
The number of dimensions of an empty array really ought to be NULL, or
if we fix it to be non-NULL then 1+. Zero just makes a weird case for no
reason. An empty string only makes sense in the context of that
particular function, it doesn't really help with other maths.
--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2008-10-21 19:45:24 | pg_ctl less than useful error message on windows when privileges wrong for postgres |
Previous Message | Peter Eisentraut | 2008-10-21 19:07:31 | Re: [HACKERS] pgsql: SQL 200N -> SQL:2003 |