pgsql: Fix BRIN minmax-multi distance for interval type

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix BRIN minmax-multi distance for interval type
Date: 2021-04-04 17:21:28
Message-ID: E1lT6RE-0003xA-Pf@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2b10e0e3c2ca14d732521479123e5d5e2094e143

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tomas Vondra 2021-04-04 17:23:23 pgsql: Fix BRIN minmax-multi distance for timetz type
Previous Message Tom Lane 2021-04-03 21:38:39 pgsql: Improve psql's behavior when the editor is exited without saving