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

Re: Using HStore type in TSearch

From: Łukasz Dejneka <l(dot)dejneka(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Using HStore type in TSearch
Date: 2010-03-26 08:15:50
Message-ID: 4df5da451003260115va8d83d1l43da0367bcf60d88@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
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.

pgsql-novice by date

Next:From: Zdravko BalordaDate: 2010-03-26 10:25:13
Subject: Re: Table inheritance
Previous:From: Tom LaneDate: 2010-03-26 03:40:55
Subject: Re: Getting started

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