From 4d88a0a9ba919f0bab72dd6c0954d6dbcb55efef Mon Sep 17 00:00:00 2001 From: Nitin Jadhav Date: Sun, 29 Jan 2023 11:40:56 +0000 Subject: [PATCH] Fix GUC_NO_SHOW_ALL test scenario in 003_check_guc.pl The existing test does not handle a case when the parameters are listed as GUC_NO_SHOW_ALL in guc.c and if it is present in postgresql.conf.sample. There was no function/view to fetch the parameters which are marked as GUC_NO_SHOW_ALL. Hence modified the signature of show_all_settings() which takes an argument incl_no_show_all. If passed as true, it includes the parameters even if it is marked as GUC_NO_SHOW_ALL. Modified the test in 003_check_guc.pl accordingly. --- doc/src/sgml/func.sgml | 2 +- src/backend/catalog/system_views.sql | 2 +- src/backend/utils/misc/guc_funcs.c | 8 ++++++-- src/include/catalog/pg_proc.dat | 8 ++++---- src/test/modules/test_misc/t/003_check_guc.pl | 2 +- src/test/regress/expected/guc.out | 2 +- src/test/regress/expected/rules.out | 2 +- src/test/regress/sql/guc.sql | 2 +- 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index e09e289a43..6e1f48b6d2 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -26194,7 +26194,7 @@ postgres=# \set file_name '000000010000000100C000AB' postgres=# \set offset 256 postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset AS lsn FROM pg_split_walfile_name(:'file_name') pd, - pg_show_all_settings() ps + pg_show_all_settings(false) ps WHERE ps.name = 'wal_segment_size'; lsn --------------- diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 8608e3fa5b..7493e03033 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -588,7 +588,7 @@ FROM JOIN pg_authid rol ON l.classoid = rol.tableoid AND l.objoid = rol.oid; CREATE VIEW pg_settings AS - SELECT * FROM pg_show_all_settings() AS A; + SELECT * FROM pg_show_all_settings(false) AS A; CREATE RULE pg_settings_u AS ON UPDATE TO pg_settings diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c index 52c361e975..9cb51e4a07 100644 --- a/src/backend/utils/misc/guc_funcs.c +++ b/src/backend/utils/misc/guc_funcs.c @@ -858,6 +858,7 @@ show_config_by_name_missing_ok(PG_FUNCTION_ARGS) Datum show_all_settings(PG_FUNCTION_ARGS) { + bool incl_no_show_all = PG_GETARG_BOOL(0); FuncCallContext *funcctx; struct config_generic **guc_vars; int num_vars; @@ -952,8 +953,11 @@ show_all_settings(PG_FUNCTION_ARGS) HeapTuple tuple; Datum result; - /* skip if marked NO_SHOW_ALL or if not visible to current user */ - if ((conf->flags & GUC_NO_SHOW_ALL) || + /* + * skip if marked NO_SHOW_ALL when requested not to include NO_SHOW_ALL + * or if not visible to current user + */ + if ((!incl_no_show_all && (conf->flags & GUC_NO_SHOW_ALL)) || !ConfigOptionIsVisible(conf)) { call_cntr = ++funcctx->call_cntr; diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index c0f2a8a77c..3d214aa2d3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -6179,10 +6179,10 @@ prosrc => 'set_config_by_name' }, { oid => '2084', descr => 'SHOW ALL as a function', proname => 'pg_show_all_settings', prorows => '1000', proretset => 't', - provolatile => 's', prorettype => 'record', proargtypes => '', - proallargtypes => '{text,text,text,text,text,text,text,text,text,text,text,_text,text,text,text,int4,bool}', - proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}', - proargnames => '{name,setting,unit,category,short_desc,extra_desc,context,vartype,source,min_val,max_val,enumvals,boot_val,reset_val,sourcefile,sourceline,pending_restart}', + provolatile => 's', prorettype => 'record', proargtypes => 'bool', + proallargtypes => '{bool,text,text,text,text,text,text,text,text,text,text,text,_text,text,text,text,int4,bool}', + proargmodes => '{i,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}', + proargnames => '{incl_no_show_all,name,setting,unit,category,short_desc,extra_desc,context,vartype,source,min_val,max_val,enumvals,boot_val,reset_val,sourcefile,sourceline,pending_restart}', prosrc => 'show_all_settings' }, { oid => '6240', descr => 'return flags for specified GUC', diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl index 1786cd1929..2103608a08 100644 --- a/src/test/modules/test_misc/t/003_check_guc.pl +++ b/src/test/modules/test_misc/t/003_check_guc.pl @@ -17,7 +17,7 @@ $node->start; my $all_params = $node->safe_psql( 'postgres', "SELECT name - FROM pg_settings + FROM pg_show_all_settings(true) WHERE NOT 'NOT_IN_SAMPLE' = ANY (pg_settings_get_flags(name)) AND name <> 'config_file' ORDER BY 1"); diff --git a/src/test/regress/expected/guc.out b/src/test/regress/expected/guc.out index 2914b950b4..a60db098a2 100644 --- a/src/test/regress/expected/guc.out +++ b/src/test/regress/expected/guc.out @@ -844,7 +844,7 @@ CREATE TABLE tab_settings_flags AS SELECT name, category, 'NO_SHOW_ALL' = ANY(flags) AS no_show_all, 'NOT_IN_SAMPLE' = ANY(flags) AS not_in_sample, 'RUNTIME_COMPUTED' = ANY(flags) AS runtime_computed - FROM pg_show_all_settings() AS psas, + FROM pg_show_all_settings(false) AS psas, pg_settings_get_flags(psas.name) AS flags; -- Developer GUCs should be flagged with GUC_NOT_IN_SAMPLE: SELECT name FROM tab_settings_flags diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index e7a2f5856a..20edbd61ed 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -1719,7 +1719,7 @@ pg_settings| SELECT name, sourcefile, sourceline, pending_restart - FROM pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, sourcefile, sourceline, pending_restart); + FROM pg_show_all_settings(false) a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, sourcefile, sourceline, pending_restart); pg_shadow| SELECT pg_authid.rolname AS usename, pg_authid.oid AS usesysid, pg_authid.rolcreatedb AS usecreatedb, diff --git a/src/test/regress/sql/guc.sql b/src/test/regress/sql/guc.sql index d40d0c178f..ffeb3df99b 100644 --- a/src/test/regress/sql/guc.sql +++ b/src/test/regress/sql/guc.sql @@ -329,7 +329,7 @@ CREATE TABLE tab_settings_flags AS SELECT name, category, 'NO_SHOW_ALL' = ANY(flags) AS no_show_all, 'NOT_IN_SAMPLE' = ANY(flags) AS not_in_sample, 'RUNTIME_COMPUTED' = ANY(flags) AS runtime_computed - FROM pg_show_all_settings() AS psas, + FROM pg_show_all_settings(false) AS psas, pg_settings_get_flags(psas.name) AS flags; -- Developer GUCs should be flagged with GUC_NOT_IN_SAMPLE: -- 2.25.1