Re: proposal: rounding up time value less than its unit.

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: proposal: rounding up time value less than its unit.
Дата
Msg-id 53F5DF4B.7020602@vmware.com
обсуждение исходный текст
Ответ на proposal: rounding up time value less than its unit.  (Tomonari Katsumata <katsumata.tomonari@po.ntts.co.jp>)
Ответы Re: proposal: rounding up time value less than its unit.
Re: proposal: rounding up time value less than its unit.
Список pgsql-hackers
On 07/10/2014 09:52 AM, Tomonari Katsumata wrote:
> Hi,
>
> Several couple weeks ago, I posted a mail to pgsql-doc.
> http://www.postgresql.org/message-id/53992FF8.2060702@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.

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.     </para>

- Heikki




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: plpgsql.extra_warnings='num_into_expressions'
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: Removing dependency to wsock32.lib when compiling code on WIndows