Re: Tsearch2 trigger firing... - Mailing list pgsql-general

From Net Virtual Mailing Lists
Subject Re: Tsearch2 trigger firing...
Date
Msg-id 20041017040740.8909@mail.e-na.net
Whole thread Raw
In response to Tsearch2 trigger firing...  ("Net Virtual Mailing Lists" <mailinglists@net-virtual.com>)
Responses Re: Tsearch2 trigger firing...  (Oleg Bartunov <oleg@sai.msu.su>)
List pgsql-general
Hello,

Thank you to Oleg for your help with this earlier!  It resolved it very
nicely!


I still have one remaining issue which I can't figure out, perhaps best
explained with an example:


CREATE TABLE sometable (
title    TEXT,
body     TEXT,
footer   TEXT,
all_fti  TSVECTOR
);

UPDATE sometable SET all_fti = setweight(to_tsvector(title), 'A') ||
setweight(to_tsvector(body),'B') || setweight(to_tsvector(footer), 'C');

INSERT INTO sometable (title, body, footer) VALUES ('something in the
title', 'something in the body', 'something in the footer');
INSERT INTO sometable (title, body, footer) VALUES ('anything in the
title', 'anything in the body', 'anything in the footer');
INSERT INTO sometable (title, body, footer) VALUES ('whatever in the
title', 'whatever in the body', 'whatever in the footer');


.. What I can't figure out is how to make those last 3 inserts
automatically update all_fti via a trigger... The documentation would
show something like:


CREATE TRIGGER sometable_update_fti BEFORE UPDATE OR INSERT ON sometable
FOR EACH ROW EXECUTE PROCEDURE tsearch2(all_fti, title, body, footer);

.. but as expected, this does not take into account the result of the
"setweight" function....  Unfortunately, I am not very skilled with
Postgres's triggers (yet) and I can't find any documentation on how to go
about this...

Any thoughts?.....

- Greg


pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: dealing with invalid date
Next
From: Ken Tozier
Date:
Subject: Re: Newbie table definition question