From: miker Date: Wed, 23 Jun 2010 19:14:39 +0000 (+0000) Subject: a bit more protection for non-cached values; beware the null depth in the two-param... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b1cfddf406fe88f47646f90bccfd6bd508d40dc4;p=evergreen%2Fbjwebb.git a bit more protection for non-cached values; beware the null depth in the two-param version of actor.org_unit_descendants! git-svn-id: svn://svn.open-ils.org/ILS/trunk@16793 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/sql/Pg/pgmemcache-ou_tree_traversal_cache.sql b/Open-ILS/src/sql/Pg/pgmemcache-ou_tree_traversal_cache.sql index 111e356d9..5f70e37bf 100644 --- a/Open-ILS/src/sql/Pg/pgmemcache-ou_tree_traversal_cache.sql +++ b/Open-ILS/src/sql/Pg/pgmemcache-ou_tree_traversal_cache.sql @@ -20,7 +20,14 @@ BEGIN; CREATE OR REPLACE FUNCTION actor.org_unit_descendants ( INT, INT ) RETURNS SETOF actor.org_unit AS $$ - SELECT * FROM actor.org_unit_descendants( (actor.org_unit_ancestor_at_depth($1,$2)).id ); + SELECT * + FROM actor.org_unit_descendants( + CASE WHEN $2 IS NOT NULL THEN + (actor.org_unit_ancestor_at_depth($1,$2)).id + ELSE + $1 + END + ); $$ LANGUAGE SQL STABLE; CREATE OR REPLACE FUNCTION actor.noncached_org_unit_descendants ( org INT ) RETURNS SETOF actor.org_unit AS $$ @@ -54,7 +61,7 @@ BEGIN -- RAISE NOTICE 'Getting perm from cache'; EXECUTE $$SELECT memcache_get('oils_orgcache_$$ || org || $$') AS x;$$ INTO cached_value; - IF cached_value.x IS NOT NULL THEN + IF cached_value.x IS NOT NULL AND cached_value.x <> '' THEN FOR curr_org IN SELECT * FROM actor.org_unit