Fix handling of multi-column BRIN indexes

When evaluating clauses on multiple scan keys of a multi-column BRIN
index, we can stop processing as soon as we find a scan key eliminating
the range, and the range should not be added to tbe bitmap.

That's how it worked before 14, but since a681e3c107 the code treated
the range as matching if it matched at least the last scan key.

Backpatch to 14, where this code was introduced.

Backpatch-through: 14
Discussion: https://postgr.es/m/ebc18613-125e-60df-7520-fcbe0f9274fc%40enterprisedb.com
This commit is contained in:
Tomas Vondra 2023-02-19 00:41:18 +01:00
parent 393430f575
commit e72910f808
1 changed files with 7 additions and 0 deletions

View File

@ -686,6 +686,13 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
break;
}
}
/*
* If we found a scan key eliminating the range, no need to
* check additional ones.
*/
if (!addrange)
break;
}
}
}