Received: from hera.inf.ucv.cl (root@hera.inf.ucv.cl [158.251.10.6]) by hub.org (8.9.3/8.9.3) with SMTP id SAA92064; Tue, 11 May 1999 18:22:24 -0400 (EDT) (envelope-from cperalta@hera.inf.ucv.cl) Received: from olimpo20.inf.ucv.cl by hera.inf.ucv.cl (AIX 3.2/UCB 5.64/4.03) id AA15313; Tue, 11 May 1999 18:19:17 -0400 Message-Id: <373812B9.794EB6CC@hera.inf.ucv.cl> Date: Tue, 11 May 1999 06:21:30 -0500 From: Carlos Peralta Ramirez X-Mailer: Mozilla 4.51 [en] (Win95; I) X-Accept-Language: en Mime-Version: 1.0 To: pgsql-sql , pgsql-general Subject: More problems with arrays !!!!! X-Priority: 1 (Highest) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I tried to create a function in C that receive an array X like argument, and return ane element of him. Here is the C code -> #include #include int4 array_1(int4 x[]){ return(x[1]); } int4 array_2(int4 *x){ return(x[1]); } int4 array_3(int4 x[]){ return(*(x+1)); } int4 array_4(int4 *x){ return(*(x+1)); } /* Note, this functions are tests only,*/ then I ceate this functions in Postgresql -> testdb=> create function array_1(_int4) returns int4 as '/var/lib/pgsql/funciones/arraystest.so' language 'c'; CREATE testdb=> create function array_2(_int4) returns int4 as '/var/lib/pgsql/funciones/arraystest.so' language 'c'; CREATE testdb=> create function array_3(_int4) returns int4 as '/var/lib/pgsql/funciones/arraystest.so' language 'c'; CREATE testdb=> create function array_4(_int4) returns int4 as '/var/lib/pgsql/funciones/arraystest.so' language 'c'; CREATE Therefore I can call the functions , but I hope another results ..... testdb=> select array_1('{1,2,3,4}'); array_1 ---- 40 (1 row) testdb=> select array_2('{1,2,3,4}'); array_2 ---- 40 (1 row) testdb=> select array_3('{1,2,3,4}'); array_3 ---- 40 (1 row) testdb=> select array_4('{1,2,3,4}'); array_4 ---- 40 (1 row) This means that the four functions returns the same value testdb=> select array_1('{1,4}'); array_1 ---- 32 (1 row) testdb=> select array_1('{1,1}'); array_1 ---- 32 (1 row) testdb=> select array_1('{3,2,3,3,4,5,6}'); array_1 ---- 52 (1 row) testdb=> select array_1('{}'); array_1 ---- 12 (1 row) testdb=> select array_1('{1}'); array_1 ---- 28 (1 row) It seems to be , this functions returns the bytes asigned to them. What can I do, for get the element (e.g. the fisrt) of the array? Thanks , PD: I want to do this, to make a function that return if a element is or not into an array.