Re: Infinite Interval

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joseph Koshakow <koshy44(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Infinite Interval
Date: 2023-03-18 19:08:33
Message-ID: 551887.1679166513@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Joseph Koshakow <koshy44(at)gmail(dot)com> writes:
> On Thu, Mar 9, 2023 at 12:42 PM Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
> wrote:
>> There are a lot of these diffs. PG code doesn't leave an extra space
>> between variable name and *.

> Those appeared from running pg_indent. I've removed them all.

More specifically, those are from running pg_indent with an obsolete
typedefs list. Good practice is to fetch an up-to-date list from
the buildfarm:

curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl -o .../typedefs.list

and use that. (If your patch adds any typedefs, you can then add them
to that list.) There's been talk of trying harder to keep
src/tools/pgindent/typedefs.list up to date, but not much has happened
yet.

> I've separated this out into another patch attached to this email.
> Should I start a new email thread or is it ok to include it in this
> one?

Having separate threads with interdependent patches is generally a
bad idea :-( ... the cfbot certainly won't cope.

>> I see that this code is very similar to the corresponding code in
>> timestamp and
>> timestamptz, so it's bound to be correct. But I always thought float
>> equality
>> is unreliable. if (r) is equivalent to if (r == 0.0) so it will not
>> work as
>> intended. But may be (float) 0.0 is a special value for which equality
>> holds
>> true.

> I'm not familiar with float equality being unreliable, but I'm by no
> means a C or float expert. Can you link me to some docs/explanation?

The specific issue with float zero is that plus zero and minus zero
are distinct concepts with distinct bit patterns, but the IEEE spec
says that they compare as equal. The C standard says about "if":

[#1] The controlling expression of an if statement shall
have scalar type.
[#2] In both forms, the first substatement is executed if
the expression compares unequal to 0. In the else form, the
second substatement is executed if the expression compares
equal to 0.

so it sure looks to me like a float control expression is valid and
minus zero should be treated as "false". Nonetheless, personally
I'd consider this to be poor style and would write "r != 0" or
"r != 0.0" rather than depending on that.

BTW, this may already need a rebase over 75bd846b6.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joseph Koshakow 2023-03-18 19:33:58 Re: Infinite Interval
Previous Message Joseph Koshakow 2023-03-18 18:48:33 Re: Infinite Interval