Re: Populating a sparse array piecemeal in plpgsql (REDUX)

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Populating a sparse array piecemeal in plpgsql (REDUX)
Дата
Msg-id 162867790805281318v3b085facr9ce5d59a360d487d@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Populating a sparse array piecemeal in plpgsql (REDUX)  ("Webb Sprague" <webb.sprague@gmail.com>)
Список pgsql-general
2008/5/27 Webb Sprague <webb.sprague@gmail.com>:
> I am trying to return a 2-d array with filled in values, but I can't
> find a way to initialize the array programmatically (ie, in a
> function, with the array size being determined by parameter values.
>
> here is one approach
>
>> Well, the point is that you need to initialize the array as a whole to
>> have the dimensions you want; PG won't guess about this.  For instance
>> you could do something like
>>
>>        declare a integer[];
>>        begin
>>          a := '{{null,null,null},{null,null,null},{null,null,null}}';
>
>  I would  like the following to get  a 3 x 3 array:
>
> declare a integer[][]
>    begin
>    a := array_init(3, 3, 0)  -- this function doesn't exist, ??

+1 it's good idea - I see problem only with dimension specification.
Maybe is better

array_init(ARRAY[3,3], 0) - so we can use this function for
multimensional array too.

Regards
Pavel

>
> Any ideas?  I guess I can do a series of appends or make some text
> thing, but that seems awkward...
>
> Tx
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Psql crashes with Segmentation fault on copy from
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Psql crashes with Segmentation fault on copy from