From 41f302b52a2f0388a9e9b084d42f18d1904db7ff Mon Sep 17 00:00:00 2001
From: Itagaki Takahiro <itagaki.takahiro@gmail.com>
Date: Tue, 15 Jun 2010 07:52:11 +0000
Subject: [PATCH] Add new GUC categories corresponding to sections in docs, and
 move description for vacuum_defer_cleanup_age to the correct category.
 Sections in postgresql.conf are also sorted in the same order with docs.

Per gripe by Fujii Masao, suggestion by Heikki Linnakangas, and patch by me.
---
 doc/src/sgml/config.sgml                      | 48 +++++++++----------
 src/backend/utils/misc/guc.c                  | 48 +++++++++++--------
 src/backend/utils/misc/postgresql.conf.sample | 14 +++---
 src/include/utils/guc_tables.h                |  7 ++-
 4 files changed, 66 insertions(+), 51 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 3c499b134cf..75127f972de 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.280 2010/05/31 15:50:48 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.281 2010/06/15 07:52:10 itagaki Exp $ -->
 
 <chapter Id="runtime-config">
   <title>Server Configuration</title>
@@ -1966,6 +1966,29 @@ SET ENABLE_SEQSCAN TO OFF;
       </listitem>
      </varlistentry>
 
+     <varlistentry id="guc-vacuum-defer-cleanup-age" xreflabel="vacuum_defer_cleanup_age">
+      <term><varname>vacuum_defer_cleanup_age</varname> (<type>integer</type>)</term>
+      <indexterm>
+       <primary><varname>vacuum_defer_cleanup_age</> configuration parameter</primary>
+      </indexterm>
+      <listitem>
+       <para>
+        Specifies the number of transactions by which <command>VACUUM</> and
+        <acronym>HOT</> updates will defer cleanup of dead row versions. The
+        default is 0 transactions, meaning that dead row versions will be
+        removed as soon as possible. You may wish to set this to a non-zero
+        value when planning or maintaining a <xref linkend="hot-standby">
+        configuration. The recommended value is <literal>0</> unless you have
+        clear reason to increase it. The purpose of the parameter is to
+        allow the user to specify an approximate time delay before cleanup
+        occurs. However, it should be noted that there is no direct link with
+        any specific time delay and so the results will be application and
+        installation specific, as well as variable over time, depending upon
+        the transaction rate (of writes only).
+       </para>
+      </listitem>
+     </varlistentry>
+
      </variablelist>
     </sect2>
    </sect1>
@@ -4407,29 +4430,6 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
       </listitem>
      </varlistentry>
 
-     <varlistentry id="guc-vacuum-defer-cleanup-age" xreflabel="vacuum_defer_cleanup_age">
-      <term><varname>vacuum_defer_cleanup_age</varname> (<type>integer</type>)</term>
-      <indexterm>
-       <primary><varname>vacuum_defer_cleanup_age</> configuration parameter</primary>
-      </indexterm>
-      <listitem>
-       <para>
-        Specifies the number of transactions by which <command>VACUUM</> and
-        <acronym>HOT</> updates will defer cleanup of dead row versions. The
-        default is 0 transactions, meaning that dead row versions will be
-        removed as soon as possible. You may wish to set this to a non-zero
-        value when planning or maintaining a <xref linkend="hot-standby">
-        configuration. The recommended value is <literal>0</> unless you have
-        clear reason to increase it. The purpose of the parameter is to
-        allow the user to specify an approximate time delay before cleanup
-        occurs. However, it should be noted that there is no direct link with
-        any specific time delay and so the results will be application and
-        installation specific, as well as variable over time, depending upon
-        the transaction rate (of writes only).
-       </para>
-      </listitem>
-     </varlistentry>
-
      <varlistentry id="guc-bytea-output" xreflabel="bytea_output">
       <term><varname>bytea_output</varname> (<type>enum</type>)</term>
       <indexterm>
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 430c37526d9..2461966f0d2 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.554 2010/05/02 02:10:33 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.555 2010/06/15 07:52:10 itagaki Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -489,14 +489,24 @@ const char *const config_group_names[] =
 	gettext_noop("Resource Usage / Memory"),
 	/* RESOURCES_KERNEL */
 	gettext_noop("Resource Usage / Kernel Resources"),
+	/* RESOURCES_VACUUM_DELAY */
+	gettext_noop("Resource Usage / Cost-Based Vacuum Delay"),
+	/* RESOURCES_BGWRITER */
+	gettext_noop("Resource Usage / Background Writer"),
+	/* RESOURCES_ASYNCHRONOUS */
+	gettext_noop("Resource Usage / Asynchronous Behavior"),
 	/* WAL */
 	gettext_noop("Write-Ahead Log"),
 	/* WAL_SETTINGS */
 	gettext_noop("Write-Ahead Log / Settings"),
 	/* WAL_CHECKPOINTS */
 	gettext_noop("Write-Ahead Log / Checkpoints"),
+	/* WAL_ARCHIVING */
+	gettext_noop("Write-Ahead Log / Archiving"),
 	/* WAL_REPLICATION */
-	gettext_noop("Write-Ahead Log / Replication"),
+	gettext_noop("Write-Ahead Log / Streaming Replication"),
+	/* WAL_STANDBY_SERVERS */
+	gettext_noop("Write-Ahead Log / Standby Servers"),
 	/* QUERY_TUNING */
 	gettext_noop("Query Tuning"),
 	/* QUERY_TUNING_METHOD */
@@ -1213,7 +1223,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"archive_mode", PGC_POSTMASTER, WAL_SETTINGS,
+		{"archive_mode", PGC_POSTMASTER, WAL_ARCHIVING,
 			gettext_noop("Allows archiving of WAL files using archive_command."),
 			NULL
 		},
@@ -1222,7 +1232,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"hot_standby", PGC_POSTMASTER, WAL_SETTINGS,
+		{"hot_standby", PGC_POSTMASTER, WAL_STANDBY_SERVERS,
 			gettext_noop("Allows connections and queries during recovery."),
 			NULL
 		},
@@ -1271,7 +1281,7 @@ static struct config_bool ConfigureNamesBool[] =
 static struct config_int ConfigureNamesInt[] =
 {
 	{
-		{"archive_timeout", PGC_SIGHUP, WAL_SETTINGS,
+		{"archive_timeout", PGC_SIGHUP, WAL_ARCHIVING,
 			gettext_noop("Forces a switch to the next xlog file if a "
 						 "new file has not been started within N seconds."),
 			NULL,
@@ -1384,7 +1394,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"max_standby_delay", PGC_SIGHUP, WAL_SETTINGS,
+		{"max_standby_delay", PGC_SIGHUP, WAL_STANDBY_SERVERS,
 			gettext_noop("Sets the maximum delay to avoid conflict processing on hot standby servers."),
 			NULL,
 			GUC_UNIT_MS
@@ -1477,7 +1487,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_cost_page_hit", PGC_USERSET, RESOURCES,
+		{"vacuum_cost_page_hit", PGC_USERSET, RESOURCES_VACUUM_DELAY,
 			gettext_noop("Vacuum cost for a page found in the buffer cache."),
 			NULL
 		},
@@ -1486,7 +1496,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_cost_page_miss", PGC_USERSET, RESOURCES,
+		{"vacuum_cost_page_miss", PGC_USERSET, RESOURCES_VACUUM_DELAY,
 			gettext_noop("Vacuum cost for a page not found in the buffer cache."),
 			NULL
 		},
@@ -1495,7 +1505,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_cost_page_dirty", PGC_USERSET, RESOURCES,
+		{"vacuum_cost_page_dirty", PGC_USERSET, RESOURCES_VACUUM_DELAY,
 			gettext_noop("Vacuum cost for a page dirtied by vacuum."),
 			NULL
 		},
@@ -1504,7 +1514,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_cost_limit", PGC_USERSET, RESOURCES,
+		{"vacuum_cost_limit", PGC_USERSET, RESOURCES_VACUUM_DELAY,
 			gettext_noop("Vacuum cost amount available before napping."),
 			NULL
 		},
@@ -1513,7 +1523,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_cost_delay", PGC_USERSET, RESOURCES,
+		{"vacuum_cost_delay", PGC_USERSET, RESOURCES_VACUUM_DELAY,
 			gettext_noop("Vacuum cost delay in milliseconds."),
 			NULL,
 			GUC_UNIT_MS
@@ -1554,7 +1564,7 @@ static struct config_int ConfigureNamesInt[] =
 	 * See also CheckRequiredParameterValues() if this parameter changes
 	 */
 	{
-		{"max_prepared_transactions", PGC_POSTMASTER, RESOURCES,
+		{"max_prepared_transactions", PGC_POSTMASTER, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of simultaneously prepared transactions."),
 			NULL
 		},
@@ -1612,7 +1622,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_defer_cleanup_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"vacuum_defer_cleanup_age", PGC_USERSET, WAL_STANDBY_SERVERS,
 			gettext_noop("Age by which VACUUM and HOT cleanup should be deferred, if any."),
 			NULL
 		},
@@ -1790,7 +1800,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"bgwriter_delay", PGC_SIGHUP, RESOURCES,
+		{"bgwriter_delay", PGC_SIGHUP, RESOURCES_BGWRITER,
 			gettext_noop("Background writer sleep time between rounds."),
 			NULL,
 			GUC_UNIT_MS
@@ -1800,7 +1810,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"bgwriter_lru_maxpages", PGC_SIGHUP, RESOURCES,
+		{"bgwriter_lru_maxpages", PGC_SIGHUP, RESOURCES_BGWRITER,
 			gettext_noop("Background writer maximum number of LRU pages to flush per round."),
 			NULL
 		},
@@ -1815,7 +1825,7 @@ static struct config_int ConfigureNamesInt[] =
 #else
 			PGC_INTERNAL,
 #endif
-			RESOURCES,
+			RESOURCES_ASYNCHRONOUS,
 			gettext_noop("Number of simultaneous requests that can be handled efficiently by the disk subsystem."),
 			gettext_noop("For RAID arrays, this should be approximately the number of drive spindles in the array.")
 		},
@@ -2143,7 +2153,7 @@ static struct config_real ConfigureNamesReal[] =
 	},
 
 	{
-		{"bgwriter_lru_multiplier", PGC_SIGHUP, RESOURCES,
+		{"bgwriter_lru_multiplier", PGC_SIGHUP, RESOURCES_BGWRITER,
 			gettext_noop("Multiple of the average buffer usage to free per round."),
 			NULL
 		},
@@ -2197,7 +2207,7 @@ static struct config_real ConfigureNamesReal[] =
 static struct config_string ConfigureNamesString[] =
 {
 	{
-		{"archive_command", PGC_SIGHUP, WAL_SETTINGS,
+		{"archive_command", PGC_SIGHUP, WAL_ARCHIVING,
 			gettext_noop("Sets the shell command that will be called to archive a WAL file."),
 			NULL
 		},
@@ -2630,7 +2640,7 @@ static struct config_string ConfigureNamesString[] =
 #endif   /* USE_SSL */
 
 	{
-		{"application_name", PGC_USERSET, LOGGING,
+		{"application_name", PGC_USERSET, LOGGING_WHAT,
 			gettext_noop("Sets the application name to be reported in statistics and logs."),
 			NULL,
 			GUC_IS_NAME | GUC_REPORT | GUC_NOT_IN_SAMPLE
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 94a4e69c6cb..5ea568a3551 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -183,19 +183,19 @@
 #archive_timeout = 0		# force a logfile segment switch after this
 				# number of seconds; 0 disables
 
-# - Hot Standby -
+# - Streaming Replication -
+
+#max_wal_senders = 0		# max number of walsender processes
+#wal_sender_delay = 200ms	# 1-10000 milliseconds
+#wal_keep_segments = 0		# in logfile segments, 16MB each; 0 disables
+
+# - Standby Servers -
 
 #hot_standby = off		# allows queries during recovery
 #max_standby_delay = 30s	# max acceptable lag to allow queries to
 				# complete without conflict; -1 means forever
 #vacuum_defer_cleanup_age = 0	# num transactions by which cleanup is deferred
 
-# - Replication -
-
-#max_wal_senders = 0		# max number of walsender processes
-#wal_sender_delay = 200ms	# 1-10000 milliseconds
-#wal_keep_segments = 0		# in logfile segments, 16MB each; 0 disables
-
 
 #------------------------------------------------------------------------------
 # QUERY TUNING
diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h
index bb96b0e546e..54aba388ecd 100644
--- a/src/include/utils/guc_tables.h
+++ b/src/include/utils/guc_tables.h
@@ -7,7 +7,7 @@
  *
  * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
  *
- *	  $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.48 2010/01/15 09:19:09 heikki Exp $
+ *	  $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.49 2010/06/15 07:52:11 itagaki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -50,10 +50,15 @@ enum config_group
 	RESOURCES,
 	RESOURCES_MEM,
 	RESOURCES_KERNEL,
+	RESOURCES_VACUUM_DELAY,
+	RESOURCES_BGWRITER,
+	RESOURCES_ASYNCHRONOUS,
 	WAL,
 	WAL_SETTINGS,
 	WAL_CHECKPOINTS,
+	WAL_ARCHIVING,
 	WAL_REPLICATION,
+	WAL_STANDBY_SERVERS,
 	QUERY_TUNING,
 	QUERY_TUNING_METHOD,
 	QUERY_TUNING_COST,
-- 
GitLab