summaryrefslogtreecommitdiff
path: root/src/backend/utils/misc
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2008-09-10 18:09:20 +0000
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2008-09-10 18:09:20 +0000
commit3b9ec4682c2f1baeeeba10b6d782386656a98f4a (patch)
tree23c9dc2306aea80cbd7bf8f45232ddeb4ac6e527 /src/backend/utils/misc
parentbacf7b2086d971e8b3f65eea00b5550db6fa9614 (diff)
downloadpostgresql-3b9ec4682c2f1baeeeba10b6d782386656a98f4a.tar.gz
Add "source file" and "source line" information to each GUC variable.
initdb forced due to changes in the pg_settings view. Magnus Hagander and Alvaro Herrera.
Diffstat (limited to 'src/backend/utils/misc')
-rw-r--r--src/backend/utils/misc/guc-file.l19
-rw-r--r--src/backend/utils/misc/guc.c61
2 files changed, 70 insertions, 10 deletions
diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index a95a35d2f7..5b4a68635b 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -4,7 +4,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.56 2008/08/22 00:20:40 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.57 2008/09/10 18:09:19 alvherre Exp $
*/
%{
@@ -39,6 +39,8 @@ struct name_value_pair
{
char *name;
char *value;
+ char *filename;
+ int sourceline;
struct name_value_pair *next;
};
@@ -307,8 +309,12 @@ ProcessConfigFile(GucContext context)
/* If we got here all the options checked out okay, so apply them. */
for (item = head; item; item = item->next)
{
- set_config_option(item->name, item->value, context,
- PGC_S_FILE, GUC_ACTION_SET, true);
+ if (set_config_option(item->name, item->value, context,
+ PGC_S_FILE, GUC_ACTION_SET, true))
+ {
+ set_config_sourcefile(item->name, item->filename,
+ item->sourceline);
+ }
}
/* Remember when we last successfully loaded the config file. */
@@ -483,6 +489,8 @@ ParseConfigFile(const char *config_file, const char *calling_file,
pfree(item->value);
item->name = opt_name;
item->value = opt_value;
+ item->filename = pstrdup(config_file);
+ item->sourceline = ConfigFileLineno-1;
}
else
{
@@ -490,6 +498,8 @@ ParseConfigFile(const char *config_file, const char *calling_file,
item = palloc(sizeof *item);
item->name = opt_name;
item->value = opt_value;
+ item->filename = pstrdup(config_file);
+ item->sourceline = ConfigFileLineno-1;
item->next = *head_p;
*head_p = item;
if (*tail_p == NULL)
@@ -502,6 +512,8 @@ ParseConfigFile(const char *config_file, const char *calling_file,
item = palloc(sizeof *item);
item->name = opt_name;
item->value = opt_value;
+ item->filename = pstrdup(config_file);
+ item->sourceline = ConfigFileLineno-1;
item->next = NULL;
if (*head_p == NULL)
*head_p = item;
@@ -553,6 +565,7 @@ free_name_value_list(struct name_value_pair *list)
pfree(item->name);
pfree(item->value);
+ pfree(item->filename);
pfree(item);
item = next;
}
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 149817e6c9..4cc1ef3a94 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.470 2008/08/25 15:11:00 mha Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.471 2008/09/10 18:09:19 alvherre Exp $
*
*--------------------------------------------------------------------
*/
@@ -129,6 +129,8 @@ extern bool optimize_bounded_sort;
extern char *SSLCipherSuites;
#endif
+static void set_config_sourcefile(const char *name, char *sourcefile,
+ int sourceline);
static const char *assign_log_destination(const char *value,
bool doit, GucSource source);
@@ -3200,6 +3202,8 @@ InitializeGUCOptions(void)
gconf->reset_source = PGC_S_DEFAULT;
gconf->source = PGC_S_DEFAULT;
gconf->stack = NULL;
+ gconf->sourcefile = NULL;
+ gconf->sourceline = 0;
switch (gconf->vartype)
{
@@ -3541,7 +3545,6 @@ ResetAllOptions(void)
PGC_S_SESSION))
elog(ERROR, "failed to reset %s", conf->gen.name);
*conf->variable = conf->reset_val;
- conf->gen.source = conf->gen.reset_source;
break;
}
case PGC_INT:
@@ -3553,7 +3556,6 @@ ResetAllOptions(void)
PGC_S_SESSION))
elog(ERROR, "failed to reset %s", conf->gen.name);
*conf->variable = conf->reset_val;
- conf->gen.source = conf->gen.reset_source;
break;
}
case PGC_REAL:
@@ -3565,7 +3567,6 @@ ResetAllOptions(void)
PGC_S_SESSION))
elog(ERROR, "failed to reset %s", conf->gen.name);
*conf->variable = conf->reset_val;
- conf->gen.source = conf->gen.reset_source;
break;
}
case PGC_STRING:
@@ -3594,7 +3595,6 @@ ResetAllOptions(void)
}
set_string_field(conf, conf->variable, str);
- conf->gen.source = conf->gen.reset_source;
break;
}
case PGC_ENUM:
@@ -3606,11 +3606,12 @@ ResetAllOptions(void)
PGC_S_SESSION))
elog(ERROR, "failed to reset %s", conf->gen.name);
*conf->variable = conf->reset_val;
- conf->gen.source = conf->gen.reset_source;
break;
}
}
+ gconf->source = gconf->reset_source;
+
if (gconf->flags & GUC_REPORT)
ReportGUCOption(gconf);
}
@@ -5108,9 +5109,38 @@ set_config_option(const char *name, const char *value,
/*
+ * Set the fields for source file and line number the setting came from.
+ */
+static void
+set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
+{
+ struct config_generic *record;
+ int elevel;
+
+ /*
+ * To avoid cluttering the log, only the postmaster bleats loudly
+ * about problems with the config file.
+ */
+ elevel = IsUnderPostmaster ? DEBUG3 : LOG;
+
+ record = find_option(name, true, elevel);
+ /* should not happen */
+ if (record == NULL)
+ elog(ERROR, "unrecognized configuration parameter \"%s\"", name);
+
+ if (record->sourcefile)
+ free(record->sourcefile);
+ record->sourcefile = guc_strdup(elevel, sourcefile);
+ record->sourceline = sourceline;
+}
+
+/*
* Set a config option to the given value. See also set_config_option,
* this is just the wrapper to be called from outside GUC. NB: this
* is used only for non-transactional operations.
+ *
+ * Note: there is no support here for setting source file/line, as it
+ * is currently not needed.
*/
void
SetConfigOption(const char *name, const char *value,
@@ -6144,6 +6174,19 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
}
break;
}
+
+ /* If the setting came from a config file, set the source location */
+ if (conf->source == PGC_S_FILE)
+ {
+ values[12] = conf->sourcefile;
+ snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);
+ values[13] = pstrdup(buffer);
+ }
+ else
+ {
+ values[12] = NULL;
+ values[13] = NULL;
+ }
}
/*
@@ -6179,7 +6222,7 @@ show_config_by_name(PG_FUNCTION_ARGS)
* show_all_settings - equiv to SHOW ALL command but implemented as
* a Table Function.
*/
-#define NUM_PG_SETTINGS_ATTS 12
+#define NUM_PG_SETTINGS_ATTS 14
Datum
show_all_settings(PG_FUNCTION_ARGS)
@@ -6231,6 +6274,10 @@ show_all_settings(PG_FUNCTION_ARGS)
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals",
TEXTOID, -1, 0);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 13, "sourcefile",
+ TEXTOID, -1, 0);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 14, "sourceline",
+ INT4OID, -1, 0);
/*
* Generate attribute metadata needed later to produce tuples from raw