aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2021-04-04 19:21:41 +0200
committerTomas Vondra <tomas.vondra@postgresql.org>2021-04-04 19:22:23 +0200
commit7262f2421a1e099a631356f7b80ad198e34e2a8a (patch)
tree78b6ff8f6170861dbfcf8e91c86f3586372fba4d
parent2b10e0e3c2ca14d732521479123e5d5e2094e143 (diff)
downloadpostgresql-7262f2421a1e099a631356f7b80ad198e34e2a8a.tar.gz
postgresql-7262f2421a1e099a631356f7b80ad198e34e2a8a.zip
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
-rw-r--r--src/backend/access/brin/brin_minmax_multi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/access/brin/brin_minmax_multi.c b/src/backend/access/brin/brin_minmax_multi.c
index 42bb177290e..e182cd95ecd 100644
--- a/src/backend/access/brin/brin_minmax_multi.c
+++ b/src/backend/access/brin/brin_minmax_multi.c
@@ -2090,7 +2090,7 @@ brin_minmax_multi_distance_timetz(PG_FUNCTION_ARGS)
TimeTzADT *ta = PG_GETARG_TIMETZADT_P(0);
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);