pgsql: Add check on initial and boot values when loading GUCs - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Add check on initial and boot values when loading GUCs
Date
Msg-id E1opMta-001YXw-Qp@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Add check on initial and boot values when loading GUCs

This commit adds a function to perform a cross-check between the initial
value of the C declaration associated to a GUC and its actual boot
value in assert-enabled builds.  The purpose of this is to prevent
anybody reading these C declarations from being fooled by mismatched
values before they are loaded at program startup.

The following rules apply depending on the GUC type:
* bool - can be false, or same as boot_val.
* int - can be 0, or same as the boot_val.
* real - can be 0.0, or same as the boot_val.
* string - can be NULL, or strcmp'd equal to the boot_val.
* enum - equal to the boot_val.

This is done for the system as well custom GUCs loaded by external
modules, which may require extension developers to adapt the C
declaration of the variables used by these GUCs (testing this change
with some of my own modules has allowed me to catch some stupid typos,
FWIW).  This may finish by being a bad experiment depending on the
feedbcak received, but let's see how it goes.

Author: Peter Smith
Reviewed-by: Nathan Bossart, Tom Lane, Michael Paquier, Justin Pryzby
Discussion: https://postgr.es/m/CAHut+PtHE0XSfjjRQ6D4v7+dqzCw=d+1a64ujra4EX8aoc_Z+w@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a73952b795632b2cf5acada8476e7cf75857e9be

Modified Files
--------------
src/backend/utils/misc/guc.c | 89 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Clean up some inconsistencies with GUC declarations
Next
From: Peter Eisentraut
Date:
Subject: pgsql: pg_dump test: Make concatenated create_sql commands more readabl