Re: Negative value of numGroups

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Negative value of numGroups
Date: 2022-05-17 15:34:17
Message-ID: 1584431.1652801657@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru> writes:
> On 13/5/2022 11:56, Andrey Lepikhov wrote:
>> (long) Min(numGroups, (double) LONG_MAX);
>>
>> can return negative value, if numGroups > LONG_MAX.

I see your point, but I don't think that repeating the same finicky
and undocumented coding pattern in multiple places is a future-proof
fix. I'm inclined to think we should invent a function along the
lines of "long clamp_double_to_long(double x)". Given where it's
used, maybe putting it beside clamp_row_est() would be good.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2022-05-18 09:37:20 BUG #17484: Query does not prune partitions correctly
Previous Message Andrey Lepikhov 2022-05-17 12:59:23 Re: Negative value of numGroups