mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Fix handling of clauses incompatible with extended statistics
Handling of incompatible clauses while applying extended statistics was a bit confused - while handling a mix of compatible and incompatible clauses it sometimes incorrectly treated the incompatible clauses as compatible, resulting in a crash. Fixed by reworking the code applying the selected statistics object to make it easier to understand, and adding a proper compatibility check. Reported-by: David Rowley Discussion: https://postgr.es/m/CAApHDvpYT10-nkSp8xXe-nbO3jmoaRyRFHbzh-RWMfAJynqgpQ%40mail.gmail.com
This commit is contained in:
@@ -1575,6 +1575,8 @@ mcv_match_expression(Node *expr, Bitmapset *keys, List *exprs, Oid *collid)
|
||||
(idx <= bms_num_members(keys) + list_length(exprs)));
|
||||
}
|
||||
|
||||
Assert((idx >= 0) && (idx < bms_num_members(keys) + list_length(exprs)));
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
@@ -1654,6 +1656,8 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
|
||||
/* match the attribute/expression to a dimension of the statistic */
|
||||
idx = mcv_match_expression(clause_expr, keys, exprs, &collid);
|
||||
|
||||
Assert((idx >= 0) && (idx < bms_num_members(keys) + list_length(exprs)));
|
||||
|
||||
/*
|
||||
* Walk through the MCV items and evaluate the current clause. We
|
||||
* can skip items that were already ruled out, and terminate if
|
||||
|
||||
Reference in New Issue
Block a user