changeset 4872:5c12b7cdc58c

Make CHECK constraint work in sessions with empty search_path CHECK constraints involving is_valid_from_item() failed when applied in a session with empty search_path, if the checked entries contained any non-schema qualified references to database objects (e.g. PostGIS functions in the public schema). This prevented restoring the current default values in sys_admin.published_services from a dump created using pg_dump.
author Tom Gottfried <tom@intevation.de>
date Fri, 24 Jan 2020 16:48:59 +0100
parents 4d8982fa49f9
children 8a4c98b80fbd
files schema/gemma.sql
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/schema/gemma.sql	Tue Jan 14 15:05:44 2020 +0100
+++ b/schema/gemma.sql	Fri Jan 24 16:48:59 2020 +0100
@@ -27,6 +27,7 @@
 --
 
 -- Check if a given string can be used as a FROM item in an SQL statement
+-- All objects in stmt should be schema qualified if not in the public schema
 CREATE OR REPLACE FUNCTION is_valid_from_item(stmt text) RETURNS boolean
 AS $$
 BEGIN
@@ -38,6 +39,7 @@
         RETURN false;
 END
 $$
+    SET search_path TO 'public'
     LANGUAGE plpgsql
     STRICT;