Skip to content

Commit

Permalink
Add EmitWarningsOnPlaceholders("age") (apache#2000)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shinyaaa authored Aug 7, 2024
1 parent 29588a2 commit 65db422
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions regress/expected/name_validation.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
--
7 changes: 7 additions & 0 deletions regress/sql/name_validation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
--
1 change: 1 addition & 0 deletions src/backend/utils/ag_guc.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ void define_config_params(void)
NULL,
NULL,
NULL);
EmitWarningsOnPlaceholders("age");
}

0 comments on commit 65db422

Please sign in to comment.