Re: Unexpected interval comparison
Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
From: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
To: tgl@sss.pgh.pa.us
Cc: adrian.klaver@aklaver.com, frazer@frazermclean.co.uk,
pgsql-general@postgresql.org
Date: 2017-04-03T11:51:18Z
Lists: pgsql-general
Attachments
- 0001-Fix-overflow-during-interval-comparison.patch (text/x-patch)
Hmm. It took a bit longer time than expected. At Fri, 31 Mar 2017 13:29:24 -0400, Tom Lane <tgl@sss.pgh.pa.us> wrote in <10353.1490981364@sss.pgh.pa.us> > Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> writes: > > int128 is seen in numeric.c. It is doable in the same manner. In > > that case it will be a bit slower on the platforms without > > int128. > > > By the way is it right that we don't assume this as a bug-fix > > which should be done in the Pg10 dev cycle, but an improvement > > for 11? > > Well, it seems like a bug to me. We might conclude that the fix > is too risky to back-patch, but it's hard to make that decision > before having a patch in hand to evaluate. Ok, the attached patch changes the result type of interval_cmp_value from TimeOffset(=int64) to new 128 bit LinearInterval. The value is hidden under the functions interval_eq/ge.../cmp and all other stuff seems to use the functions. For platforms without 128 bit support, int64 * 2 version of interval_cmp_value is used. I added separate test for the near-overflow values since just adding such values into INTERVAL_TABLE resuted in a mess. (I ran 64-bit version by commenting-out the definition of PG_INT128_TYPE in pg_config.h). The attached patch is that. regards, -- Kyotaro Horiguchi NTT Open Source Software Center
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