X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9F9BFD1B53B for ; Wed, 5 Nov 2003 08:49:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 90417-08 for ; Wed, 5 Nov 2003 04:49:19 -0400 (AST) Received: from palrel10.hp.com (palrel10.hp.com [156.153.255.245]) by svr1.postgresql.org (Postfix) with ESMTP id 8486FD1B58E for ; Wed, 5 Nov 2003 04:49:17 -0400 (AST) Received: from redsea.india.hp.com (redsea.india.hp.com [15.76.97.3]) by palrel10.hp.com (Postfix) with ESMTP id 0799E1C02763 for ; Wed, 5 Nov 2003 00:49:17 -0800 (PST) Received: from eb96106 (eb96106.india.hp.com [15.76.96.106]) by redsea.india.hp.com (8.9.3 (PHNE_28810)/8.9.3 SMKit7.02) with SMTP id OAA29862 for ; Wed, 5 Nov 2003 14:29:26 +0530 (IST) Message-ID: <016101c3a379$afd92600$6a604c0f@india.hp.com> From: "Rajiv Malhotra" To: Subject: using Version-1 style coding how to access varchar arrays from C function Date: Wed, 5 Nov 2003 14:19:08 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_015E_01C3A3A7.C6BC9720" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=HTML_40_50 X-Spam-Level: X-Archive-Number: 200311/6 X-Sequence-Number: 4564 This is a multi-part message in MIME format. ------=_NextPart_000_015E_01C3A3A7.C6BC9720 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable HI ,=20 I have written a small C function that should access the varchar array data= type . Here is the function=20 Line Num 1 Datum evman_verify(PG_FUNCTION_ARGS ) { Line Num 2 TupleTableSlot *t =3D (TupleTableSlot *) PG_GETARG_POINTER(0); Line Num 3 VarChar* val =3D (VarChar*)PG_GETARG_VARCHAR_P(1); Line Num 4 bool isnull; Line Num 5 VarChar** pr =3D (VarChar**) (GetAttributeByName(t,"propsa",&is= null)); // I think this typecasting is wrong as there is no macro to get = array data or is there any that I don't know Line Num 6 PG_RETURN_VARCHAR_P(*pr); //to return first VarChar* } Schema of table is=20 CREATE TABLE f_test( props VARCHAR(100) , propsa VARCHAR(100)[]); the linking from pg-sql looks like this CREATE FUNCTION gettext(f_test,varchar) return varchar as 'MYROOT/sharedlib= ' , 'evman_verify' LANGUAGE C; where sharedlib the library made after compilation.. I able to acces all the basic types but not the array as in line num 5. The= function returns NULL value while accessed from query . The query I am usi= ng look like=20 Insert into f_test values ( 'hello' , '{"hi","bye"}'); // values in table select gettext(f_test,props) from f_test; I am expecting the result as "hi" Regards , Rajiv Malhotra HP - ISO Bangalore=20 Office Number : 2051265 Mobile Number : 9886124097 Mail -id rajiv@india.hp.com ------=_NextPart_000_015E_01C3A3A7.C6BC9720 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
HI ,
 
I have written a small C function that sho= uld=20 access the varchar array data type .
 
Here is the function
 
Line Num 1  Datum=20 evman_verify(PG_FUNCTION_ARGS ) {
Line Num 2  TupleTableSlot *= t =3D=20 (TupleTableSlot *) PG_GETARG_POINTER(0);
Line Num 3  VarChar* = val =3D=20 (VarChar*)PG_GETARG_VARCHAR_P(1);
Line Num 4  bool isnull;
Line Num= =20 5
  VarChar** pr =3D (VarCha= r**)=20 (GetAttributeByName(t,"propsa",&isnull));   // I think this= =20 typecasting is wrong as there is no macro to get array data or is there any= that=20 I don't know
Line Num 6 = ;=20 PG_RETURN_VARCHAR_P(*pr);  //to return first VarChar*
}
Schema of table is
 
CREATE TABLE f_test( props VARCHAR(100) , = propsa=20 VARCHAR(100)[]);
 
the linking from pg-sql looks like=20 this
 
CREATE FUNCTION gettext(f_test,varchar) re= turn=20 varchar as 'MYROOT/sharedlib' , 'evman_verify' LANGUAGE C;
 
where sharedlib the library made after=20 compilation..
 
 
I able to acces all the basic types but no= t the=20 array as in line num 5. The function returns NULL value while accessed= from=20 query . The query I am using look like
 
Insert into f_test values ( 'hello' ,=20 '{"hi","bye"}');  // values in table
 
select gettext(f_test,props) from=20 f_test;
 
I am expecting the result as=20 "hi"
 
 
Regards ,
 
Rajiv Malhotra
HP - ISO Bangalore
O= ffice=20 Number   :   2051265
Mobile Number  : &nbs= p;=20 9886124097
Mail -id   rajiv@india.hp.com
------=_NextPart_000_015E_01C3A3A7.C6BC9720--