diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index aecdcd0..e8cf396 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -194,6 +194,27 @@ pg_reload_conf(PG_FUNCTION_ARGS) PG_RETURN_BOOL(true); } +/* + * Test the effects of reloading postgresql.conf file's contents + */ +Datum +pg_test_reload_conf(PG_FUNCTION_ARGS) +{ + int nestlevel; + + if (!superuser()) + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + (errmsg("must be superuser to test the contents of postgresql.conf file")))); + + nestlevel = NewGUCNestLevel(); + + ProcessConfigFile_base(PGC_SIGHUP, true); + + AtEOXact_GUC(false, nestlevel); + + PG_RETURN_BOOL(true); +} /* * Rotate log file diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l index d3565a5..ff23711 100644 --- a/src/backend/utils/misc/guc-file.l +++ b/src/backend/utils/misc/guc-file.l @@ -111,7 +111,7 @@ STRING \'([^'\\\n]|\\.|\'\')*\' * If an error occurs, no values will be changed. */ void -ProcessConfigFile(GucContext context) +ProcessConfigFile_base(GucContext context, bool testing) { bool error = false; bool apply = false; @@ -288,7 +288,7 @@ ProcessConfigFile(GucContext context) int scres; /* In SIGHUP cases in the postmaster, we want to report changes */ - if (context == PGC_SIGHUP && !IsUnderPostmaster) + if ((context == PGC_SIGHUP && !IsUnderPostmaster) || testing) { const char *preval = GetConfigOption(item->name, true, false); @@ -300,7 +300,7 @@ ProcessConfigFile(GucContext context) } scres = set_config_option(item->name, item->value, - context, PGC_S_FILE, + context, testing ? PGC_S_TEST : PGC_S_FILE, GUC_ACTION_SET, true, 0); if (scres > 0) { diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index b5be075..5c6ce06 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -4721,6 +4721,7 @@ DESCR("SP-GiST support for quad tree over range"); DATA(insert OID = 3473 ( spg_range_quad_leaf_consistent PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 16 "2281 2281" _null_ _null_ _null_ _null_ spg_range_quad_leaf_consistent _null_ _null_ _null_ )); DESCR("SP-GiST support for quad tree over range"); +DATA(insert OID = 9999 ( pg_test_reload_conf PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pg_test_reload_conf _null_ _null_ _null_ )); /* event triggers */ DATA(insert OID = 3566 ( pg_event_trigger_dropped_objects PGNSP PGUID 12 10 100 0 0 f f f f t t s 0 0 2249 "" "{26,26,23,25,25,25,25}" "{o,o,o,o,o,o,o}" "{classid, objid, objsubid, object_type, schema_name, object_name, object_identity}" _null_ pg_event_trigger_dropped_objects _null_ _null_ _null_ )); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 667c58b..eb5032b 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -478,6 +478,7 @@ extern Datum current_query(PG_FUNCTION_ARGS); extern Datum pg_cancel_backend(PG_FUNCTION_ARGS); extern Datum pg_terminate_backend(PG_FUNCTION_ARGS); extern Datum pg_reload_conf(PG_FUNCTION_ARGS); +extern Datum pg_test_reload_conf(PG_FUNCTION_ARGS); extern Datum pg_tablespace_databases(PG_FUNCTION_ARGS); extern Datum pg_tablespace_location(PG_FUNCTION_ARGS); extern Datum pg_rotate_logfile(PG_FUNCTION_ARGS); diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index d497b1f..42cdb38 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -307,7 +307,8 @@ extern void EmitWarningsOnPlaceholders(const char *className); extern const char *GetConfigOption(const char *name, bool missing_ok, bool restrict_superuser); extern const char *GetConfigOptionResetString(const char *name); -extern void ProcessConfigFile(GucContext context); +extern void ProcessConfigFile_base(GucContext context, bool reportchanges); +#define ProcessConfigFile(context) ProcessConfigFile_base(context, false) extern void InitializeGUCOptions(void); extern bool SelectConfigFiles(const char *userDoption, const char *progname); extern void ResetAllOptions(void);