Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-interfaces by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group