git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0e99be1)
Repair two TIME WITH TIME ZONE bugs found by Dennis Vshivkov. Comparison
2005年4月23日 22:53:05 +0000 (22:53 +0000)
2005年4月23日 22:53:05 +0000 (22:53 +0000)
of timetz values misbehaved in --enable-integer-datetime cases, and
EXTRACT(EPOCH) subtracted the zone instead of adding it in all cases.
Backpatch to all supported releases (except --enable-integer-datetime code
does not exist in 7.2).


diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index bc2bb0371c0507f459aa6bfa7e0d7b61281af7a7..ab4b71acd17e18a2745a62026984a358df7089db 100644 (file)
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.104 2004年12月31日 22:01:21 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.105 2005年04月23日 22:53:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1869,12 +1869,20 @@ timetz_scale(PG_FUNCTION_ARGS)
static int
timetz_cmp_internal(TimeTzADT *time1, TimeTzADT *time2)
{
+ /* Primary sort is by true (GMT-equivalent) time */
+#ifdef HAVE_INT64_TIMESTAMP
+ int64 t1,
+ t2;
+
+ t1 = time1->time + (time1->zone * INT64CONST(1000000));
+ t2 = time2->time + (time2->zone * INT64CONST(1000000));
+#else
double t1,
t2;
- /* Primary sort is by true (GMT-equivalent) time */
t1 = time1->time + time1->zone;
t2 = time2->time + time2->zone;
+#endif
if (t1 > t2)
return 1;
@@ -2443,9 +2451,9 @@ timetz_part(PG_FUNCTION_ARGS)
else if ((type == RESERV) && (val == DTK_EPOCH))
{
#ifdef HAVE_INT64_TIMESTAMP
- result = ((time->time / 1000000e0) - time->zone);
+ result = ((time->time / 1000000e0) + time->zone);
#else
- result = (time->time - time->zone);
+ result = (time->time + time->zone);
#endif
}
else
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /