Re: tsearch2 trigger alternative - Mailing list pgsql-general

From Teodor Sigaev
Subject Re: tsearch2 trigger alternative
Date
Msg-id 403CA96A.7080706@sigaev.ru
Whole thread Raw
In response to tsearch2 trigger alternative  (Chris Gamache <cgg007@yahoo.com>)
Responses Re: tsearch2 trigger alternative  (Chris Gamache <cgg007@yahoo.com>)
List pgsql-general

Chris Gamache wrote:
> Tsearch2 comes with its own tsearch2 trigger function. You pass column names to
> it, and it puts a vanilla tsvector into the column named in TG_ARGV[0]. Not
> only can you pass column names to it, but you can pass simple functions to it
> as well. This is magical to me. :)
look at tsvector.c:864

numattr = SPI_fnumber(rel->rd_att, trigger->tgargs[i]);
if (numattr == SPI_ERROR_NOATTRIBUTE)
{
      funcoid = findFunc(trigger->tgargs[i]);
      if (funcoid == InvalidOid)
           ereport(ERROR,
                 (errcode(ERRCODE_UNDEFINED_COLUMN),
                  errmsg("could not find function or field \"%s\"",
                  trigger->tgargs[i])));
           continue;
}

If current args (trigger->tgargs[i]) isn't a column name, then it's a function
name. It's simple :)


>
> I'm trying to figure out how to do the same thing using plpgsql, except instead
> of returning a vanilla tsvector, I want to return a specially weighted
> tsvector. I've created a function that can do this:
I didn't work with plpgsql :(

--
Teodor Sigaev                                  E-mail: teodor@sigaev.ru

pgsql-general by date:

Previous
From: "cnliou"
Date:
Subject:
Next
From: "cnliou"
Date:
Subject: invalid memory alloc request size