Commit b517e653 authored by Peter Eisentraut's avatar Peter Eisentraut

Allow units to be specified with configuration settings.

parent a998a692
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.127 2006/07/25 03:51:21 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.128 2006/07/27 08:30:41 petere Exp $ -->
<!--
Documentation of the system catalogs, directed toward PostgreSQL developers
-->
......@@ -5482,6 +5482,12 @@
<entry></entry>
<entry>current value of the parameter</entry>
</row>
<row>
<entry><structfield>unit</structfield></entry>
<entry><type>text</type></entry>
<entry></entry>
<entry>implicit unit of the parameter</entry>
</row>
<row>
<entry><structfield>category</structfield></entry>
<entry><type>text</type></entry>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.70 2006/07/26 11:35:55 petere Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.71 2006/07/27 08:30:41 petere Exp $ -->
<chapter Id="runtime-config">
<title>Server Configuration</title>
......@@ -28,6 +28,20 @@
(all case-insensitive) or any unambiguous prefix of these.
</para>
<para>
Some settings specify a memory or time value. Each of these has
an implicit unit, which is either kilobytes, blocks (typically 8
kilobytes), milliseconds, seconds, or minutes. For convenience, a
(possibly different) unit can also be specified explicitly. Valid
memory units are <literal>kB</literal> (kilobytes),
<literal>MB</literal> (megabytes), and <literal>GB</literal>
(gigabytes); valid time units are <literal>ms</literal>
(milliseconds), <literal>s</literal> (seconds),
<literal>min</literal> (minutes), <literal>h</literal> (hours),
and <literal>d</literal> (days). Note that the multiplier for
memory units in 1024, not 1000.
</para>
<para>
One way to set these parameters is to edit the file
<filename>postgresql.conf</><indexterm><primary>postgresql.conf</></>,
......@@ -39,6 +53,7 @@
log_connections = yes
log_destination = 'syslog'
search_path = '"$user", public'
shared_buffers = 128MB
</programlisting>
One parameter is specified per line. The equal sign between name and
value is optional. Whitespace is insignificant and blank lines are
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 1996-2006, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.28 2006/07/25 03:51:21 tgl Exp $
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.29 2006/07/27 08:30:41 petere Exp $
*/
CREATE VIEW pg_roles AS
......@@ -172,7 +172,7 @@ CREATE VIEW pg_prepared_statements AS
CREATE VIEW pg_settings AS
SELECT *
FROM pg_show_all_settings() AS A
(name text, setting text, category text, short_desc text, extra_desc text,
(name text, setting text, unit text, category text, short_desc text, extra_desc text,
context text, vartype text, source text, min_val text, max_val text);
CREATE RULE pg_settings_u AS
......
......@@ -4,7 +4,7 @@
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.37 2006/03/07 01:03:12 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.38 2006/07/27 08:30:41 petere Exp $
*/
%{
......@@ -68,7 +68,9 @@ SIGN ("-"|"+")
DIGIT [0-9]
HEXDIGIT [0-9a-fA-F]
INTEGER {SIGN}?({DIGIT}+|0x{HEXDIGIT}+)
UNIT_LETTER [a-zA-Z]
INTEGER {SIGN}?({DIGIT}+|0x{HEXDIGIT}+){UNIT_LETTER}*
EXPONENT [Ee]{SIGN}?{DIGIT}+
REAL {SIGN}?{DIGIT}*"."{DIGIT}*{EXPONENT}?
......
This diff is collapsed.
......@@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.118 2006/06/18 15:38:37 petere Exp $
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.119 2006/07/27 08:30:41 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1105,16 +1105,16 @@ test_config_settings(void)
*
*/
#define MIN_BUFS_FOR_CONNS(nconns) ((nconns) * 10)
#define MIN_BUFS_FOR_CONNS(nconns) ((nconns) * 10 * (BLCKSZ/1024))
#define FSM_FOR_BUFS(nbuffers) ((nbuffers) > 1000 ? 50 * (nbuffers) : 20000)
static const int trial_conns[] = {
100, 50, 40, 30, 20, 10
};
static const int trial_bufs[] = {
4000, 3500, 3000, 2500, 2000, 1500,
1000, 900, 800, 700, 600, 500,
400, 300, 200, 100, 50
32000, 28000, 24000, 20000, 16000, 12000,
8000, 7200, 6400, 5600, 4800, 4000,
3200, 2400, 1600, 800, 400
};
char cmd[MAXPGPATH];
......@@ -1140,7 +1140,7 @@ test_config_settings(void)
snprintf(cmd, sizeof(cmd),
"%s\"%s\" --boot -x0 %s "
"-c max_connections=%d "
"-c shared_buffers=%d "
"-c shared_buffers=%dkB "
"-c max_fsm_pages=%d "
"template1 < \"%s\" > \"%s\" 2>&1%s",
SYSTEMQUOTE, backend_exec, boot_options,
......@@ -1175,7 +1175,7 @@ test_config_settings(void)
snprintf(cmd, sizeof(cmd),
"%s\"%s\" --boot -x0 %s "
"-c max_connections=%d "
"-c shared_buffers=%d "
"-c shared_buffers=%dkB "
"-c max_fsm_pages=%d "
"template1 < \"%s\" > \"%s\" 2>&1%s",
SYSTEMQUOTE, backend_exec, boot_options,
......@@ -1188,7 +1188,7 @@ test_config_settings(void)
n_buffers = test_buffs;
n_fsm_pages = FSM_FOR_BUFS(n_buffers);
printf("%d/%d\n", n_buffers, n_fsm_pages);
printf("%dkB/%d\n", n_buffers, n_fsm_pages);
}
/*
......@@ -1211,7 +1211,7 @@ setup_config(void)
snprintf(repltok, sizeof(repltok), "max_connections = %d", n_connections);
conflines = replace_token(conflines, "#max_connections = 100", repltok);
snprintf(repltok, sizeof(repltok), "shared_buffers = %d", n_buffers);
snprintf(repltok, sizeof(repltok), "shared_buffers = %dkB", n_buffers);
conflines = replace_token(conflines, "#shared_buffers = 1000", repltok);
snprintf(repltok, sizeof(repltok), "max_fsm_pages = %d", n_fsm_pages);
......
......@@ -7,7 +7,7 @@
*
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.23 2006/07/13 16:49:20 momjian Exp $
* $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.24 2006/07/27 08:30:41 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -130,6 +130,15 @@ struct config_generic
#define GUC_SUPERUSER_ONLY 0x0100 /* show only to superusers */
#define GUC_IS_NAME 0x0200 /* limit string to NAMEDATALEN-1 */
#define GUC_UNIT_KB 0x0400 /* value is in 1 kB */
#define GUC_UNIT_BLOCKS 0x0800 /* value is in blocks */
#define GUC_UNIT_MEMORY (GUC_UNIT_KB|GUC_UNIT_BLOCKS)
#define GUC_UNIT_MS 0x1000 /* value is in milliseconds */
#define GUC_UNIT_S 0x2000 /* value is in seconds */
#define GUC_UNIT_MIN 0x4000 /* value is in minutes */
#define GUC_UNIT_TIME (GUC_UNIT_MS|GUC_UNIT_S|GUC_UNIT_MIN)
/* bit values in status field */
#define GUC_HAVE_TENTATIVE 0x0001 /* tentative value is defined */
#define GUC_HAVE_LOCAL 0x0002 /* a SET LOCAL has been executed */
......
......@@ -1285,7 +1285,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem
pg_prepared_xacts | SELECT p."transaction", p.gid, p."prepared", u.rolname AS "owner", d.datname AS "database" FROM ((pg_prepared_xact() p("transaction" xid, gid text, "prepared" timestamp with time zone, ownerid oid, dbid oid) 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.category, a.short_desc, a.extra_desc, a.context, a.vartype, a.source, a.min_val, a.max_val FROM pg_show_all_settings() a(name text, setting text, category text, short_desc text, extra_desc text, context text, vartype text, source text, min_val text, max_val text);
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 FROM pg_show_all_settings() a(name text, setting text, unit text, category text, short_desc text, extra_desc text, context text, vartype text, source text, min_val text, max_val text);
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 d.oid AS datid, d.datname, pg_stat_get_backend_pid(s.backendid) AS procpid, pg_stat_get_backend_userid(s.backendid) AS usesysid, u.rolname AS usename, pg_stat_get_backend_activity(s.backendid) AS current_query, pg_stat_get_backend_activity_start(s.backendid) AS query_start, pg_stat_get_backend_start(s.backendid) AS backend_start, pg_stat_get_backend_client_addr(s.backendid) AS client_addr, pg_stat_get_backend_client_port(s.backendid) AS client_port FROM pg_database d, (SELECT pg_stat_get_backend_idset() AS backendid) s, pg_authid u WHERE ((pg_stat_get_backend_dbid(s.backendid) = d.oid) AND (pg_stat_get_backend_userid(s.backendid) = 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"]));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment