Skip to content

Commit 009f8d1

Browse files
committed
Extend check_GUC_init() with checks on flag combinations when loading GUCs
This extends the work begun by a73952b, with the addition of a GUC check for flag combinations in check_GUC_init(), making sure that anything defined with GUC_NO_SHOW_ALL also includes GUC_NOT_IN_SAMPLE, as first step. There has never been any GUCs of this kind in the core code, and this combination makes little sense as a parameter marked as not fit for SHOW ALL should not be hidden in postgresql.conf.sample. Note that GUCs marked with GUC_NO_SHOW_ALL are not listed under pg_settings or SHOW ALL (still they can be queried individually), making them unfit for checks via SQL queries in the regression tests that do a full scan of the parameters available. The SQL tests are still a bit incorrect about that, and will be cleaned up in a separate commit. We have also discussed the possibility to extend the SQL functions for GUCs so as they could show more information about parameters defined with GUC_NO_SHOW_ALL, though it has been concluded that this is not worth the extra complication in the long run, an enforced policy at initialization time being enough to do the same job. Per discussion with Nitin Jadhav and Tom Lane. Discussion: https://postgr.es/m/CAMm1aWaYe0muu3ABo7iSAgK+OWDS9yNe8GGRYnCyeEpScYKa+g@mail.gmail.com
1 parent d07c294 commit 009f8d1

File tree

1 file changed

+22
-4
lines changed
  • src/backend/utils/misc

1 file changed

+22
-4
lines changed

src/backend/utils/misc/guc.c

+22-4
Original file line numberDiff line numberDiff line change
@@ -1383,11 +1383,14 @@ check_GUC_name_for_parameter_acl(const char *name)
13831383
}
13841384

13851385
/*
1386-
* Routine in charge of checking that the initial value of a GUC is the
1387-
* same when declared and when loaded to prevent anybody looking at the
1388-
* C declarations of these GUCS from being fooled by mismatched values.
1386+
* Routine in charge of checking various states of a GUC.
13891387
*
1390-
* The following validation rules apply:
1388+
* This performs two sanity checks. First, it checks that the initial
1389+
* value of a GUC is the same when declared and when loaded to prevent
1390+
* anybody looking at the C declarations of these GUCS from being fooled by
1391+
* mismatched values. Second, it checks for incorrect flag combinations.
1392+
*
1393+
* The following validation rules apply for the values:
13911394
* bool - can be false, otherwise must be same as the boot_val
13921395
* int - can be 0, otherwise must be same as the boot_val
13931396
* real - can be 0.0, otherwise must be same as the boot_val
@@ -1398,6 +1401,7 @@ check_GUC_name_for_parameter_acl(const char *name)
13981401
static bool
13991402
check_GUC_init(struct config_generic *gconf)
14001403
{
1404+
/* Checks on values */
14011405
switch (gconf->vartype)
14021406
{
14031407
case PGC_BOOL:
@@ -1462,6 +1466,20 @@ check_GUC_init(struct config_generic *gconf)
14621466
}
14631467
}
14641468

1469+
/* Flag combinations */
1470+
1471+
/*
1472+
* GUC_NO_SHOW_ALL requires GUC_NOT_IN_SAMPLE, as a parameter not part
1473+
* of SHOW ALL should not be hidden in postgresql.conf.sample.
1474+
*/
1475+
if ((gconf->flags & GUC_NO_SHOW_ALL) &&
1476+
!(gconf->flags & GUC_NOT_IN_SAMPLE))
1477+
{
1478+
elog(LOG, "GUC %s flags: NO_SHOW_ALL and !NOT_IN_SAMPLE",
1479+
gconf->name);
1480+
return false;
1481+
}
1482+
14651483
return true;
14661484
}
14671485
#endif

0 commit comments

Comments
 (0)