Commit 7262f242 authored by Tomas Vondra's avatar Tomas Vondra

Fix BRIN minmax-multi distance for timetz type

The distance calculation ignored the time zone, so the result of (b-a)
might have ended negative even if (b > a). Fixed by considering the time
zone difference.

Reported-by: Jaime Casanova
Discussion: https://postgr.es/m/CAJKUy5jLZFLCxyxfT%3DMfK5mtPfSzHA1rVLowR-j4RRsFVvKm7A%40mail.gmail.com
parent 2b10e0e3
...@@ -2090,7 +2090,7 @@ brin_minmax_multi_distance_timetz(PG_FUNCTION_ARGS) ...@@ -2090,7 +2090,7 @@ brin_minmax_multi_distance_timetz(PG_FUNCTION_ARGS)
TimeTzADT *ta = PG_GETARG_TIMETZADT_P(0); TimeTzADT *ta = PG_GETARG_TIMETZADT_P(0);
TimeTzADT *tb = PG_GETARG_TIMETZADT_P(1); TimeTzADT *tb = PG_GETARG_TIMETZADT_P(1);
delta = tb->time - ta->time; delta = (tb->time - ta->time) + (tb->zone - ta->zone) * USECS_PER_SEC;
Assert(delta >= 0); Assert(delta >= 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment