Re: Fix for edge case in date_bin() function - Mailing list pgsql-hackers

From Moaaz Assali
Subject Re: Fix for edge case in date_bin() function
Date
Msg-id CALkF+nt9V0WW9i3ezbZ3OrSxrS5__mr62burPPL_4ZAYwrTU_g@mail.gmail.com
Whole thread Raw
In response to Re: Fix for edge case in date_bin() function  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Fix for edge case in date_bin() function
List pgsql-hackers
Hello Tom,

Thanks for the quick patch!

You're right. The stride_usecs calculation, tm_delta += ustride_usecs, and final result calculations can overflow and need a guard.

However, I don't see the issue with the INT64 -> UINT64 mapping. The current implementation results in integer overflows (errors instead after the recent patch) even for valid timestamps where the result of date_bin() is also another valid timestamp. 

On the other hand, the INT64 -> UINT64 mapping solves this issue and allows the input of any valid source and origin timestamps as long as the stride chosen doesn't output invalid timestamps that cannot be represented by Timestamp(tz) type anyways. Since all INT64 values can be mapped 1-to-1 in UINT64, I don't see where the problem is.

Best regards,
Moaaz Assali

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: DOCS: Avoid using abbreviation "aka"
Next
From: Bertrand Drouvot
Date:
Subject: Re: Synchronizing slots from primary to standby