summaryrefslogtreecommitdiff
path: root/util/dump.sql
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-11-29 18:28:33 +0100
committerYorhel <git@yorhel.nl>2009-11-29 18:28:33 +0100
commit11290678d9b900baec7a92581a6f87cc70d329ea (patch)
tree9f45a43ce313fff9378646fc0736acf7ee3ff3e2 /util/dump.sql
parentbe023476e67dc76a5fb1344af5b5cb9244d992e7 (diff)
Tags: Replaced tag_tree() with WITH .. SELECT queries, and removed /g/debug
The return value of dbTagTree() is also somewhat easier to work with.
Diffstat (limited to 'util/dump.sql')
-rw-r--r--util/dump.sql60
1 files changed, 0 insertions, 60 deletions
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