]> ruin.nu Git - ndwebbie.git/blob - database/functions/wiki_pages.sql
Clean up database directory
[ndwebbie.git] / database / functions / wiki_pages.sql
1 CREATE OR REPLACE FUNCTION update_wiki_page() RETURNS trigger
2 AS $$
3 DECLARE
4         rec RECORD;
5 BEGIN
6         SELECT setweight(to_tsvector(wpr.text), 'D') AS ts
7                 INTO STRICT rec
8                 FROM wiki_page_revisions wpr
9                 WHERE NEW.wprev = wpr.wprev;
10         NEW.textsearch := rec.ts
11                 || setweight(to_tsvector(NEW.namespace || ':' || NEW.name), 'A');
12         NEW.time = NOW();
13         return NEW;
14 END;
15 $$ LANGUAGE plpgsql;
16