Re: Disallow arrays with non-standard lower bounds - Mailing list pgsql-hackers

From Gavin Flower
Subject Re: Disallow arrays with non-standard lower bounds
Date
Msg-id 52CF4BE2.3020902@archidevsys.co.nz
Whole thread Raw
In response to Re: Disallow arrays with non-standard lower bounds  (Peter Geoghegan <pg@heroku.com>)
Responses Re: Disallow arrays with non-standard lower bounds  (Kevin Grittner <kgrittn@ymail.com>)
List pgsql-hackers
On 10/01/14 12:55, Peter Geoghegan wrote:
> On Thu, Jan 9, 2014 at 3:41 PM, David Fetter <david@fetter.org> wrote:
>> We have dropped support, as you put it, for bigger and harder-hitting
>> mistakes than this.  Anybody whose code has this kind of silliness in
>> it will be in other kinds of trouble, too.
> While the decision to make it possible to set the lower bound index
> value arbitrarily was made before I was active in the project, I
> imagine it went something like this:
>
> Person 1: We should make our arrays similar to those found in a
> certain proprietary system's standard procedural language - with one
> as a lower bound.
>
> Person 2: I don't like that, it should always be zero.
>
> Person 1: We can all be winners.
>
Starting arrays at zero makes the most sense, as then you can calculate 
the displacement simply as (index) * (size of entry), and not have 
subtract one from the index first.  This would be my preference.

Both C & C++ use zero as the default, so Java naturally followed their 
example.

But I wouldn't push it, as people who mainly know SQL are more used to 
starting arrays at 1, and it is not worth the effort to change it as 
this stage.  At least we should be consistent how we treat arrays in  SQL.


Cheers,
Gavin



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Turning off HOT/Cleanup sometimes
Next
From: Stephen Frost
Date:
Subject: Re: Turning off HOT/Cleanup sometimes