diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-23 22:53:26 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-23 22:53:26 +0000 |
commit | 582dcae7e8bbaa660f922c1bcd3deba36c129b6a (patch) | |
tree | cdc81bee4e9e4116c87be4d43c435e1f281bd6b0 /src | |
parent | 58d0214ed8798baa7c4bf4a5089a9d9d39307dda (diff) | |
download | postgresql-582dcae7e8bbaa660f922c1bcd3deba36c129b6a.tar.gz postgresql-582dcae7e8bbaa660f922c1bcd3deba36c129b6a.zip |
Repair two TIME WITH TIME ZONE bugs found by Dennis Vshivkov. Comparison
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).
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/date.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index bc2bb0371c0..4e344eb091e 100644 --- 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.104.4.1 2005/04/23 22:53:26 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 |