Re: [HACKERS] array manipulations

Поиск
Список
Период
Сортировка
От Peter Blazso
Тема Re: [HACKERS] array manipulations
Дата
Msg-id 37D172AE.621E6725@deltav.hu
обсуждение исходный текст
Ответ на Re: [HACKERS] array manipulations  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane wrote:

> I think it should be possible to make a type-independent version of that
> code, and if you want to do so it'd be a great extension.

I should have much more spare time but I'll try... :-)

> How does it look to the user?  Something like
>
>         UPDATE table SET arrayfield = arrayInsert(arrayfield, index, newval)
>         UPDATE table SET arrayfield = arrayDelete(arrayfield, index)

Not exactly. My functions don't use indices yet and they still work only on one
dimensional 'int' arrays. You can insert a new value only as the last elem and
delete all values from the array that match a given integer. They can be used
like below:
       UPDATE table SET arrayfield = array_app_int(arrayfield, newval);       UPDATE table SET arrayfield =
array_del_int(arrayfield,matchval);
 

This time I focused only on user additions/deletions to/from a group in
'pg_group', however the code can be extended easily to do other things as well.

> What do you do about multi-dimensional arrays?

Unfortunately nothing, yet. This code is still an intro into array
manipulations.

> One thing a number of people have complained about is that the natural
> way to extend an array is
>
>         UPDATE table SET arrayfield[n+1] = newval
>
> if arrayfield currently has n entries.  The array assignment code ought
> to handle this case but doesn't.  I don't think it would be a huge fix
> but I haven't looked at the code enough to understand what would need
> to change.

If you want I can send you these functions accompanied by some notes and
comments I just did ...

Peter Blazso




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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] md.c is feeling much better now, thank you
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] temp table oddness?