Skip to content

Commit 3bea93b

Browse files
committed
Add columns boot_val and reset_val to the pg_settings view, to expose
the value a parameter has at server start and will have after RESET, respectively. Greg Smith, with some modifications by me.
1 parent 89f373b commit 3bea93b

File tree

5 files changed

+82
-14
lines changed

5 files changed

+82
-14
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 13 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.176 2008/09/23 09:20:33 heikki Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.177 2008/10/06 13:05:36 mha Exp $ -->
22
<!--
33
Documentation of the system catalogs, directed toward PostgreSQL developers
44
-->
@@ -6435,6 +6435,18 @@
64356435
<entry>Allowed values in enum parameters (NULL for non-enum
64366436
values)</entry>
64376437
</row>
6438+
<row>
6439+
<entry><structfield>boot_val</structfield></entry>
6440+
<entry><type>text</type></entry>
6441+
<entry>Parameter value assumed at server startup if the parameter is
6442+
not otherwise set</entry>
6443+
</row>
6444+
<row>
6445+
<entry><structfield>reset_val</structfield></entry>
6446+
<entry><type>text</type></entry>
6447+
<entry>Default run-time session value for the parameter that it will
6448+
revert to if <command>RESET</command></entry>
6449+
</row>
64386450
<row>
64396451
<entry><structfield>sourcefile</structfield></entry>
64406452
<entry><type>text</type></entry>

src/backend/utils/misc/guc.c

Lines changed: 64 additions & 8 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.474 2008/09/30 10:52:13 heikki Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.475 2008/10/06 13:05:36 mha Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -6067,6 +6067,8 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
60676067
{
60686068
case PGC_BOOL:
60696069
{
6070+
struct config_bool *lconf = (struct config_bool *) conf;
6071+
60706072
/* min_val */
60716073
values[9] = NULL;
60726074

@@ -6075,6 +6077,12 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
60756077

60766078
/* enumvals */
60776079
values[11] = NULL;
6080+
6081+
/* boot_val */
6082+
values[12] = pstrdup(lconf->boot_val ? "on" : "off");
6083+
6084+
/* reset_val */
6085+
values[13] = pstrdup(lconf->reset_val ? "on" : "off");
60786086
}
60796087
break;
60806088

@@ -6092,6 +6100,14 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
60926100

60936101
/* enumvals */
60946102
values[11] = NULL;
6103+
6104+
/* boot_val */
6105+
snprintf(buffer, sizeof(buffer), "%d", lconf->boot_val);
6106+
values[12] = pstrdup(buffer);
6107+
6108+
/* reset_val */
6109+
snprintf(buffer, sizeof(buffer), "%d", lconf->reset_val);
6110+
values[13] = pstrdup(buffer);
60956111
}
60966112
break;
60976113

@@ -6109,11 +6125,21 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
61096125

61106126
/* enumvals */
61116127
values[11] = NULL;
6128+
6129+
/* boot_val */
6130+
snprintf(buffer, sizeof(buffer), "%g", lconf->boot_val);
6131+
values[12] = pstrdup(buffer);
6132+
6133+
/* reset_val */
6134+
snprintf(buffer, sizeof(buffer), "%g", lconf->reset_val);
6135+
values[13] = pstrdup(buffer);
61126136
}
61136137
break;
61146138

61156139
case PGC_STRING:
61166140
{
6141+
struct config_string *lconf = (struct config_string *) conf;
6142+
61176143
/* min_val */
61186144
values[9] = NULL;
61196145

@@ -6122,11 +6148,25 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
61226148

61236149
/* enumvals */
61246150
values[11] = NULL;
6151+
6152+
/* boot_val */
6153+
if (lconf->boot_val == NULL)
6154+
values[12] = NULL;
6155+
else
6156+
values[12] = pstrdup(lconf->boot_val);
6157+
6158+
/* reset_val */
6159+
if (lconf->reset_val == NULL)
6160+
values[13] = NULL;
6161+
else
6162+
values[13] = pstrdup(lconf->reset_val);
61256163
}
61266164
break;
61276165

61286166
case PGC_ENUM:
61296167
{
6168+
struct config_enum *lconf = (struct config_enum *) conf;
6169+
61306170
/* min_val */
61316171
values[9] = NULL;
61326172

@@ -6135,6 +6175,12 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
61356175

61366176
/* enumvals */
61376177
values[11] = config_enum_get_options((struct config_enum *) conf, "", "");
6178+
6179+
/* boot_val */
6180+
values[12] = pstrdup(config_enum_lookup_by_value(lconf, lconf->boot_val));
6181+
6182+
/* reset_val */
6183+
values[13] = pstrdup(config_enum_lookup_by_value(lconf, lconf->reset_val));
61386184
}
61396185
break;
61406186

@@ -6152,6 +6198,12 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
61526198

61536199
/* enumvals */
61546200
values[11] = NULL;
6201+
6202+
/* boot_val */
6203+
values[12] = NULL;
6204+
6205+
/* reset_val */
6206+
values[13] = NULL;
61556207
}
61566208
break;
61576209
}
@@ -6163,14 +6215,14 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
61636215
*/
61646216
if (conf->source == PGC_S_FILE && superuser())
61656217
{
6166-
values[12] = conf->sourcefile;
6218+
values[14] = conf->sourcefile;
61676219
snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);
6168-
values[13] = pstrdup(buffer);
6220+
values[15] = pstrdup(buffer);
61696221
}
61706222
else
61716223
{
6172-
values[12] = NULL;
6173-
values[13] = NULL;
6224+
values[14] = NULL;
6225+
values[15] = NULL;
61746226
}
61756227
}
61766228

@@ -6207,7 +6259,7 @@ show_config_by_name(PG_FUNCTION_ARGS)
62076259
* show_all_settings - equiv to SHOW ALL command but implemented as
62086260
* a Table Function.
62096261
*/
6210-
#define NUM_PG_SETTINGS_ATTS 14
6262+
#define NUM_PG_SETTINGS_ATTS 16
62116263

62126264
Datum
62136265
show_all_settings(PG_FUNCTION_ARGS)
@@ -6259,9 +6311,13 @@ show_all_settings(PG_FUNCTION_ARGS)
62596311
TEXTOID, -1, 0);
62606312
TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals",
62616313
TEXTOID, -1, 0);
6262-
TupleDescInitEntry(tupdesc, (AttrNumber) 13, "sourcefile",
6314+
TupleDescInitEntry(tupdesc, (AttrNumber) 13, "boot_val",
6315+
TEXTOID, -1, 0);
6316+
TupleDescInitEntry(tupdesc, (AttrNumber) 14, "reset_val",
6317+
TEXTOID, -1, 0);
6318+
TupleDescInitEntry(tupdesc, (AttrNumber) 15, "sourcefile",
62636319
TEXTOID, -1, 0);
6264-
TupleDescInitEntry(tupdesc, (AttrNumber) 14, "sourceline",
6320+
TupleDescInitEntry(tupdesc, (AttrNumber) 16, "sourceline",
62656321
INT4OID, -1, 0);
62666322

62676323
/*

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.493 2008/10/05 17:33:16 petere Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.494 2008/10/06 13:05:37 mha Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 200810051
56+
#define CATALOG_VERSION_NO 200810061
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.517 2008/10/05 17:33:16 petere Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.518 2008/10/06 13:05:37 mha Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -3145,7 +3145,7 @@ DATA(insert OID = 2077 ( current_setting PGNSP PGUID 12 1 0 0 f f t f s 1 25 "2
31453145
DESCR("SHOW X as a function");
31463146
DATA(insert OID = 2078 ( set_config PGNSP PGUID 12 1 0 0 f f f f v 3 25 "25 25 16" _null_ _null_ _null_ set_config_by_name _null_ _null_ _null_ ));
31473147
DESCR("SET X as a function");
3148-
DATA(insert OID = 2084 ( pg_show_all_settings PGNSP PGUID 12 1 1000 0 f f t t s 0 2249 "" "{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_ ));
3148+
DATA(insert OID = 2084 ( pg_show_all_settings PGNSP PGUID 12 1 1000 0 f f t t s 0 2249 "" "{25,25,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,o,o}" "{name,setting,unit,category,short_desc,extra_desc,context,vartype,source,min_val,max_val,enumvals,boot_val,reset_val,sourcefile,sourceline}" show_all_settings _null_ _null_ _null_ ));
31493149
DESCR("SHOW ALL as a function");
31503150
DATA(insert OID = 1371 ( pg_lock_status PGNSP PGUID 12 1 1000 0 f f t t v 0 2249 "" "{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_ ));
31513151
DESCR("view system lock information");

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.enumvals, a.sourcefile, a.sourceline FROM pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals, sourcefile, sourceline);
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.boot_val, a.reset_val, a.sourcefile, a.sourceline FROM pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, 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)
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