Re: Fix overflow hazard in timestamp_pl_interval

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joseph Koshakow <koshy44(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix overflow hazard in timestamp_pl_interval
Date: 2024-04-28 17:45:16
Message-ID: 710530.1714326316@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:
>> Attached is a patch that fixes some overflow/underflow hazards in
>> `timestamp_pl_interval`. The microseconds overflow could produce
>> incorrect result. The month overflow would generally still result in an
>> error from the timestamp month field being too low, but it's still
>> better to catch it early.

Yeah. I had earlier concluded that we couldn't overflow here without
triggering the range checks in tm2timestamp, but clearly that was
too optimistic.

>> I couldn't find any existing timestamp plus interval tests so I stuck
>> a new tests in `timestamp.sql`. If there's a better place, then
>> please let me know.

They're in horology.sql, so I moved the tests there and pushed it.
Thanks for the report!

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-04-28 18:52:40 Re: DROP OWNED BY fails to clean out pg_init_privs grants
Previous Message Justin Pryzby 2024-04-28 14:54:16 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands