Re: Possible marginally-incompatible change to array subscripting

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Yury Zhuravlev <u(dot)zhuravlev(at)postgrespro(dot)ru>
Subject: Re: Possible marginally-incompatible change to array subscripting
Date: 2015-12-22 18:47:23
Message-ID: CAFj8pRBjuyhz=DVwamsMuYat0oFEUofJD2PPz=M7Ju0f+X-7_w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-12-22 18:34 GMT+01:00 Robert Haas <robertmhaas(at)gmail(dot)com>:

> On Tue, Dec 22, 2015 at 11:51 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > I'm reviewing Yury Zhuravlev's patch to allow array slice boundaries to
> be
> > omitted, for example "a[4:]" means "the slice extending from element 4 to
> > the last element of a". It strikes me that there's an improvement we
> > could easily make for the case where a mixture of slice and non-slice
> > syntax appears, that is something like "a[3:4][5]". Now, this has always
> > meant a slice, and the way we've traditionally managed that is to treat
> > simple subscripts as being the range upper bound with a lower bound of 1;
> > that is, what this example means is exactly "a[3:4][1:5]".
> >
> > ISTM that if we'd had Yury's code in there from the beginning, what we
> > would define this as meaning is "a[3:4][:5]", ie the implied range runs
> > from whatever the array lower bound is up to the specified subscript.
> >
> > This would make no difference of course for the common case where the
> > array lower bound is 1, but it seems a lot less arbitrary when it isn't.
> > So I think we should strongly consider changing it to mean that, even
> > though it would be non-backwards-compatible in such cases.
> >
> > Comments?
>
> Gosh, our arrays are strange. I would have expected a[3:4][5] to mean
> a[3:4][5:5].
>

exactly,

Pavel

>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2015-12-22 18:49:36 Re: Re: Reusing abbreviated keys during second pass of ordered [set] aggregates
Previous Message Joshua D. Drake 2015-12-22 18:43:33 Re: Possible marginally-incompatible change to array subscripting