From de3926478b04b75bfce26e5482d7086e343aff2f Mon Sep 17 00:00:00 2001 From: Simon Norris Date: Wed, 20 Nov 2024 09:23:04 -0800 Subject: [PATCH] fix #163 --- db/functions/FWA_Downstream.sql | 15 +++++++-------- db/functions/FWA_Upstream.sql | 13 +++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/db/functions/FWA_Downstream.sql b/db/functions/FWA_Downstream.sql index c79577b..e05cef3 100644 --- a/db/functions/FWA_Downstream.sql +++ b/db/functions/FWA_Downstream.sql @@ -65,7 +65,8 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Downstream( localcode_ltree_b ltree ) -RETURNS boolean AS $$ +RETURNS boolean language sql set search_path = public AS $$ + SELECT -- watershed code a is a descendant of watershed code b @@ -87,7 +88,7 @@ SELECT ) $$ -language 'sql' immutable parallel safe; +immutable parallel safe; @@ -105,9 +106,7 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Downstream( tolerance double precision default .001 ) -RETURNS boolean AS $$ - - +RETURNS boolean language sql set search_path = public AS $$ SELECT @@ -186,7 +185,7 @@ RETURNS boolean AS $$ END $$ -language 'sql' immutable parallel safe; +immutable parallel safe; CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Downstream( blue_line_key_a integer, @@ -201,7 +200,7 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Downstream( tolerance double precision default .001 ) -RETURNS boolean AS $$ +RETURNS boolean language sql set search_path = public AS $$ SELECT whse_basemapping.FWA_Downstream( @@ -219,6 +218,6 @@ SELECT ) $$ -language 'sql' immutable parallel safe; +immutable parallel safe; --COMMENT ON FUNCTION FWA_Downstream IS 'Compare input watershed codes and/or linear positions A and B, return TRUE if codes/positions A are downstream of codes/positions B'; \ No newline at end of file diff --git a/db/functions/FWA_Upstream.sql b/db/functions/FWA_Upstream.sql index a494e9f..0692d2f 100644 --- a/db/functions/FWA_Upstream.sql +++ b/db/functions/FWA_Upstream.sql @@ -62,8 +62,6 @@ return TRUE when the values for b are upstream of the values for a. */ --- ensure the functions are created in the public schema -set search_path to public; -- watershed code comparison only CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Upstream( @@ -75,6 +73,8 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Upstream( RETURNS boolean AS $$ +SET search_path TO public,whse_basemapping,usgs,hydrosheds; + SELECT -- Simple case, where watershed code and local code of (a) are equivalent. -- Return TRUE for all records in (b) that are children of (a) @@ -130,7 +130,8 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Upstream( tolerance double precision default .001 ) -RETURNS boolean AS $$ +RETURNS boolean language sql set search_path = public AS $$ + SELECT -- b is a child of a, always @@ -222,7 +223,7 @@ SELECT END ) $$ -language 'sql' immutable parallel safe; +immutable parallel safe; -- shortcut for points, dnstr measure a and upstr measure are equivalent @@ -239,7 +240,7 @@ CREATE OR REPLACE FUNCTION whse_basemapping.FWA_Upstream( tolerance double precision default .001 ) -RETURNS boolean AS $$ +RETURNS boolean language sql set search_path = public AS $$ SELECT whse_basemapping.FWA_Upstream( @@ -256,7 +257,7 @@ SELECT tolerance ) $$ -language 'sql' immutable parallel safe; +immutable parallel safe; --COMMENT ON FUNCTION FWA_Upstream IS 'Compare input watershed codes and/or linear positions A and B, return TRUE if codes/positions A are upstream of codes/positions B'; \ No newline at end of file