Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3b9ec46

Browse files
committed
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.
1 parentbacf7b2 commit3b9ec46

File tree

7 files changed

+93
-17
lines changed

7 files changed

+93
-17
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.172 2008/07/30 17:05:04 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.173 2008/09/10 18:09:19 alvherre Exp $ -->
22
<!--
33
Documentation of the system catalogs, directed toward PostgreSQL developers
44
-->
@@ -6414,6 +6414,20 @@
64146414
<entry>Allowed values in enum parameters (NULL for non-enum
64156415
values)</entry>
64166416
</row>
6417+
<row>
6418+
<entry><structfield>sourcefile</structfield></entry>
6419+
<entry><type>text</type></entry>
6420+
<entry>Input file the current value was set from (NULL for values set in
6421+
sources other than configuration files). Helpful when using
6422+
configuration include directives.</entry>
6423+
</row>
6424+
<row>
6425+
<entry><structfield>sourceline</structfield></entry>
6426+
<entry><type>text</type></entry>
6427+
<entry>Line number within the sourcefile the current value was set
6428+
from (NULL for values set in sources other than configuration files)
6429+
</entry>
6430+
</row>
64176431
</tbody>
64186432
</tgroup>
64196433
</table>

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.56 2008/08/22 00:20:40 momjian Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.57 2008/09/10 18:09:19 alvherre Exp $
88
*/
99

1010
%{
@@ -39,6 +39,8 @@ struct name_value_pair
3939
{
4040
char *name;
4141
char *value;
42+
char *filename;
43+
intsourceline;
4244
structname_value_pair *next;
4345
};
4446

@@ -307,8 +309,12 @@ ProcessConfigFile(GucContext context)
307309
/* If we got here all the options checked out okay, so apply them. */
308310
for (item = head; item; item = item->next)
309311
{
310-
set_config_option(item->name, item->value, context,
311-
PGC_S_FILE, GUC_ACTION_SET,true);
312+
if (set_config_option(item->name, item->value, context,
313+
PGC_S_FILE, GUC_ACTION_SET,true))
314+
{
315+
set_config_sourcefile(item->name, item->filename,
316+
item->sourceline);
317+
}
312318
}
313319

314320
/* Remember when we last successfully loaded the config file. */
@@ -483,13 +489,17 @@ ParseConfigFile(const char *config_file, const char *calling_file,
483489
pfree(item->value);
484490
item->name = opt_name;
485491
item->value = opt_value;
492+
item->filename =pstrdup(config_file);
493+
item->sourceline = ConfigFileLineno-1;
486494
}
487495
else
488496
{
489497
/* prepend to list */
490498
item =palloc(sizeof *item);
491499
item->name = opt_name;
492500
item->value = opt_value;
501+
item->filename =pstrdup(config_file);
502+
item->sourceline = ConfigFileLineno-1;
493503
item->next = *head_p;
494504
*head_p = item;
495505
if (*tail_p ==NULL)
@@ -502,6 +512,8 @@ ParseConfigFile(const char *config_file, const char *calling_file,
502512
item =palloc(sizeof *item);
503513
item->name = opt_name;
504514
item->value = opt_value;
515+
item->filename =pstrdup(config_file);
516+
item->sourceline = ConfigFileLineno-1;
505517
item->next =NULL;
506518
if (*head_p ==NULL)
507519
*head_p = item;
@@ -553,6 +565,7 @@ free_name_value_list(struct name_value_pair *list)
553565

554566
pfree(item->name);
555567
pfree(item->value);
568+
pfree(item->filename);
556569
pfree(item);
557570
item = next;
558571
}

‎src/backend/utils/misc/guc.c

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.470 2008/08/25 15:11:00 mha Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.471 2008/09/10 18:09:19 alvherre Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -129,6 +129,8 @@ extern bool optimize_bounded_sort;
129129
externchar*SSLCipherSuites;
130130
#endif
131131

132+
staticvoidset_config_sourcefile(constchar*name,char*sourcefile,
133+
intsourceline);
132134

133135
staticconstchar*assign_log_destination(constchar*value,
134136
booldoit,GucSourcesource);
@@ -3200,6 +3202,8 @@ InitializeGUCOptions(void)
32003202
gconf->reset_source=PGC_S_DEFAULT;
32013203
gconf->source=PGC_S_DEFAULT;
32023204
gconf->stack=NULL;
3205+
gconf->sourcefile=NULL;
3206+
gconf->sourceline=0;
32033207

32043208
switch (gconf->vartype)
32053209
{
@@ -3541,7 +3545,6 @@ ResetAllOptions(void)
35413545
PGC_S_SESSION))
35423546
elog(ERROR,"failed to reset %s",conf->gen.name);
35433547
*conf->variable=conf->reset_val;
3544-
conf->gen.source=conf->gen.reset_source;
35453548
break;
35463549
}
35473550
casePGC_INT:
@@ -3553,7 +3556,6 @@ ResetAllOptions(void)
35533556
PGC_S_SESSION))
35543557
elog(ERROR,"failed to reset %s",conf->gen.name);
35553558
*conf->variable=conf->reset_val;
3556-
conf->gen.source=conf->gen.reset_source;
35573559
break;
35583560
}
35593561
casePGC_REAL:
@@ -3565,7 +3567,6 @@ ResetAllOptions(void)
35653567
PGC_S_SESSION))
35663568
elog(ERROR,"failed to reset %s",conf->gen.name);
35673569
*conf->variable=conf->reset_val;
3568-
conf->gen.source=conf->gen.reset_source;
35693570
break;
35703571
}
35713572
casePGC_STRING:
@@ -3594,7 +3595,6 @@ ResetAllOptions(void)
35943595
}
35953596

35963597
set_string_field(conf,conf->variable,str);
3597-
conf->gen.source=conf->gen.reset_source;
35983598
break;
35993599
}
36003600
casePGC_ENUM:
@@ -3606,11 +3606,12 @@ ResetAllOptions(void)
36063606
PGC_S_SESSION))
36073607
elog(ERROR,"failed to reset %s",conf->gen.name);
36083608
*conf->variable=conf->reset_val;
3609-
conf->gen.source=conf->gen.reset_source;
36103609
break;
36113610
}
36123611
}
36133612

3613+
gconf->source=gconf->reset_source;
3614+
36143615
if (gconf->flags&GUC_REPORT)
36153616
ReportGUCOption(gconf);
36163617
}
@@ -5107,10 +5108,39 @@ set_config_option(const char *name, const char *value,
51075108
}
51085109

51095110

5111+
/*
5112+
* Set the fields for source file and line number the setting came from.
5113+
*/
5114+
staticvoid
5115+
set_config_sourcefile(constchar*name,char*sourcefile,intsourceline)
5116+
{
5117+
structconfig_generic*record;
5118+
intelevel;
5119+
5120+
/*
5121+
* To avoid cluttering the log, only the postmaster bleats loudly
5122+
* about problems with the config file.
5123+
*/
5124+
elevel=IsUnderPostmaster ?DEBUG3 :LOG;
5125+
5126+
record=find_option(name, true,elevel);
5127+
/* should not happen */
5128+
if (record==NULL)
5129+
elog(ERROR,"unrecognized configuration parameter \"%s\"",name);
5130+
5131+
if (record->sourcefile)
5132+
free(record->sourcefile);
5133+
record->sourcefile=guc_strdup(elevel,sourcefile);
5134+
record->sourceline=sourceline;
5135+
}
5136+
51105137
/*
51115138
* Set a config option to the given value. See also set_config_option,
51125139
* this is just the wrapper to be called from outside GUC.NB: this
51135140
* is used only for non-transactional operations.
5141+
*
5142+
* Note: there is no support here for setting source file/line, as it
5143+
* is currently not needed.
51145144
*/
51155145
void
51165146
SetConfigOption(constchar*name,constchar*value,
@@ -6144,6 +6174,19 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
61446174
}
61456175
break;
61466176
}
6177+
6178+
/* If the setting came from a config file, set the source location */
6179+
if (conf->source==PGC_S_FILE)
6180+
{
6181+
values[12]=conf->sourcefile;
6182+
snprintf(buffer,sizeof(buffer),"%d",conf->sourceline);
6183+
values[13]=pstrdup(buffer);
6184+
}
6185+
else
6186+
{
6187+
values[12]=NULL;
6188+
values[13]=NULL;
6189+
}
61476190
}
61486191

61496192
/*
@@ -6179,7 +6222,7 @@ show_config_by_name(PG_FUNCTION_ARGS)
61796222
* show_all_settings - equiv to SHOW ALL command but implemented as
61806223
* a Table Function.
61816224
*/
6182-
#defineNUM_PG_SETTINGS_ATTS12
6225+
#defineNUM_PG_SETTINGS_ATTS14
61836226

61846227
Datum
61856228
show_all_settings(PG_FUNCTION_ARGS)
@@ -6231,6 +6274,10 @@ show_all_settings(PG_FUNCTION_ARGS)
62316274
TEXTOID,-1,0);
62326275
TupleDescInitEntry(tupdesc, (AttrNumber)12,"enumvals",
62336276
TEXTOID,-1,0);
6277+
TupleDescInitEntry(tupdesc, (AttrNumber)13,"sourcefile",
6278+
TEXTOID,-1,0);
6279+
TupleDescInitEntry(tupdesc, (AttrNumber)14,"sourceline",
6280+
INT4OID,-1,0);
62346281

62356282
/*
62366283
* Generate attribute metadata needed later to produce tuples from raw

‎src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.484 2008/09/08 00:47:41 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.485 2008/09/10 18:09:20 alvherre Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200809071
56+
#defineCATALOG_VERSION_NO200809101
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.513 2008/09/06 00:01:24 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.514 2008/09/10 18:09:20 alvherre Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -3159,7 +3159,7 @@ DATA(insert OID = 2077 ( current_settingPGNSP PGUID 12 1 0 0 f f t f s 1 25 "2
31593159
DESCR("SHOW X as a function");
31603160
DATA(insertOID=2078 (set_configPGNSPPGUID12100ffffv325"25 25 16"_null__null__null_set_config_by_name_null__null__null_ ));
31613161
DESCR("SET X as a function");
3162-
DATA(insertOID=2084 (pg_show_all_settingsPGNSPPGUID12110000fftts02249"""{25,25,25,25,25,25,25,25,25,25,25,25}""{o,o,o,o,o,o,o,o,o,o,o,o}""{name,setting,unit,category,short_desc,extra_desc,context,vartype,source,min_val,max_val,enumvals}"show_all_settings_null__null__null_ ));
3162+
DATA(insertOID=2084 (pg_show_all_settingsPGNSPPGUID12110000fftts02249"""{25,25,25,25,25,25,25,25,25,25,25,25,25,23}""{o,o,o,o,o,o,o,o,o,o,o,o,o,o}""{name,setting,unit,category,short_desc,extra_desc,context,vartype,source,min_val,max_val,enumvals,sourcefile,sourceline}"show_all_settings_null__null__null_ ));
31633163
DESCR("SHOW ALL as a function");
31643164
DATA(insertOID=1371 (pg_lock_statusPGNSPPGUID12110000ffttv02249"""{25,26,26,23,21,25,28,26,26,21,25,23,25,16}""{o,o,o,o,o,o,o,o,o,o,o,o,o,o}""{locktype,database,relation,page,tuple,virtualxid,transactionid,classid,objid,objsubid,virtualtransaction,pid,mode,granted}"pg_lock_status_null__null__null_ ));
31653165
DESCR("view system lock information");

‎src/include/utils/guc_tables.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.41 2008/03/17 17:45:09 mha Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.42 2008/09/10 18:09:20 alvherre Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -126,6 +126,8 @@ struct config_generic
126126
GucSourcereset_source;/* source of the reset_value */
127127
GucSourcesource;/* source of the current actual value */
128128
GucStack*stack;/* stacked prior values */
129+
char*sourcefile;/* file this settings is from (NULL if not file) */
130+
intsourceline;/* line in source file */
129131
};
130132

131133
/* bit values in flags field */

‎src/test/regress/expected/rules.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem
12871287
pg_prepared_xacts | SELECT p.transaction, p.gid, p.prepared, u.rolname AS owner, d.datname AS database FROM ((pg_prepared_xact() p(transaction, gid, prepared, ownerid, dbid) LEFT JOIN pg_authid u ON ((p.ownerid = u.oid))) LEFT JOIN pg_database d ON ((p.dbid = d.oid)));
12881288
pg_roles | SELECT pg_authid.rolname, pg_authid.rolsuper, pg_authid.rolinherit, pg_authid.rolcreaterole, pg_authid.rolcreatedb, pg_authid.rolcatupdate, pg_authid.rolcanlogin, pg_authid.rolconnlimit, '********'::text AS rolpassword, pg_authid.rolvaliduntil, pg_authid.rolconfig, pg_authid.oid FROM pg_authid;
12891289
pg_rules | SELECT n.nspname AS schemaname, c.relname AS tablename, r.rulename, pg_get_ruledef(r.oid) AS definition FROM ((pg_rewrite r JOIN pg_class c ON ((c.oid = r.ev_class))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (r.rulename <> '_RETURN'::name);
1290-
pg_settings | SELECT a.name, a.setting, a.unit, a.category, a.short_desc, a.extra_desc, a.context, a.vartype, a.source, a.min_val, a.max_val, a.enumvalsFROM pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals);
1290+
pg_settings | SELECT a.name, a.setting, a.unit, a.category, a.short_desc, a.extra_desc, a.context, a.vartype, a.source, a.min_val, a.max_val, a.enumvals, a.sourcefile, a.sourcelineFROM pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals, sourcefile, sourceline);
12911291
pg_shadow | SELECT pg_authid.rolname AS usename, pg_authid.oid AS usesysid, pg_authid.rolcreatedb AS usecreatedb, pg_authid.rolsuper AS usesuper, pg_authid.rolcatupdate AS usecatupd, pg_authid.rolpassword AS passwd, (pg_authid.rolvaliduntil)::abstime AS valuntil, pg_authid.rolconfig AS useconfig FROM pg_authid WHERE pg_authid.rolcanlogin;
12921292
pg_stat_activity | SELECT s.datid, d.datname, s.procpid, s.usesysid, u.rolname AS usename, s.current_query, s.waiting, s.xact_start, s.query_start, s.backend_start, s.client_addr, s.client_port FROM pg_database d, pg_stat_get_activity(NULL::integer) s(datid, procpid, usesysid, current_query, waiting, xact_start, query_start, backend_start, client_addr, client_port), pg_authid u WHERE ((s.datid = d.oid) AND (s.usesysid = u.oid));
12931293
pg_stat_all_indexes | SELECT c.oid AS relid, i.oid AS indexrelid, n.nspname AS schemaname, c.relname, i.relname AS indexrelname, pg_stat_get_numscans(i.oid) AS idx_scan, pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch FROM (((pg_class c JOIN pg_index x ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char"]));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp