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 CADxJZo1nByfUP0kTQsD=X69iFcHODs2nTa9W9aN14MPWpUbS6Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)  (Kevin Grittner <kgrittn@ymail.com>)
Ответы Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 7 April 2013 01:43, Kevin Grittner <kgrittn@ymail.com> wrote:
> Brendan Jurd <direvus@gmail.com> wrote:
>> Indeed it does not prohibit nesting arrays inside other arrays, but
>> the multidim arrays that Postgres allows you to create are not the
>> same thing as nested arrays.
>>
> Your interpretation matches mine all around.  It is unfortunate
> that we have hijacked the standard's syntax for arrays to add a
> matrix feature.

It really is unfortunate.  I wonder if it was done in an attempt to
mimic Oracle behaviour.

> It seems to leave us without any way forward on
> these issues that I like very much.

On the specific issue of CARDINALITY, I guess we need to decide
whether we are going to pretend that our array/matrix thing is
actually nested.  I first argued that we should not.   But it occurred
to me that if we do pretend, it would at least leave the door ajar if
we want to do something to make our arrays more nest-like in future,
without disrupting the behaviour of CARDINALITY.

It is unlikely that we ever would make such a change, but given the
intensity of the opposition to any kind of SQL-level behavioural
changes we've had on this thread, I don't want to create any more
barriers to future efforts to comport with the spec.

So how about:

* we add CARDINALITY, make it work like array_length(a, 1) except that
it returns zero for empty arrays, and
* we add array_num_items, which exposes the internal ArrayGetNItems,
and returns zero for empty arrays.

As in:

CARDINALITY(ARRAY[[1,2], [3,4], [5,6]]) => 3
array_num_items(ARRAY[[1,2], [3,4], [5,6]]) => 6

Cheers,
BJ



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

Предыдущее
От: Misa Simic
Дата:
Сообщение: Re: Fwd: Range types (DATERANGE, TSTZRANGE) in a foreign key with "inclusion" logic
Следующее
От: Tom Lane
Дата:
Сообщение: Re: WIP: index support for regexp search