pgsql: Fix calculation in brin_minmax_multi_distance_date

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема pgsql: Fix calculation in brin_minmax_multi_distance_date
Дата
Msg-id E1qwQBQ-002dKP-D6@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix calculation in brin_minmax_multi_distance_date

When calculating the distance between date values, make sure to subtract
them in the right order, i.e. (larger - smaller).

The distance is used to determine which values to merge, and is expected
to be a positive value. The code unfortunately did the subtraction in
the opposite order, i.e. (smaller - larger), thus producing negative
values and merging values the most distant values first.

The resulting index is correct (i.e. produces correct results), but may
be significantly less efficient. This affects all minmax-multi indexes
on date columns.

Backpatch to 14, where minmax-multi indexes were introduced.

Reported-by: Ashutosh Bapat
Reviewed-by: Ashutosh Bapat, Dean Rasheed
Backpatch-through: 14
Discussion: https://postgr.es/m/eef0ea8c-4aaa-8d0d-027f-58b1f35dd170@enterprisedb.com

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/088233f8db6c22cbff6c29c212ce138236a5bcc1

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c |  7 ++++++-
src/test/regress/expected/brin_multi.out    | 20 ++++++++++++++++++++
src/test/regress/sql/brin_multi.sql         | 18 ++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: pgsql: Fix minmax-multi on infinite date/timestamp values
Следующее
От: Tomas Vondra
Дата:
Сообщение: pgsql: Fix overflow when calculating timestamp distance in BRIN