Re: Unexpected interval comparison
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: adrian.klaver@aklaver.com, frazer@frazermclean.co.uk,
pgsql-general@postgresql.org
Date: 2017-04-05T21:06:53Z
Lists: pgsql-general
Attachments
- fix-overflow-during-interval-comparison-20170405-2.patch (text/x-diff) patch
- (unnamed) (text/plain)
I wrote: > Looking at what we've got here, it's already a substantial fraction of > what would be needed to provide a compiler-independent implementation > of the int128-based aggregate logic in numeric.c. With that in mind, > I propose that we extract the relevant stuff into a new header file > that is designed as general-purpose int128 support. Something like the > attached. I also attach the test program I put together to verify it. Here's a fleshed-out patch for the original problem based on that. I found that direct int64-to-int128 coercions were also needed to handle some of the steps in timestamp.c, so I added those to int128.h. I think it would be reasonable to back-patch this, although it would need some adjustments for the back branches since we only recently got rid of the float-timestamp option. Also I'd not be inclined to depend on native int128 any further back than it was already in use. regards, tom lane
Commits
-
Fix integer-overflow problems in interval comparison.
- fd52b8834330 9.6.3 landed
- d68a2b20ae2c 9.5.7 landed
- 8851bcf8813b 9.4.12 landed
- df1a699e5ba3 10.0 landed