Hi all I need a bit assistance. In ../src/backend/utils/adt/tsginidx.c there is a function called gin_extract_tsquery. It recieves 5 parameters and I would like to execute it from C code using my own function. The gin_extract_tsquery relevant part: Datum gin_extract_tsquery(PG_FUNCTION_ARGS) { TSQuery query = PG_GETARG_TSQUERY(0); int32 *nentries = (int32 *) PG_GETARG_POINTER(1); /* StrategyNumber strategy = PG_GETARG_UINT16(2); */ bool **ptr_partialmatch = (bool **) PG_GETARG_POINTER(3); Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4); Datum *entries = NULL; bool *partialmatch; elog(NOTICE,"[%s,%d]","step: ",03); *nentries = 0; elog(NOTICE,"[%s,%d]","step: ",04); ..... } I created my own simple wrapper function, so I can control the gin_extract_tsquery directly. Here's the code: Datum test(PG_FUNCTION_ARGS) { //arguments HStore<----><------>*hs = PG_GETARG_HS(0); TSQuery<---><------>tq = PG_GETARG_TSQUERY(1); Datum<-----><------>*dats; elog(NOTICE,"[%s,%d]","step: ",01); //variables char<------><------>*nentries; elog(NOTICE,"[%s,%d]","step: ",02); //operations nentries = DirectFunctionCall2(gin_extract_tsquery_ljd, TSQueryGetDatum(tq), dats); .... } The above function call is incompleate (only 2 params instead of 5) but it's not relevant at this point. The issue is that no matter what I pass (Datum, pointer to Datum, pointer to char, pointer to int32, PG macros to variables and pointers, etc...) as a 2nd parameter I get an error when I call my wrapper function from Postgres. It goes well right until the line before "step: 04" notice in gin_extract_tsquery. Namely the "*nentries = 0;" line. What do I need to pass in my wrapper function so it works properly? An example and short explanation (I just started learning C & PG) would be greatly appreciated. Also a related question: Is it possible to launch a function like gin_extract_query directly from Postgres? I'ts decralation is: CREATE OR REPLACE FUNCTION gin_extract_tsquery(tsquery, internal, smallint, internal, internal) RETURNS internal AS .... I've tried to find something about "internal" parameters in functions in manual but failed. If it's possible, what would be a working example? Thanks in advance. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general