Re: Passing arrays - Mailing list pgsql-sql

From Guy Fraser
Subject Re: Passing arrays
Date
Msg-id 3E53D5D0.7020104@incentre.net
Whole thread Raw
In response to Re: Passing arrays  (Achilleus Mantzios <achill@matrix.gatewaynet.com>)
List pgsql-sql
Can someone explain to me why people keep refering to contrib/intarray.

This person need help with a text array not an int array.
 From what I can tell people keep refering to some GIST cruft but have never
supplied an example.

If I am missing something please let me know, I am sure all members of this
list would appreciate more details on the issues of arrays.

My wish list:

array_insert(array_column _std_array_types_[],element_insertion_point int)
returns _std_array_types_[]

array_replace(array_column _std_array_types_[],element_to_replace int) returns
std_array_types_[]

array_remove(array_column _std_array_types_[],element_to_remove int) returns
std_array_types_[]

array_append(array_column _std_array_types_[]) returns std_array_types_[]

array_accumulate(data_to_append _std_type_) returns _array_of_same_type_[]

array_size(array_column _std_array_types_[]) returns int

I have made my own array_size functions, but they are on one my machines at home.

I have been tring to build an agrigate "array_accumulate" for text data but
have not had success. Using my array_size function I tried to just use an
update but it would not work, this is basicly what I tried.

update table2 set data_array[array_size(data_array) + 1] = table1.new_data
where table2.id_data = table1.match_data;

The data in table1 was a list from the standard alias file as (alias text,dest
text) and the data in table2 was a distinct list of destinations from list1
and an array of '{nobody}' like this (dest text not null,aliases text[]
default '{nobody}').

When I run the update query only the first match is added to the array.

The other weirdness was, that I couldn't seen to add the first element of the
array. That may have been fixed though when I changed my function to remove
the "strict immutable" attributes.

I have not had any success trying to build a function to do the update so I
can use it in an aggrigate.

To make the functions type insensitive I have been thinking it may be possible
to cast the array or array data to text on input and back to the original type
on output, but I would rather find a better way to do it.


Guy

Achilleus Mantzios wrote:> On Fri, 14 Feb 2003, Michael Weaver wrote:
..snip...
>>>-----Original Message----->>>From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com]>>>Sent: Friday, 14 February
200312:58 PM>>>To: Michael Weaver>>>Cc: 'pgsql-novice@postgresql.org'; 'pgsql-sql@postgresql.org'>>>Subject: Re: [SQL]
Passingarrays
 
...snip...
>> Also check out contrib/intarray and its indexing capabilites> if you have 1 dimensional integer
arrays.>>>>Thanks.>>>
...snip...




pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: VIEW or Stored Proc - Is this even possible?
Next
From: "Matthew Nuzum"
Date:
Subject: simple join problem