using Version-1 style coding how to access varchar arrays from C function

From: "Rajiv Malhotra" <rajiv(at)india(dot)hp(dot)com>
To: <pgsql-interfaces(at)postgresql(dot)org>
Subject: using Version-1 style coding how to access varchar arrays from C function
Date: 2003-11-05 08:49:08
Message-ID: 016101c3a379$afd92600$6a604c0f@india.hp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

HI ,

I have written a small C function that should access the varchar array data type .

Here is the function

Line Num 1 Datum evman_verify(PG_FUNCTION_ARGS ) {
Line Num 2 TupleTableSlot *t = (TupleTableSlot *) PG_GETARG_POINTER(0);
Line Num 3 VarChar* val = (VarChar*)PG_GETARG_VARCHAR_P(1);
Line Num 4 bool isnull;
Line Num 5 VarChar** pr = (VarChar**) (GetAttributeByName(t,"propsa",&isnull)); // 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

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 using look like

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
Office Number : 2051265
Mobile Number : 9886124097
Mail -id rajiv(at)india(dot)hp(dot)com

Browse pgsql-interfaces by date

  From Date Subject
Next Message Bruce Momjian 2003-11-07 04:03:49 Re: ODBC Driver
Previous Message Hiroshi Inoue 2003-11-03 01:23:16 Re: Possible bug with psqlodbc driver