Skip to content

Commit c5b08d3

Browse files
committed
Fix btree_gist to handle timetz zone correctly per recent changes.
1 parent a0ea713 commit c5b08d3

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

contrib/btree_gist/btree_time.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,17 @@ gbt_timetz_compress(PG_FUNCTION_ARGS)
124124
{
125125
timeKEY *r = (timeKEY *) palloc(sizeof(timeKEY));
126126
TimeTzADT *tz = DatumGetTimeTzADTP(entry->key);
127+
TimeADT tmp;
127128

128129
retval = palloc(sizeof(GISTENTRY));
129130

130131
/* We are using the time + zone only to compress */
131-
r->lower = r->upper = (tz->time + tz->zone);
132+
#ifdef HAVE_INT64_TIMESTAMP
133+
tmp = tz->time + (tz->zone * INT64CONST(1000000));
134+
#else
135+
tmp = (tz->time + tz->zone);
136+
#endif
137+
r->lower = r->upper = tmp;
132138
gistentryinit(*retval, PointerGetDatum(r),
133139
entry->rel, entry->page,
134140
entry->offset, sizeof(timeKEY), FALSE);
@@ -162,10 +168,17 @@ gbt_timetz_consistent(PG_FUNCTION_ARGS)
162168
{
163169
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
164170
TimeTzADT *query = PG_GETARG_TIMETZADT_P(1);
165-
TimeADT qqq = query->time + query->zone;
171+
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
172+
166173
timeKEY *kkk = (timeKEY *) DatumGetPointer(entry->key);
174+
TimeADT qqq;
167175
GBT_NUMKEY_R key;
168-
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
176+
177+
#ifdef HAVE_INT64_TIMESTAMP
178+
qqq = query->time + (query->zone * INT64CONST(1000000));
179+
#else
180+
qqq = (query->time + query->zone);
181+
#endif
169182

170183
key.lower = (GBT_NUMKEY *) & kkk->lower;
171184
key.upper = (GBT_NUMKEY *) & kkk->upper;

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