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

From: Tomonari Katsumata <t(dot)katsumata1122(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Tomonari Katsumata <katsumata(dot)tomonari(at)po(dot)ntts(dot)co(dot)jp>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: rounding up time value less than its unit.
Date: 2014-08-23 04:14:06
Message-ID: CAC55fYfmj0qBpGAZEXefUym1uCKK8agNCVWn7v8mAzQz_trjtQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)vmware(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

Attachment Content-Type Size
time-unit-guc-round-up_v2.patch application/octet-stream 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2014-08-23 05:21:50 Re: Re: proposal: ignore null fields in not relation type composite type based constructors
Previous Message Bruce Momjian 2014-08-23 02:04:50 Re: Is this a bug?