From: | Peter Blazso <blazso(at)deltav(dot)hu> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] array manipulations |
Date: | 1999-09-04 19:27:42 |
Message-ID: | 37D172AE.621E6725@deltav.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 1999-09-04 19:52:50 | Re: [HACKERS] temp table oddness? |
Previous Message | Bruce Momjian | 1999-09-04 19:11:30 | Re: [HACKERS] md.c is feeling much better now, thank you |