Craeteing sparse arrays

Поиск
Список
Период
Сортировка
От Peter Hunsberger
Тема Craeteing sparse arrays
Дата
Msg-id cc159a4a0910151420v37ef3bdcv7ef2d4f6250108a3@mail.gmail.com
обсуждение исходный текст
Ответы Re: Craeteing sparse arrays  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Is there any easy way to create sparse arrays with Postres?
Specifically, when I construct, add or aggregate data to an array, I
want to be able to specify the position within the array where the
data is placed and have any intervening positions that have not yet
been populated just marked as nulls. eg, something like

insert into foo (bar[3],[7]) values ( 'a', 'b')

would build an array

bar = { null, null, 'a', null, null, null, 'b' }

or some such thing.  I suspect I'm going to have to write a function
to just find the length and append nulls until I reach the desired
position?  Given that some of the arrays I will be dealing with could
potentially be 1000s of elements long that seems a bit perverse.

I'm currently using 8.3 but 8.4 solutions are also welcome.  C code
not considered out of the question if it isn't a lot of work and will
make the rest of the process close to trivial...

--
Peter Hunsberger

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

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: npgsql and postgres enum type
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Craeteing sparse arrays