Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02699bc

Browse filesBrowse files
committed
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
1 parent 7aa81c6 commit 02699bc
Copy full SHA for 02699bc

File tree

1 file changed

+5
-1
lines changed
Filter options

1 file changed

+5
-1
lines changed

‎src/backend/access/brin/brin_minmax_multi.c

Copy file name to clipboardExpand all lines: src/backend/access/brin/brin_minmax_multi.c
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,11 @@ build_distances(FmgrInfo *distanceFn, Oid colloid,
13351335
int ndistances;
13361336
DistanceValue *distances;
13371337

1338-
Assert(neranges >= 2);
1338+
Assert(neranges > 0);
1339+
1340+
/* If there's only a single range, there's no distance to calculate. */
1341+
if (neranges == 1)
1342+
return NULL;
13391343

13401344
ndistances = (neranges - 1);
13411345
distances = (DistanceValue *) palloc0(sizeof(DistanceValue) * ndistances);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.