summaryrefslogtreecommitdiff
path: root/util/dump.sql
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-12-05 18:29:53 +0100
committerYorhel <git@yorhel.nl>2009-12-05 18:32:47 +0100
commit9aa6f31f9a800157dd6899e3b237316890e2872f (patch)
treed34f43d4bf96dd62182ce470f14c1fd12c333e2f /util/dump.sql
parentf8becca564556989db2973577336ea3fb8f5fd7e (diff)
SQL: Call update_vncache() in a trigger
This removes the need for the dbVNCache() function in perl.
Diffstat (limited to 'util/dump.sql')
-rw-r--r--util/dump.sql17
1 files changed, 16 insertions, 1 deletions
diff --git a/util/dump.sql b/util/dump.sql
index 70f79b2d..2e2b6cf7 100644
--- a/util/dump.sql
+++ b/util/dump.sql
@@ -701,7 +701,7 @@ CREATE TRIGGER vn_relgraph_notify AFTER UPDATE ON vn FOR EACH ROW EXECUTE PROCED
-- Same as above for producers, with slight differences in the steps:
-- There is no 2, and
-- 3 = Producer edit of which the name, language or type differs from the previous revision
-CREATE OR REPLACE FUNCTION vn_relgraph_notify() RETURNS trigger AS $$
+CREATE OR REPLACE FUNCTION producer_relgraph_notify() RETURNS trigger AS $$
BEGIN
-- 1.
IF NEW.rgraph IS DISTINCT FROM OLD.rgraph OR NEW.latest IS DISTINCT FROM OLD.latest THEN
@@ -751,6 +751,21 @@ CREATE TRIGGER insert_notify AFTER INSERT ON threads_posts FOR EACH STATEMENT EX
CREATE TRIGGER insert_notify AFTER INSERT ON tags FOR EACH STATEMENT EXECUTE PROCEDURE insert_notify();
+-- call update_vncache() when a release is added, edited, hidden or unhidden
+CREATE OR REPLACE FUNCTION release_vncache_update() RETURNS trigger AS $$
+BEGIN
+ IF OLD.latest IS DISTINCT FROM NEW.latest OR OLD.hidden IS DISTINCT FROM NEW.hidden THEN
+ PERFORM update_vncache(vid) FROM (
+ SELECT DISTINCT vid FROM releases_vn WHERE rid = OLD.latest OR rid = NEW.latest
+ ) AS v(vid);
+ END IF;
+ RETURN NULL;
+END;
+$$ LANGUAGE plpgsql;
+
+CREATE TRIGGER release_vncache_update AFTER UPDATE ON releases FOR EACH ROW EXECUTE PROCEDURE release_vncache_update();
+
+