On 07/10/2014 09:52 AM, Tomonari Katsumata wrote:

Several couple weeks ago, I posted a mail to pgsql-doc.

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.

The patch also rounds a zero up to one. A naked zero with no unit is not affected, but e.g if you have "log_rotation_age=0s", it will not disable the feature as you might expect, but set it to 1 minute. Should we do something about that?

If we're going to explain the rounding up in the manual, we also need to explain the normal rule, which is to round down. How about this:

--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -44,6 +44,15 @@
      (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.
+    <para>
+     If a memory or time setting is specified with more precision than the
+ implicit unit of the setting, it is rounded down. However, if rounding + down would yield a zero, it is rounded up to one instead. For example, + the implicit unit of <varname>log_rotation_age</varname is minutes, so if
+     you set it to <literal>150s</literal>, it will be rounded down to two
+     minutes. However, if you set it to <literal>10s</literal>, it will be
+     rounded up to one minute.

- Heikki

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to