Skip to content

Commit 9f5836d

Browse files
committed
Remember the source GucContext for each GUC parameter.
We used to just remember the GucSource, but saving GucContext too provides a little more information --- notably, whether a SET was done by a superuser or regular user. This allows us to rip out the fairly dodgy code that define_custom_variable used to use to try to infer the context to re-install a pre-existing setting with. In particular, it now works for a superuser to SET a extension's SUSET custom variable before loading the associated extension, because GUC can remember whether the SET was done as a superuser or not. The plperl regression tests contain an example where this is useful.
1 parent 09e196e commit 9f5836d

File tree

9 files changed

+73
-81
lines changed

9 files changed

+73
-81
lines changed

src/backend/utils/misc/guc-file.l

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,7 @@ ProcessConfigFile(GucContext context)
296296
GUC_ACTION_SET, true);
297297
if (scres > 0)
298298
{
299-
/* variable was updated, so remember the source location */
300-
set_config_sourcefile(item->name, item->filename,
301-
item->sourceline);
302-
303-
/* and log the change if appropriate */
299+
/* variable was updated, so log the change if appropriate */
304300
if (pre_value)
305301
{
306302
const char *post_value = GetConfigOption(item->name, true, false);
@@ -315,7 +311,17 @@ ProcessConfigFile(GucContext context)
315311
}
316312
else if (scres == 0)
317313
error = true;
318-
/* else no error but variable was not changed, do nothing */
314+
/* else no error but variable's active value was not changed */
315+
316+
/*
317+
* We should update source location unless there was an error, since
318+
* even if the active value didn't change, the reset value might have.
319+
* (In the postmaster, there won't be a difference, but it does matter
320+
* in backends.)
321+
*/
322+
if (scres != 0)
323+
set_config_sourcefile(item->name, item->filename,
324+
item->sourceline);
319325

320326
if (pre_value)
321327
pfree(pre_value);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy