Re: Proposal: new function array_init

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Proposal: new function array_init
Дата
Msg-id 20173.1212425204@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Proposal: new function array_init  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Ответы Re: Proposal: new function array_init
Re: Proposal: new function array_init
Re: Proposal: new function array_init
Список pgsql-hackers
"Pavel Stehule" <pavel.stehule@gmail.com> writes:
> There was more time questions about array's initialisation. I propose
> function array_init.

> CREATE OR REPLACE FUNCTION array_init(sizes int[], v anyelement)
> RETURNS anyarray;

I think this is basically a good idea, but maybe the API needs a bit of
adjustment --- providing the sizes as an array doesn't seem especially
convenient.  Since we only allow up to 6 dimensions (IIRC), what about
six functions with different numbers of parameters:
array_int(int, anyelement)array_int(int, int, anyelement)...array_int(int, int, int, int, int, int, anyelement)

I don't object to having the array-input version too, but seems like in
most cases this way would be easier to use.  It wouldn't work well
for providing lower bounds too, but maybe the array-input case is
sufficient for that.

Other thoughts:

* Should the fill value be the first parameter instead of the last?
I'm not sure either way.

* I have a mild preference for "array_fill" instead of "array_init".

* We can handle a null fill value now, but what about nulls in the
dimensions?  The alternatives seem to be to return a null array
(not an array of nulls) or throw error.
        regards, tom lane


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

Предыдущее
От: "David E. Wheeler"
Дата:
Сообщение: Re: Case-Insensitve Text Comparison
Следующее
От: Greg Smith
Дата:
Сообщение: Re: Overhauling GUCS