-
unknown authored
Recommit to 5.1.22. The bug caused memory corruption for some queries with top OR level in the WHERE condition if they contained equality predicates and other sargable predicates in disjunctive parts of the condition. The corruption happened because the upper bound of the memory allocated for KEY_FIELD and SARGABLE_PARAM internal structures containing info about potential lookup keys was calculated incorrectly in some cases. In particular it was calculated incorrectly when the WHERE condition was an OR formula with disjuncts being AND formulas including equalities and other sargable predicates. mysql-test/r/select.result: Added a test case for bug #30396. Recommit to 5.1.22. mysql-test/t/select.test: Added a test case for bug #30396. Recommit to 5.1.22. sql/item_cmpfunc.h: Removed max_members from the COND_EQUAL class as not useful anymore. Recommit to 5.1.22. sql/sql_base.cc: Added the max_equal_elems field to the st_select_lex structure. Recommit to 5.1.22. sql/sql_lex.cc: Added the max_equal_elems field to the st_select_lex structure. Recommit to 5.1.22. sql/sql_lex.h: Added the max_equal_elems field to the st_select_lex structure. The field contains the maximal number of elements in multiple equalities built for the query conditions. Recommit to 5.1.22. sql/sql_select.cc: Fixed bug #30396. Recommit to 5.1.22. The bug caused memory corruption for some queries with top OR level in the WHERE condition if they contained equality predicates and other sargable predicates in disjunctive parts of the condition. The corruption happened because the upper bound of the memory allocated for KEY_FIELD and SARGABLE_PARAM internal structures containing info about potential lookup keys was calculated incorrectly in some cases. In particular it was calculated incorrectly when the WHERE condition was an OR formula with disjuncts being AND formulas including equalities and other sargable predicates. The max_equal_elems field to the st_select_lex structure is used now to calculate the above mentioned upper bound. The field contains the maximal number of elements in multiple equalities built for the query conditions.
d55f22fe