mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Improve BRIN minmax-multi opclass test coverage
Per the code coverage report, the existing regression tests did not exercice some a couple important BRIN minmax-multi code paths. - The tests focused on testing planning with a range of scan key strategies, but not the execution. Fixed by adding queries that actually test query execution for both equality and inequality. - All tests created indexes after inserting data, but this only exercises the CREATE INDEX strategy that sees all values at once, not incremental summary updates. The new tests flip the order and create the index before adding data. - The assert check(s) validating correctness of expanded ranges were present only in the "union" code path, which is not covered by regression tests at all (as it requires concurrency etc.). Fixed by adding the asserts to a couple more places. Reviewed-by: Heikki Linnakangas Discussion: https://postgr.es/m/57020b2e-d9c9-9bc7-4892-b36d9bb07563%40enterprisedb.com
This commit is contained in:
@@ -1660,6 +1660,9 @@ ensure_free_space_in_buffer(BrinDesc *bdesc, Oid colloid,
|
||||
/* build the expanded ranges */
|
||||
eranges = build_expanded_ranges(cmpFn, colloid, range, &neranges);
|
||||
|
||||
/* Is the expanded representation of ranges correct? */
|
||||
AssertCheckExpandedRanges(bdesc, colloid, attno, attr, eranges, neranges);
|
||||
|
||||
/* and we'll also need the 'distance' procedure */
|
||||
distanceFn = minmax_multi_get_procinfo(bdesc, attno, PROCNUM_DISTANCE);
|
||||
|
||||
@@ -1675,6 +1678,9 @@ ensure_free_space_in_buffer(BrinDesc *bdesc, Oid colloid,
|
||||
range->maxvalues * MINMAX_BUFFER_LOAD_FACTOR,
|
||||
cmpFn, colloid);
|
||||
|
||||
/* Is the result of reducing expanded ranges correct? */
|
||||
AssertCheckExpandedRanges(bdesc, colloid, attno, attr, eranges, neranges);
|
||||
|
||||
/* Make sure we've sufficiently reduced the number of ranges. */
|
||||
Assert(count_values(eranges, neranges) <= range->maxvalues * MINMAX_BUFFER_LOAD_FACTOR);
|
||||
|
||||
@@ -2859,6 +2865,9 @@ brin_minmax_multi_union(PG_FUNCTION_ARGS)
|
||||
ranges_a->maxvalues,
|
||||
cmpFn, colloid);
|
||||
|
||||
/* Is the result of reducing expanded ranges correct? */
|
||||
AssertCheckExpandedRanges(bdesc, colloid, attno, attr, eranges, neranges);
|
||||
|
||||
/* update the first range summary */
|
||||
store_expanded_ranges(ranges_a, eranges, neranges);
|
||||
|
||||
|
Reference in New Issue
Block a user