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

Поиск
Список
Период
Сортировка
От Rajiv Malhotra
Тема using Version-1 style coding how to access varchar arrays from C function
Дата
Msg-id 016101c3a379$afd92600$6a604c0f@india.hp.com
обсуждение исходный текст
Список 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@india.hp.com

В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Alberto Cabello Sanchez
Дата:
Сообщение: Re: libpq++ and kdevelop
Следующее
От: Julie Russell
Дата:
Сообщение: Re: libpq++ and kdevelop