Re: Disallow arrays with non-standard lower bounds

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>, Peter Geoghegan <pg(at)heroku(dot)com>, David Fetter <david(at)fetter(dot)org>
Cc: Jim Nasby <jim(at)nasby(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Disallow arrays with non-standard lower bounds
Date: 2014-01-10 22:10:16
Message-ID: 1389391816.48526.YahooMailNeo@web122301.mail.ne1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz> wrote:

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

The SQL standard explicitly specifies that arrays positions range
from 1 to the cardinality of the array, with individual elements
referenced by position.  When implementing a language for which
there is an international standard, my preference is to conform to
the standard.

I don't have a problem with extensions to the language, and a
variable low bound is workable as an extension as long as the
standard ways to create an array default to a low bound of 1.

A bigger problem with our array implementation is that is is really
a multidimensional matrix, rather than an array which can contain
nested arrays.  That is both non-standard and limiting.

That said, I think it would be nice to have better support for
arrays defined with a single dimension and a low bound of 1, as the
standard requires.  Functions which throw an error when passed a
non-conforming parameter and can provide a simplified API as a
result would probably get used by me.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2014-01-10 22:10:33 Re: Disallow arrays with non-standard lower bounds
Previous Message David Fetter 2014-01-10 22:06:09 Re: Disallow arrays with non-standard lower bounds