Attached is an updated and separate version of my patch exposing the
internal GUC boot_val as default_val, which failed to attach itself to the
already committed changes to the pg_settings view.
Brief reminder of what it does:
postgres=# select name,setting,default_val from pg_settings where
name='shared_buffers';
name | setting | default_val
----------------+---------+-------------
shared_buffers | 4096 | 1024
General justification for this change with a longer example is at
http://archives.postgresql.org/pgsql-hackers/2008-09/msg00233.php
Based on feedback the first time around, I updated the documentation for
this column to read "Default value assumed at server startup if the
parameter is not otherwise set".
Would only take a quick search/replace of the patch to change
"default_val" to something else if there are still any objections there.
"boot_val" is another candidate name, I feel that would make the purpose
of the column less obvious to users of pg_settings even if it is more
correct. I'm really more concerned about the feature than exactly what
it's named though. I didn't bother to expose the reset_val since I can't
think of any obvious use cases for wanting to know it.
--
* Greg Smith [EMAIL PROTECTED] http://www.gregsmith.com Baltimore, MD
Index: doc/src/sgml/catalogs.sgml
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/doc/src/sgml/catalogs.sgml,v
retrieving revision 2.174
diff -c -r2.174 catalogs.sgml
*** doc/src/sgml/catalogs.sgml 15 Sep 2008 18:43:41 -0000 2.174
--- doc/src/sgml/catalogs.sgml 16 Sep 2008 03:18:42 -0000
***************
*** 6422,6427 ****
--- 6422,6433 ----
values)</entry>
</row>
<row>
+ <entry><structfield>default_val</structfield></entry>
+ <entry><type>text</type></entry>
+ <entry>Default value assumed at server startup if the parameter is not
+ otherwise set</entry>
+ </row>
+ <row>
<entry><structfield>sourcefile</structfield></entry>
<entry><type>text</type></entry>
<entry>Input file the current value was set from (NULL for values set in
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.472
diff -c -r1.472 guc.c
*** src/backend/utils/misc/guc.c 10 Sep 2008 19:16:22 -0000 1.472
--- src/backend/utils/misc/guc.c 16 Sep 2008 03:44:09 -0000
***************
*** 6087,6092 ****
--- 6087,6094 ----
{
case PGC_BOOL:
{
+ struct config_bool *lconf = (struct config_bool
*) conf;
+
/* min_val */
values[9] = NULL;
***************
*** 6095,6100 ****
--- 6097,6106 ----
/* enumvals */
values[11] = NULL;
+
+ /* default_val */
+ snprintf(buffer, sizeof(buffer), "%s",
lconf->boot_val ? "on" : "off");
+ values[12] = pstrdup(buffer);
}
break;
***************
*** 6112,6117 ****
--- 6118,6127 ----
/* enumvals */
values[11] = NULL;
+
+ /* default_val */
+ snprintf(buffer, sizeof(buffer), "%d",
lconf->boot_val);
+ values[12] = pstrdup(buffer);
}
break;
***************
*** 6129,6139 ****
--- 6139,6155 ----
/* enumvals */
values[11] = NULL;
+
+ /* default_val */
+ snprintf(buffer, sizeof(buffer), "%g",
lconf->boot_val);
+ values[12] = pstrdup(buffer);
}
break;
case PGC_STRING:
{
+ struct config_string *lconf = (struct
config_string *) conf;
+
/* min_val */
values[9] = NULL;
***************
*** 6142,6152 ****
--- 6158,6180 ----
/* enumvals */
values[11] = NULL;
+
+ /* default_val */
+ if (lconf->boot_val == NULL)
+ {
+ values[12] = NULL;
+ } else
+ {
+ snprintf(buffer, sizeof(buffer), "%s",
lconf->boot_val);
+ values[12] = pstrdup(buffer);
+ }
}
break;
case PGC_ENUM:
{
+ struct config_enum *lconf = (struct config_enum
*) conf;
+
/* min_val */
values[9] = NULL;
***************
*** 6155,6160 ****
--- 6183,6193 ----
/* enumvals */
values[11] = config_enum_get_options((struct
config_enum *) conf, "", "");
+
+ /* default_val */
+ snprintf(buffer, sizeof(buffer), "%s",
+ config_enum_lookup_by_value(lconf,
lconf->boot_val));
+ values[12] = pstrdup(buffer);
}
break;
***************
*** 6172,6177 ****
--- 6205,6213 ----
/* enumvals */
values[11] = NULL;
+
+ /* default_val */
+ values[12] = NULL;
}
break;
}
***************
*** 6179,6192 ****
/* 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;
}
}
--- 6215,6228 ----
/* If the setting came from a config file, set the source location */
if (conf->source == PGC_S_FILE)
{
! values[13] = conf->sourcefile;
snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);
! values[14] = pstrdup(buffer);
}
else
{
values[13] = NULL;
+ values[14] = NULL;
}
}
***************
*** 6223,6229 ****
* show_all_settings - equiv to SHOW ALL command but implemented as
* a Table Function.
*/
! #define NUM_PG_SETTINGS_ATTS 14
Datum
show_all_settings(PG_FUNCTION_ARGS)
--- 6259,6265 ----
* show_all_settings - equiv to SHOW ALL command but implemented as
* a Table Function.
*/
! #define NUM_PG_SETTINGS_ATTS 15
Datum
show_all_settings(PG_FUNCTION_ARGS)
***************
*** 6275,6283 ****
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);
/*
--- 6311,6321 ----
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals",
TEXTOID, -1, 0);
! TupleDescInitEntry(tupdesc, (AttrNumber) 13, "default_val",
! TEXTOID, -1, 0);
! TupleDescInitEntry(tupdesc, (AttrNumber) 14, "sourcefile",
TEXTOID, -1, 0);
! TupleDescInitEntry(tupdesc, (AttrNumber) 15, "sourceline",
INT4OID, -1, 0);
/*
Index: src/include/catalog/pg_proc.h
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/src/include/catalog/pg_proc.h,v
retrieving revision 1.514
diff -c -r1.514 pg_proc.h
*** src/include/catalog/pg_proc.h 10 Sep 2008 18:09:20 -0000 1.514
--- src/include/catalog/pg_proc.h 16 Sep 2008 03:31:53 -0000
***************
*** 3159,3165 ****
DESCR("SHOW X as a function");
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_ ));
DESCR("SET X as a function");
! 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_ ));
DESCR("SHOW ALL as a function");
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_ ));
DESCR("view system lock information");
--- 3159,3165 ----
DESCR("SHOW X as a function");
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_ ));
DESCR("SET X as a function");
! 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,23}"
"{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,default_val,sourcefile,sourceline}"
show_all_settings _null_ _null_ _null_ ));
DESCR("SHOW ALL as a function");
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_ ));
DESCR("view system lock information");
Index: src/test/regress/expected/rules.out
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/src/test/regress/expected/rules.out,v
retrieving revision 1.142
diff -c -r1.142 rules.out
*** src/test/regress/expected/rules.out 10 Sep 2008 18:09:20 -0000 1.142
--- src/test/regress/expected/rules.out 16 Sep 2008 03:33:11 -0000
***************
*** 1287,1293 ****
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)));
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;
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);
! 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);
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;
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));
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"]));
--- 1287,1293 ----
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)));
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;
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);
! 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.default_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, default_val, sourcefile,
sourceline);
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;
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));
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"]));
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers