From: Shinya Kato <Shinya11.Kato@oss.nttdata.com>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Daniel Gustafsson <daniel@yesql.se>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Emit a warning if the extension's GUC is set incorrectly
Date: Mon, 20 Dec 2021 21:05:23 +0900
Message-ID: <c5660e836dd511549810fd35b12edc3c@oss.nttdata.com> (raw)
In-Reply-To: <83b33009-3a1b-9230-8f07-2115763c1853@enterprisedb.com>
References: <524fa2c0a34f34b68fbfa90d0760d515@oss.nttdata.com>
<681A95E0-0CCA-4C66-A12B-CE0D8D5076D7@yesql.se>
<25643eaa81a69416317e85c2fd7d4c0a@oss.nttdata.com>
<CALj2ACX9eDm9bPmcZDTGazEVrH+p7jUXfN0miBc_VVze_mjw9A@mail.gmail.com>
<98d354d3b099d8e24c6b653336bd29d7@oss.nttdata.com>
<CALj2ACUBKmDa35PmcfGZ==4rLNm4GW04D7o-ARkeipHijr5yuw@mail.gmail.com>
<4a2c5e69b98bf8ffbef2fad2f1850c97@oss.nttdata.com>
<9956b3b9-9cc3-49d2-f9e8-7f3ed3c63994@oss.nttdata.com>
<9f5e96ca44891915f1d2736bea9fdf45@oss.nttdata.com>
<83b33009-3a1b-9230-8f07-2115763c1853@enterprisedb.com>
On 2021-12-17 15:42, Peter Eisentraut wrote:
> On 17.12.21 03:25, Shinya Kato wrote:
>> For now, I'v attached the patch that fixed the compilation error.
>
> I think it would be good if you could split the uncontroversial new
> EmitErrorsOnPlaceholders() calls into a separate patch. And please
> add an explanation what exactly the rest of the patch changes.
Thank you for the comment!
I splitted the patch.
- v6-01-Add-EmitWarningsOnPlaceholders.patch
We should use EmitWarningsOnPlaceholders when we use
DefineCustomXXXVariable.
I don't think there is any room for debate.
- v6-0002-Change-error-level-of-EmitWarningsOnPlaceholders.patch
This is a patch to change the error level of EmitWarningsOnPlaceholders
from WARNING to ERROR.
I think it's OK to emit ERROR as well as when the wrong GUC is set for
non-extensions, or since it does not behave abnormally, it can be left
as WARNING.
Thought?
- v6-0003-Emit-error-when-invalid-extensions-GUCs-are-set.patch
This is a patch to emit error when invalid extension's GUCs are set.
No test changes have been made, so the regression test will fail.
I have created a patch, but I don't think this is necessary because of
the previous discussion.
--
Regards,
--
Shinya Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Attachments:download all (3 files, .tar.gz)v6-0001-Add-EmitWarningsOnPlaceholders.patch (text/x-diff, 3.1K) downloaddiff --git a/contrib/auth_delay/auth_delay.c b/contrib/auth_delay/auth_delay.cindex 5820ac328d..d11dd1e416 100644--- a/contrib/auth_delay/auth_delay.c+++ b/contrib/auth_delay/auth_delay.c@@ -67,6 +67,9 @@ _PG_init(void)
NULL,
NULL,
NULL);
++ EmitWarningsOnPlaceholders("auth_delay");+
/* Install Hooks */
original_client_auth_hook = ClientAuthentication_hook;
ClientAuthentication_hook = auth_delay_checks;
diff --git a/contrib/pg_trgm/trgm_op.c b/contrib/pg_trgm/trgm_op.cindex fb38135f7a..0407c7dd64 100644--- a/contrib/pg_trgm/trgm_op.c+++ b/contrib/pg_trgm/trgm_op.c@@ -100,6 +100,8 @@ _PG_init(void)
NULL,
NULL,
NULL);
++ EmitWarningsOnPlaceholders("pg_trgm");
}
/*
diff --git a/contrib/postgres_fdw/option.c b/contrib/postgres_fdw/option.cindex 48c7417e6e..36555398ec 100644--- a/contrib/postgres_fdw/option.c+++ b/contrib/postgres_fdw/option.c@@ -469,4 +469,6 @@ _PG_init(void)
NULL,
NULL,
NULL);
++ EmitWarningsOnPlaceholders("postgres_fdw");
}
diff --git a/contrib/sepgsql/hooks.c b/contrib/sepgsql/hooks.cindex 19a3ffb7ff..44a09c35a7 100644--- a/contrib/sepgsql/hooks.c+++ b/contrib/sepgsql/hooks.c@@ -455,6 +455,8 @@ _PG_init(void)
NULL,
NULL);
+ EmitWarningsOnPlaceholders("sepgsql");+
/* Initialize userspace access vector cache */
sepgsql_avc_init();
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.cindex e11837559d..1389aa0943 100644--- a/src/pl/tcl/pltcl.c+++ b/src/pl/tcl/pltcl.c@@ -474,6 +474,8 @@ _PG_init(void)
PGC_SUSET, 0,
NULL, NULL, NULL);
+ EmitWarningsOnPlaceholders("pltclu");+
pltcl_pm_init_done = true;
}
diff --git a/src/test/modules/delay_execution/delay_execution.c b/src/test/modules/delay_execution/delay_execution.cindex b3d0841ba8..8ec623ac52 100644--- a/src/test/modules/delay_execution/delay_execution.c+++ b/src/test/modules/delay_execution/delay_execution.c@@ -91,6 +91,8 @@ _PG_init(void)
NULL,
NULL);
+ EmitWarningsOnPlaceholders("delay_execution");+
/* Install our hook */
prev_planner_hook = planner_hook;
planner_hook = delay_execution_planner;
diff --git a/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c b/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.cindex 6b0a3db104..3ba33e501c 100644--- a/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c+++ b/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c@@ -48,6 +48,9 @@ _PG_init(void)
NULL,
NULL,
NULL);
++ EmitWarningsOnPlaceholders("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.cindex 0b6246676b..adb02d8cb8 100644--- a/src/test/modules/worker_spi/worker_spi.c+++ b/src/test/modules/worker_spi/worker_spi.c@@ -322,6 +322,8 @@ _PG_init(void)
0,
NULL, NULL, NULL);
+ EmitWarningsOnPlaceholders("worker_spi");+
/* set up common data for all our workers */
memset(&worker, 0, sizeof(worker));
worker.bgw_flags = BGWORKER_SHMEM_ACCESS |
v6-0002-Change-error-level-of-EmitWarningsOnPlaceholders.patch (text/x-diff, 935B) downloaddiff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.cindex 7b03046301..5e9407c34a 100644--- a/src/backend/utils/misc/guc.c+++ b/src/backend/utils/misc/guc.c@@ -9333,6 +9333,13 @@ DefineCustomEnumVariable(const char *name,
define_custom_variable(&var->gen);
}
+/*+ * For historical context, this function name is EmitWarningsOnPlaceholders,+ * but it emits an error when an invalid custom GUC is set.+ *+ * If we use DefineCustomXXXVariable, it is recommended that this function is+ * added.+ */
void
EmitWarningsOnPlaceholders(const char *className)
{
@@ -9348,7 +9355,7 @@ EmitWarningsOnPlaceholders(const char *className)
strncmp(className, var->name, classLen) == 0 &&
var->name[classLen] == GUC_QUALIFIER_SEPARATOR)
{
- ereport(WARNING,+ ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("unrecognized configuration parameter \"%s\"",
var->name)));
v6-0003-Emit-error-when-invalid-extensions-GUCs-are-set.patch (text/x-diff, 812B) downloaddiff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.cindex 7b03046301..deb41b2011 100644--- a/src/backend/utils/misc/guc.c+++ b/src/backend/utils/misc/guc.c@@ -5439,11 +5439,19 @@ valid_custom_variable_name(const char *name)
{
bool saw_sep = false;
bool name_start = true;
+ int placeholder_length = 0;
for (const char *p = name; *p; p++)
{
+ placeholder_length++;
if (*p == GUC_QUALIFIER_SEPARATOR)
{
+ /* Check invalid placeholder and custom parameter*/+ char *placeholder = malloc(sizeof(char) * (placeholder_length - 1));+ strncpy(placeholder, name, placeholder_length - 1);+ placeholder[placeholder_length -1] = '\0';+ EmitWarningsOnPlaceholders(placeholder);+
if (name_start)
return false; /* empty name component */
saw_sep = true;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: Shinya11.Kato@oss.nttdata.com, peter.eisentraut@enterprisedb.com, masao.fujii@oss.nttdata.com, bharath.rupireddyforpostgres@gmail.com, daniel@yesql.se
Subject: Re: Emit a warning if the extension's GUC is set incorrectly
In-Reply-To: <c5660e836dd511549810fd35b12edc3c@oss.nttdata.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox