From 583210e77cbb2bd75f36627b459d97647abd436f Mon Sep 17 00:00:00 2001 From: Soumyadeep Chakraborty Date: Mon, 7 Aug 2023 15:09:09 -0700 Subject: [PATCH] Fix CREATE EXTENSION change user's search_path. Cherry-picked from greenplum-db/gpdb#16160 This is fixed by setting 'relocatable=false' and 'schema' to make extension responding to SCHEMA option of CREATE EXTENSION. I expand the PR from two extensions to all four problematic extensions. This is preferred over setting and referencing search_path directly in the extension install script - which leads to issues such as #59. Also take out 'relocatable=true' as these extensions were never relocatable to begin with due to their explicit need to create everything under public (and besides relocatable and schema are conflicting options). See: https://github.com/greenplum-db/gpdb/pull/16160 See: Issue#59 --- .../gp_debug_numsegments/gp_debug_numsegments--1.0.sql | 2 -- .../gp_debug_numsegments/gp_debug_numsegments.control | 2 +- .../gp_distribution_policy/gp_distribution_policy--1.0.sql | 2 -- .../gp_distribution_policy/gp_distribution_policy.control | 2 +- gpcontrib/gp_internal_tools/gp_internal_tools--1.0.0.sql | 7 ------- gpcontrib/gp_internal_tools/gp_internal_tools.control | 2 +- gpcontrib/gp_sparse_vector/gp_sparse_vector--1.0.1.sql | 6 ------ gpcontrib/gp_sparse_vector/gp_sparse_vector.control | 2 +- 8 files changed, 4 insertions(+), 21 deletions(-) diff --git a/gpcontrib/gp_debug_numsegments/gp_debug_numsegments--1.0.sql b/gpcontrib/gp_debug_numsegments/gp_debug_numsegments--1.0.sql index b2c10cf04d2..4a121070e78 100644 --- a/gpcontrib/gp_debug_numsegments/gp_debug_numsegments--1.0.sql +++ b/gpcontrib/gp_debug_numsegments/gp_debug_numsegments--1.0.sql @@ -3,8 +3,6 @@ -- complain if script is sourced in psql, rather than via CREATE EXTENSION \echo Use "CREATE EXTENSION gp_debug_numsegments" to load this file. \quit -SET search_path = public; - -- This function set the default numsegments when creating tables. -- This form accepts a text argument: 'full', 'minimal', 'random'. CREATE OR REPLACE FUNCTION gp_debug_set_create_table_default_numsegments(text) RETURNS text diff --git a/gpcontrib/gp_debug_numsegments/gp_debug_numsegments.control b/gpcontrib/gp_debug_numsegments/gp_debug_numsegments.control index fee8da81a58..c411a7f5925 100644 --- a/gpcontrib/gp_debug_numsegments/gp_debug_numsegments.control +++ b/gpcontrib/gp_debug_numsegments/gp_debug_numsegments.control @@ -2,4 +2,4 @@ comment = 'get / set default numsegments when creating tables' default_version = '1.0' module_pathname = '$libdir/gp_debug_numsegments' -relocatable = true +schema = public diff --git a/gpcontrib/gp_distribution_policy/gp_distribution_policy--1.0.sql b/gpcontrib/gp_distribution_policy/gp_distribution_policy--1.0.sql index 3bfeb3c1846..56b1cfe60fa 100644 --- a/gpcontrib/gp_distribution_policy/gp_distribution_policy--1.0.sql +++ b/gpcontrib/gp_distribution_policy/gp_distribution_policy--1.0.sql @@ -3,8 +3,6 @@ -- complain if script is sourced in psql, rather than via CREATE EXTENSION \echo Use "CREATE EXTENSION gp_distribution_policy" to load this file. \quit -SET search_path = public; - -- This function validates the data distribution in a table in a segment. CREATE OR REPLACE FUNCTION gp_distribution_policy_table_check(relid regclass) RETURNS boolean diff --git a/gpcontrib/gp_distribution_policy/gp_distribution_policy.control b/gpcontrib/gp_distribution_policy/gp_distribution_policy.control index d766af836bb..451e8afedcd 100644 --- a/gpcontrib/gp_distribution_policy/gp_distribution_policy.control +++ b/gpcontrib/gp_distribution_policy/gp_distribution_policy.control @@ -2,4 +2,4 @@ comment = 'check distribution policy in a GPDB cluster' default_version = '1.0' module_pathname = '$libdir/gp_distribution_policy' -relocatable = true +schema = public diff --git a/gpcontrib/gp_internal_tools/gp_internal_tools--1.0.0.sql b/gpcontrib/gp_internal_tools/gp_internal_tools--1.0.0.sql index 1e168871d65..db671b17919 100644 --- a/gpcontrib/gp_internal_tools/gp_internal_tools--1.0.0.sql +++ b/gpcontrib/gp_internal_tools/gp_internal_tools--1.0.0.sql @@ -5,11 +5,6 @@ -------------------------------------------------------------------------------- -- Session state functions and views -- -------------------------------------------------------------------------------- --- Adjust this setting to control where the objects get created. - -CREATE SCHEMA session_state; -SET search_path = session_state; - -- SessionState views -------------------------------------------------------------------------------- @@ -105,5 +100,3 @@ pg_stat_activity as S ON M.sessionid = S.sess_id; GRANT SELECT ON session_level_memory_consumption TO public; - -SET search_path TO DEFAULT; diff --git a/gpcontrib/gp_internal_tools/gp_internal_tools.control b/gpcontrib/gp_internal_tools/gp_internal_tools.control index c42720d190b..f0b78502973 100644 --- a/gpcontrib/gp_internal_tools/gp_internal_tools.control +++ b/gpcontrib/gp_internal_tools/gp_internal_tools.control @@ -1,3 +1,3 @@ comment = 'Different internal tools for Cloudberry Database' default_version = '1.0.0' -relocatable = true +schema = session_state diff --git a/gpcontrib/gp_sparse_vector/gp_sparse_vector--1.0.1.sql b/gpcontrib/gp_sparse_vector/gp_sparse_vector--1.0.1.sql index e94784f1646..543a2ca9a1d 100644 --- a/gpcontrib/gp_sparse_vector/gp_sparse_vector--1.0.1.sql +++ b/gpcontrib/gp_sparse_vector/gp_sparse_vector--1.0.1.sql @@ -1,10 +1,6 @@ -- complain if script is sourced in psql, rather than via CREATE EXTENSION \echo Use "CREATE EXTENSION gp_sparse_vector" to load this file. \quit -CREATE SCHEMA sparse_vector; - -SET search_path TO sparse_vector; - DROP TYPE IF EXISTS svec CASCADE; CREATE TYPE svec; @@ -373,5 +369,3 @@ OPERATOR 3 == , OPERATOR 4 >= , OPERATOR 5 > , FUNCTION 1 svec_l2_cmp(svec, svec); - -SET search_path TO DEFAULT; diff --git a/gpcontrib/gp_sparse_vector/gp_sparse_vector.control b/gpcontrib/gp_sparse_vector/gp_sparse_vector.control index 898da449cbc..c07128d934f 100644 --- a/gpcontrib/gp_sparse_vector/gp_sparse_vector.control +++ b/gpcontrib/gp_sparse_vector/gp_sparse_vector.control @@ -1,3 +1,3 @@ comment = 'SParse vector implementation for GreenPlum' default_version = '1.0.1' -relocatable = true +schema = sparse_vector