summaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/guc.c
diff options
context:
space:
mode:
authorJeff Davis <jdavis@postgresql.org>2024-03-04 19:42:16 -0800
committerJeff Davis <jdavis@postgresql.org>2024-03-04 19:42:16 -0800
commit59825d16399699e2f99016b9add46cb2d4916f82 (patch)
treeea8d60b32711b06de70773059bbc3a70d5d76e00 /src/backend/utils/misc/guc.c
parenta37a3e2b36d7de965f974b8caca0c295833708f2 (diff)
Fix buildfarm failures from 2af07e2f74.
Use GUC_ACTION_SAVE rather than GUC_ACTION_SET, necessary for working with parallel query. Now that the call requires more arguments, wrap the call in a new function to avoid code duplication and offer a place for a comment. Discussion: https://postgr.es/m/E1rhJpO-0027Wf-9L@gemulon.postgresql.org
Diffstat (limited to 'src/backend/utils/misc/guc.c')
-rw-r--r--src/backend/utils/misc/guc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index f12eef75e0c..dd5a46469a6 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -67,6 +67,12 @@
*/
#define REALTYPE_PRECISION 17
+/*
+ * Safe search path when executing code as the table owner, such as during
+ * maintenance operations.
+ */
+#define GUC_SAFE_SEARCH_PATH "pg_catalog, pg_temp"
+
static int GUC_check_errcode_value;
static List *reserved_class_prefix = NIL;
@@ -2235,6 +2241,19 @@ NewGUCNestLevel(void)
}
/*
+ * Set search_path to a fixed value for maintenance operations. No effect
+ * during bootstrap, when the search_path is already set to a fixed value and
+ * cannot be changed.
+ */
+void
+RestrictSearchPath(void)
+{
+ if (!IsBootstrapProcessingMode())
+ set_config_option("search_path", GUC_SAFE_SEARCH_PATH, PGC_USERSET,
+ PGC_S_SESSION, GUC_ACTION_SAVE, true, 0, false);
+}
+
+/*
* Do GUC processing at transaction or subtransaction commit or abort, or
* when exiting a function that has proconfig settings, or when undoing a
* transient assignment to some GUC variables. (The name is thus a bit of