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

Поиск
Список
Период
Сортировка
От Brendan Jurd
Тема Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)
Дата
Msg-id CADxJZo3GPM6DuWQDquA3UJFGbZdie53dL-zvBuD+G3L34i=Nvw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On 1 April 2013 21:57, Robert Haas <robertmhaas@gmail.com> wrote:
> On Tue, Mar 26, 2013 at 4:39 PM, Brendan Jurd <direvus@gmail.com> wrote:
>> On 27 March 2013 06:47, Robert Haas <robertmhaas@gmail.com> wrote:
>>> rhaas=# select '{}'::int4[] = '{}'::int4[];
>>
>> The good news is, if anybody out there is using that idiom to test for
>> emptiness, they will not be disrupted by the change.
>
> According to the discussion downthread, apparently they will, because
> you're introducing an infinitude of empty arrays, not all of which
> compare equal to '{}'::int4.

It is not possible to construct e.g. '[3:2]={}' or '{{}, {}}' in
existing applications, so there is no way for that idiom in existing
applications to be broken by upgrading.  If testing for equality with
'{}' works now, it will also work post-upgrade.

The only way for it to stop working is if somebody upgrades, and
*then* goes out of their way to create an empty array with nondefault
lower bounds, and then tries to compare that array against the empty
array with default lower bounds, to test for emptiness.  Which would
be silly.

Big picture: A very large number of users wouldn't be using arrays at
all, and of those who are, probably a vanishingly small number
(perhaps zero) care about how emptiness interacts with multiple
dimensions or nondefault lower bounds.  We're talking about a corner
case inside a corner case here.

For most folks, this upgrade would break nothing.  A few (myself
included) will want to grep their code for
array_(lower|upper|length|dims) call sites and maybe make some tweaks.

Cheers,
BJ



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)
Следующее
От: Jim Nasby
Дата:
Сообщение: Re: Page replacement algorithm in buffer cache