pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix assert in BRIN build_distances
3+ messages / 1 participants
[nested] [flat]

* pgsql: Fix assert in BRIN build_distances
@ 2022-12-30 19:48 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Tomas Vondra @ 2022-12-30 19:48 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix assert in BRIN build_distances

When brin_minmax_multi_union merges summaries, we may end up with just a
single range after merge_overlapping_ranges. The summaries may contain
just one range each, and they may overlap (or be exactly the same).

With a single range there's no distance to calculate, but we happen to
call build_distances anyway - which is fine, we don't calculate the
distance in this case, except that with asserts this failed due to a
check there are at least two ranges.

The assert is unnecessarily strict, so relax it a bit and bail out if
there's just a single range. The relaxed assert would be enough, but
this way we don't allocate unnecessary memory for distance.

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

Reported-by: Jaime Casanova
Backpatch-through: 14
Discussion: https://postgr.es/m/YzVA55qS0hgz8P3r@ahch-to

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/883dc0214a64c0923455bf30bfcc5f953e70af39

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Fix assert in BRIN build_distances
@ 2022-12-30 19:49 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Tomas Vondra @ 2022-12-30 19:49 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix assert in BRIN build_distances

When brin_minmax_multi_union merges summaries, we may end up with just a
single range after merge_overlapping_ranges. The summaries may contain
just one range each, and they may overlap (or be exactly the same).

With a single range there's no distance to calculate, but we happen to
call build_distances anyway - which is fine, we don't calculate the
distance in this case, except that with asserts this failed due to a
check there are at least two ranges.

The assert is unnecessarily strict, so relax it a bit and bail out if
there's just a single range. The relaxed assert would be enough, but
this way we don't allocate unnecessary memory for distance.

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

Reported-by: Jaime Casanova
Backpatch-through: 14
Discussion: https://postgr.es/m/YzVA55qS0hgz8P3r@ahch-to

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c4f64cfab9fefd7974c9097be72691c33c7afcea

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Fix assert in BRIN build_distances
@ 2022-12-30 19:50 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Tomas Vondra @ 2022-12-30 19:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix assert in BRIN build_distances

When brin_minmax_multi_union merges summaries, we may end up with just a
single range after merge_overlapping_ranges. The summaries may contain
just one range each, and they may overlap (or be exactly the same).

With a single range there's no distance to calculate, but we happen to
call build_distances anyway - which is fine, we don't calculate the
distance in this case, except that with asserts this failed due to a
check there are at least two ranges.

The assert is unnecessarily strict, so relax it a bit and bail out if
there's just a single range. The relaxed assert would be enough, but
this way we don't allocate unnecessary memory for distance.

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

Reported-by: Jaime Casanova
Backpatch-through: 14
Discussion: https://postgr.es/m/YzVA55qS0hgz8P3r@ahch-to

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/02699bc1fd3b7fccba2e6b55189a148ef69b8a00

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-12-30 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-12-30 19:48 pgsql: Fix assert in BRIN build_distances Tomas Vondra <tomas.vondra@postgresql.org>
2022-12-30 19:49 pgsql: Fix assert in BRIN build_distances Tomas Vondra <tomas.vondra@postgresql.org>
2022-12-30 19:50 pgsql: Fix assert in BRIN build_distances Tomas Vondra <tomas.vondra@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox