Fix BRIN minmax-multi distance for interval type

Tomas Vondra <tomas.vondra@postgresql.org>

Commit: 2b10e0e3c2ca14d732521479123e5d5e2094e143
Author: Tomas Vondra <tomas.vondra@postgresql.org>
Date: 2021-04-04T17:19:51Z
Releases: 14.0
Fix BRIN minmax-multi distance for interval type

The distance calculation for interval type was treating months as having
31 days, which is inconsistent with the interval comparator (using 30
days). Due to this it was possible to get negative distance (b-a) when
(a<b), trigerring an assert.

Fixed by adopting the same logic as interval_cmp_value.

Reported-by: Jaime Casanova
Discussion: https://postgr.es/m/CAJKUy5jKH0Xhneau2mNftNPtTy-BVgQfXc8zQkEvRvBHfeUThQ%40mail.gmail.com

Files

PathChange+/−
src/backend/access/brin/brin_minmax_multi.c modified +13 −8

Discussion