Hi,

Several couple weeks ago, I posted a mail to pgsql-doc.
http://www.postgresql.org/message-id/53992ff8.2060...@po.ntts.co.jp

In this thread, I concluded that it's better to
round up the value which is less than its unit.
Current behavior (rounding down) has undesirable setting risk,
because some GUCs have special meaning for 0.

And then I made a patch for this.
Please check the attached patch.

regards,
-----------
Tomonari Katsumata
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 04ddd73..9aaffb0 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -43,7 +43,9 @@
      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 is 1024, not 1000.
+     for memory units is 1024, not 1000. And also note that if you set
+     less value than which is expected for the time setting, the value
+     would be rounded up.
     </para>
 
     <para>
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 3a31a75..8ba4879 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -5122,9 +5122,11 @@ parse_int(const char *value, int *result, int flags, const char **hintmsg)
 				switch (flags & GUC_UNIT_TIME)
 				{
 					case GUC_UNIT_S:
+						val += (val < MS_PER_S) ? MS_PER_S : 0;
 						val /= MS_PER_S;
 						break;
 					case GUC_UNIT_MIN:
+						val += (val < MS_PER_MIN) ? MS_PER_MIN : 0;
 						val /= MS_PER_MIN;
 						break;
 				}
@@ -5138,6 +5140,7 @@ parse_int(const char *value, int *result, int flags, const char **hintmsg)
 						val *= MS_PER_S;
 						break;
 					case GUC_UNIT_MIN:
+						val += (val < S_PER_MIN) ? S_PER_MIN : 0;
 						val /= S_PER_MIN;
 						break;
 				}
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to