mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix LP BUG#682683
Analysis: The fix for LP BUG#680846 avoids evaluation of constant expressions with subqueries in the GROUP/ORDER clauses in the procedure remove_const(). The purpose of remove_const is to remove constant expressions in the GROUP/ORDER clauses. In order delay until execution the evaluation of such subqueries, they were not removed in the GROUP/ORDER clause. As a result temp table creation during execution attempted to create a column in the temp table for each constant GROUP/ORDER expression. However, the logic in create_tmp_table is to not create temp table columns for constant items. The crash was due to a group Item without a corresponding column in the temp table for GROUP BY. Solution: The patch adds back removal of constant expressions with subqueries. In order for such expressions to be evaluated, so that the server can ensure that such subquries return 1 row, the evaluation of these expressions is delayed until execution.
This commit is contained in:
@ -1599,6 +1599,13 @@ public:
|
||||
evaluated at optimization time.
|
||||
*/
|
||||
Item *exec_const_cond;
|
||||
/*
|
||||
Constant ORDER and/or GROUP expressions that contain subqueries. Such
|
||||
expressions need to evaluated to verify that the subquery indeed
|
||||
returns a single row. The evaluation of such expressions is delayed
|
||||
until query execution.
|
||||
*/
|
||||
List<Item> exec_const_order_group_cond;
|
||||
SQL_SELECT *select; ///<created in optimisation phase
|
||||
JOIN_TAB *return_tab; ///<used only for outer joins
|
||||
Item **ref_pointer_array; ///<used pointer reference for this select
|
||||
@ -1762,7 +1769,8 @@ public:
|
||||
bool send_row_on_empty_set()
|
||||
{
|
||||
return (do_send_rows && tmp_table_param.sum_func_count != 0 &&
|
||||
!group_list && having_value != Item::COND_FALSE);
|
||||
!(group_list || group_optimized_away) &&
|
||||
having_value != Item::COND_FALSE);
|
||||
}
|
||||
bool change_result(select_result *result);
|
||||
bool is_top_level_join() const
|
||||
|
Reference in New Issue
Block a user