Update tsvector trigger

From: "x asasaxax" <xanaruto(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Update tsvector trigger
Date: 2008-08-05 22:04:31
Message-ID: 91495cb0808051504w22358a04u149cdeef014df588@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

i´m trying to do a trigger that its called when update or insert, that
update the tsvectors, for text-search. Here´s my code:

create table x(
cod serial,
texto text,
vectors tsvector,
constraint pk primary key(cod)
);

CREATE OR REPLACE FUNCTION atualiza_vectors() RETURNS trigger AS $$
BEGIN
IF NEW.texto<>NULL THEN
UPDATE x SET vectors = to_tsvector(lower(to_ascii(NEW.texto)))
where cod= NEW.cod;
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER atualiza_vectors AFTER INSERT OR UPDATE ON x
FOR EACH ROW EXECUTE PROCEDURE atualiza_vectors();

When the trigger its called, postgre shows the following error: "stack depth
limit exceeded".

Did anyone knows what its wrong?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-08-05 22:57:10 Re: bytea encode performance issues
Previous Message Glyn Astill 2008-08-05 21:37:08 Re: What happen to the VARATT_SIZEP macro in version 8.3?