Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL) - Mailing list pgsql-hackers

From Brendan Jurd
Subject Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)
Date
Msg-id CADxJZo1b55z8YGss59xo=FLQeYtsqPVYVkoLj7bdo_cCfg=_-w@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)  (Josh Berkus <josh@agliodbs.com>)
List pgsql-hackers
On 28 March 2013 09:39, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
> On 27 March 2013 17:14, Brendan Jurd <direvus@gmail.com> wrote:
>> Well the fix is primarily about 1-D empty arrays, and in that respect
>> it is much less confusing than what we have now.
>
> Maybe. But even in 1-D, it's still jumping from having one empty array
> to infinitely many starting at different indexes, e.g., '{}'::int[] !=
> '[4:3]={}'::int[]. There may be a certain logic to that, but I'm not
> convinced about its usefulness.

We already have the ability to define lower bounds other than 1 on
arrays, and it would be inconsistent to allow that for arrays with
elements, but not for arrays without.  I could imagine somebody
wanting to create an empty zero-based array, and then iteratively
append elements to it.

> Also, it is incompatible with the choice made for empty ranges,

To me it doesn't make sense to try to draw parallels between arrays
and ranges, they really are completely different things.

Cheers,
BJ



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Catching resource leaks during WAL replay
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)