From 11290678d9b900baec7a92581a6f87cc70d329ea Mon Sep 17 00:00:00 2001
From: Yorhel <git@yorhel.nl>
Date: Sun, 29 Nov 2009 18:28:33 +0100
Subject: Tags: Replaced tag_tree() with WITH .. SELECT queries, and removed
 /g/debug

The return value of dbTagTree() is also somewhat easier to work with.
---
 util/dump.sql | 60 -----------------------------------------------------------
 1 file changed, 60 deletions(-)

(limited to 'util/dump.sql')

diff --git a/util/dump.sql b/util/dump.sql
index cad84ac2..bf13c115 100644
--- a/util/dump.sql
+++ b/util/dump.sql
@@ -491,66 +491,6 @@ END;
 $$ LANGUAGE plpgsql;
 
 
--- tag: tag to start with,
--- lvl: recursion level
--- dir: direction, true = parent->child, false = child->parent
-CREATE TYPE tag_tree_item AS (lvl smallint, tag integer, name text, c_vns integer);
-CREATE OR REPLACE FUNCTION tag_tree(tag integer, lvl integer, dir boolean) RETURNS SETOF tag_tree_item AS $$
-DECLARE
-  r tag_tree_item%rowtype;
-  r2 tag_tree_item%rowtype;
-BEGIN
-  IF dir AND tag = 0 THEN
-    FOR r IN
-      SELECT lvl, t.id, t.name, t.c_vns
-        FROM tags t
-        WHERE state = 2 AND NOT EXISTS(SELECT 1 FROM tags_parents tp WHERE tp.tag = t.id)
-        ORDER BY t.name
-    LOOP
-      RETURN NEXT r;
-      IF lvl-1 <> 0 THEN
-        FOR r2 IN SELECT * FROM tag_tree(r.tag, lvl-1, dir) LOOP
-          RETURN NEXT r2;
-        END LOOP;
-      END IF;
-    END LOOP;
-  ELSIF dir THEN
-    FOR r IN
-      SELECT lvl, tp.tag, t.name, t.c_vns
-        FROM tags_parents tp
-        JOIN tags t ON t.id = tp.tag
-        WHERE tp.parent = tag
-          AND state = 2
-        ORDER BY t.name
-    LOOP
-      RETURN NEXT r;
-      IF lvl-1 <> 0 THEN
-        FOR r2 IN SELECT * FROM tag_tree(r.tag, lvl-1, dir) LOOP
-          RETURN NEXT r2;
-        END LOOP;
-      END IF;
-    END LOOP;
-  ELSE
-    FOR r IN
-      SELECT lvl, tp.parent, t.name, t.c_vns
-        FROM tags_parents tp
-        JOIN tags t ON t.id = tp.parent
-        WHERE tp.tag = tag
-          AND state = 2
-        ORDER BY t.name
-    LOOP
-      RETURN NEXT r;
-      IF lvl-1 <> 0 THEN
-        FOR r2 IN SELECT * FROM tag_tree(r.tag, lvl-1, dir) LOOP
-          RETURN NEXT r2;
-        END LOOP;
-      END IF;
-    END LOOP;
-  END IF;
-END;
-$$ LANGUAGE plpgsql;
-
-
 -- recalculate tags_vn_inherit
 CREATE OR REPLACE FUNCTION tag_vn_calc() RETURNS void AS $$
 BEGIN
-- 
cgit v1.2.3

