Re: proposal: rounding up time value less than its unit. - Mailing list pgsql-hackers

From Tomonari Katsumata
Subject Re: proposal: rounding up time value less than its unit.
Date
Msg-id CAC55fYfmj0qBpGAZEXefUym1uCKK8agNCVWn7v8mAzQz_trjtQ@mail.gmail.com
Whole thread Raw
In response to Re: proposal: rounding up time value less than its unit.  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Responses Re: proposal: rounding up time value less than its unit.
List pgsql-hackers
Thank you for the comments.

It was a bug in my patch as another developer says.
I've not considered about the value 'zero', sorry.

I attached new patch.
This patch rounds up the value when only it's less than required unit.
Like below.
(unit: min)
0->0
0s->0
10s->1
70s->1

Although my original complaint is fixed, I'm worried about this change will make users confusing.
Is it better to raise a message(ex. INFO) when a value less than required unit is set?



2014-08-21 21:00 GMT+09:00 Heikki Linnakangas <hlinnakangas@vmware.com>:
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




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

Attachment

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Is this a bug?
Next
From: Pavel Stehule
Date:
Subject: Re: Re: proposal: ignore null fields in not relation type composite type based constructors