Skip to content

Commit 72405b0

Browse files
committed
Add some comments to tinterval_cmp_internal pointing out its severe
implementation deficiencies. Per discussion of bug #5592, we're not going to change it, but these things should be documented so that if anyone ever reimplements type tinterval, they will be more careful.
1 parent 31b6fc0 commit 72405b0

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/backend/utils/adt/nabstime.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.164 2010/02/26 02:01:09 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.165 2010/08/03 16:31:02 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1155,9 +1155,22 @@ tintervalsame(PG_FUNCTION_ARGS)
11551155
/*
11561156
* tinterval comparison routines
11571157
*
1158-
* Note: comparison is based on the lengths of the tintervals, not on
1159-
* endpoint value. This is pretty bogus, but since it's only a legacy
1160-
* datatype I'm not going to propose changing it.
1158+
* Note: comparison is based only on the lengths of the tintervals, not on
1159+
* endpoint values (as long as they're not INVALID). This is pretty bogus,
1160+
* but since it's only a legacy datatype, we're not going to change it.
1161+
*
1162+
* Some other bogus things that won't be changed for compatibility reasons:
1163+
* 1. The interval length computations overflow at 2^31 seconds, causing
1164+
* intervals longer than that to sort oddly compared to those shorter.
1165+
* 2. infinity and minus infinity (NOEND_ABSTIME and NOSTART_ABSTIME) are
1166+
* just ordinary integers. Since this code doesn't handle them specially,
1167+
* it's possible for [a b] to be considered longer than [c infinity] for
1168+
* finite abstimes a, b, c. In combination with the previous point, the
1169+
* interval [-infinity infinity] is treated as being shorter than many finite
1170+
* intervals :-(
1171+
*
1172+
* If tinterval is ever reimplemented atop timestamp, it'd be good to give
1173+
* some consideration to avoiding these problems.
11611174
*/
11621175
static int
11631176
tinterval_cmp_internal(TimeInterval a, TimeInterval b)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy