summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-02-21 14:10:15 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2022-02-21 14:10:43 -0500
commit88103567cb8fa5be46dc9fac3e3b8774951a2be7 (patch)
tree731532cb1686190be3f48abe50fef3c2f7ee4214 /src/test
parent2776922201f751e3202a713b61d97fe4e44a8440 (diff)
downloadpostgresql-88103567cb8fa5be46dc9fac3e3b8774951a2be7.tar.gz
Disallow setting bogus GUCs within an extension's reserved namespace.
Commit 75d22069e tried to throw a warning for setting a custom GUC whose prefix belongs to a previously-loaded extension, if there is no such GUC defined by the extension. But that caused unstable behavior with parallel workers, because workers don't necessarily load extensions and GUCs in the same order their leader did. To make that work safely, we have to completely disallow the case. We now actually remove any such GUCs at the time of initial extension load, and then throw an error not just a warning if you try to add one later. While this might create a compatibility issue for a few people, the improvement in error-detection capability seems worth it; it's hard to believe that there's any good use-case for choosing such GUC names. This also un-reverts 5609cc01c (Rename EmitWarningsOnPlaceholders() to MarkGUCPrefixReserved()), since that function's old name is now even more of a misnomer. Florin Irion and Tom Lane Discussion: https://postgr.es/m/1902182.1640711215@sss.pgh.pa.us
Diffstat (limited to 'src/test')
-rw-r--r--src/test/modules/delay_execution/delay_execution.c2
-rw-r--r--src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c2
-rw-r--r--src/test/modules/worker_spi/worker_spi.c2
-rw-r--r--src/test/regress/expected/guc.out11
-rw-r--r--src/test/regress/sql/guc.sql7
5 files changed, 21 insertions, 3 deletions
diff --git a/src/test/modules/delay_execution/delay_execution.c b/src/test/modules/delay_execution/delay_execution.c
index ad50383bf8..cf34e8c2d7 100644
--- a/src/test/modules/delay_execution/delay_execution.c
+++ b/src/test/modules/delay_execution/delay_execution.c
@@ -91,7 +91,7 @@ _PG_init(void)
NULL,
NULL);
- EmitWarningsOnPlaceholders("delay_execution");
+ MarkGUCPrefixReserved("delay_execution");
/* Install our hook */
prev_planner_hook = planner_hook;
diff --git a/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c b/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c
index 3ba33e501c..7c469fd57e 100644
--- a/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c
+++ b/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c
@@ -49,7 +49,7 @@ _PG_init(void)
NULL,
NULL);
- EmitWarningsOnPlaceholders("ssl_passphrase");
+ MarkGUCPrefixReserved("ssl_passphrase");
if (ssl_passphrase)
openssl_tls_init_hook = set_rot13;
diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c
index 05ced63780..48829df29c 100644
--- a/src/test/modules/worker_spi/worker_spi.c
+++ b/src/test/modules/worker_spi/worker_spi.c
@@ -322,7 +322,7 @@ _PG_init(void)
0,
NULL, NULL, NULL);
- EmitWarningsOnPlaceholders("worker_spi");
+ MarkGUCPrefixReserved("worker_spi");
/* set up common data for all our workers */
memset(&worker, 0, sizeof(worker));
diff --git a/src/test/regress/expected/guc.out b/src/test/regress/expected/guc.out
index 75b6bfbf11..3de6404ba5 100644
--- a/src/test/regress/expected/guc.out
+++ b/src/test/regress/expected/guc.out
@@ -548,6 +548,17 @@ ERROR: invalid configuration parameter name "special.weird name"
DETAIL: Custom parameter names must be two or more simple identifiers separated by dots.
SHOW special."weird name";
ERROR: unrecognized configuration parameter "special.weird name"
+-- Check what happens when you try to set a "custom" GUC within the
+-- namespace of an extension.
+SET plpgsql.extra_foo_warnings = true; -- allowed if plpgsql is not loaded yet
+LOAD 'plpgsql'; -- this will throw a warning and delete the variable
+WARNING: invalid configuration parameter name "plpgsql.extra_foo_warnings", removing it
+DETAIL: "plpgsql" is now a reserved prefix.
+SET plpgsql.extra_foo_warnings = true; -- now, it's an error
+ERROR: invalid configuration parameter name "plpgsql.extra_foo_warnings"
+DETAIL: "plpgsql" is a reserved prefix.
+SHOW plpgsql.extra_foo_warnings;
+ERROR: unrecognized configuration parameter "plpgsql.extra_foo_warnings"
--
-- Test DISCARD TEMP
--
diff --git a/src/test/regress/sql/guc.sql b/src/test/regress/sql/guc.sql
index 3e2819449c..d5db101e48 100644
--- a/src/test/regress/sql/guc.sql
+++ b/src/test/regress/sql/guc.sql
@@ -163,6 +163,13 @@ SHOW custom."bad-guc";
SET special."weird name" = 'foo'; -- could be allowed, but we choose not to
SHOW special."weird name";
+-- Check what happens when you try to set a "custom" GUC within the
+-- namespace of an extension.
+SET plpgsql.extra_foo_warnings = true; -- allowed if plpgsql is not loaded yet
+LOAD 'plpgsql'; -- this will throw a warning and delete the variable
+SET plpgsql.extra_foo_warnings = true; -- now, it's an error
+SHOW plpgsql.extra_foo_warnings;
+
--
-- Test DISCARD TEMP
--