Ok, so I did this (modified the ts_match_vq function):
Datum.
ljd_test(PG_FUNCTION_ARGS).
{
//get arguments
HStore *hs = PG_GETARG_HS(0);.
TSQuery tq = PG_GETARG_TSQUERY(1);
TSQuery tq_in;
CHKVAL chkvalKeys;
bool res;
//check for empty values.
if (!hs->size || !tq->size)
{
PG_FREE_IF_COPY(hs, 0);
PG_FREE_IF_COPY(tq, 1);
PG_RETURN_BOOL(false);
}
//process TSQuery
tq_in = TSQueryGetDatum(tq);
//process HStore
//HEntry *ptr = ARRPTR(hs);
//char *words = STRPTR(hs);
chkvalKeys.arrb = ARRPTR(hs);
chkvalKeys.arre = chkvalKeys.arrb + hs->size;
chkvalKeys.values = STRPTR(hs);
chkvalKeys.operand = GETOPERAND(tq_in);
res = ljd_exec(
GETQUERY(tq_in),
&chkvalKeys,
true,
checkcondition_str
);
PG_FREE_IF_COPY(hs, 0);
PG_FREE_IF_COPY(tq, 1);
PG_RETURN_BOOL(res);
Now the problem is in the data passed to CHKVAL type (the "chkvalKeys.values = STRPTR(hs);" line), in TSVector data is ltree (I think), but the HStore STRPTR function returns a string. How could I convert the HStore values, so they are compatible with checkcondition_str function located in /postgresql-8.4.3/contrib/ltree ??
Thanks in advance.