From 65db42263b42df775cd092591a65e41ff1d6bbb1 Mon Sep 17 00:00:00 2001 From: Shinya Kato <37682778+shinyaaa@users.noreply.github.com> Date: Thu, 8 Aug 2024 08:07:27 +0900 Subject: [PATCH] Add EmitWarningsOnPlaceholders("age") (#2000) Added EmitWarningsOnPlaceholders("age") to warn when an undefined GUC parameter is set for a placeholder named "age". Warnings are issued when PostgreSQL starts and when SET statements are executed. When PostgreSQL starts ``` 2024-08-01 18:32:31.220 JST [2039799] WARNING: invalid configuration parameter name "age.invalid_parameter", removing it ``` When SET statement is executed ``` ERROR: invalid configuration parameter name "age.invalid_parameter" DETAIL: "age" is a reserved prefix. ``` Regression tests were added. --- regress/expected/name_validation.out | 8 ++++++++ regress/sql/name_validation.sql | 7 +++++++ src/backend/utils/ag_guc.c | 1 + 3 files changed, 16 insertions(+) diff --git a/regress/expected/name_validation.out b/regress/expected/name_validation.out index a9f804076..d0ba31ec1 100644 --- a/regress/expected/name_validation.out +++ b/regress/expected/name_validation.out @@ -475,6 +475,14 @@ NOTICE: graph "graph123" has been dropped (1 row) +-- +-- Test GUC names +-- +SET age.enable_containment TO ON; +SET age.invalid_parameter TO ON; +ERROR: invalid configuration parameter name "age.invalid_parameter" +DETAIL: "age" is a reserved prefix. +SET any_placeholder.any_parameter TO ON; -- -- End of test -- diff --git a/regress/sql/name_validation.sql b/regress/sql/name_validation.sql index 0c96a25f2..acf782677 100644 --- a/regress/sql/name_validation.sql +++ b/regress/sql/name_validation.sql @@ -178,6 +178,13 @@ SELECT create_elabel('graph123', 'elabel0123456789012345678901234567890123456789 -- clean up SELECT drop_graph('graph123', true); +-- +-- Test GUC names +-- +SET age.enable_containment TO ON; +SET age.invalid_parameter TO ON; +SET any_placeholder.any_parameter TO ON; + -- -- End of test -- diff --git a/src/backend/utils/ag_guc.c b/src/backend/utils/ag_guc.c index d9a99f66e..86b4e00bc 100644 --- a/src/backend/utils/ag_guc.c +++ b/src/backend/utils/ag_guc.c @@ -42,4 +42,5 @@ void define_config_params(void) NULL, NULL, NULL); + EmitWarningsOnPlaceholders("age"); }