Search Postgresql Archives

Update tsvector trigger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux