mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-31983 jointable materialization subquery optimization ignoring
...errors, then failing ASSERT. UPDATE queries treat warnings as errors. In this case, an invalid condition "datetime_key_col >= '2012-01'" caused warning-as-error inside SQL_SELECT::test_quick_select(). The code that called test_quick_select() ignored this error and continued join optimization. Then it eventually reached a thd->is_error() check and failed to setup SJ-Materialization which failed an assert. Fixed this by making SQL_SELECT::test_quick_select() return error in its return value, and making any code that calls it to check for error condition and abort the query if the error is returned. Places in the code that didn't check for errors from SQL_SELECT::test_quick_select but now do: - get_quick_record_count() call in make_join_statistics(), - test_if_skip_sort_order(), - "Range checked for each record" code. Extra error handling fixes and commit text wording by Sergei Petrunia, Reviewed-by: Sergei Petrunia, Oleg Smirnov
This commit is contained in:
@@ -1712,13 +1712,20 @@ class SQL_SELECT :public Sql_alloc {
|
||||
~SQL_SELECT();
|
||||
void cleanup();
|
||||
void set_quick(QUICK_SELECT_I *new_quick) { delete quick; quick= new_quick; }
|
||||
|
||||
/*
|
||||
@return
|
||||
true - for ERROR and IMPOSSIBLE_RANGE
|
||||
false - Ok
|
||||
*/
|
||||
bool check_quick(THD *thd, bool force_quick_range, ha_rows limit)
|
||||
{
|
||||
key_map tmp;
|
||||
tmp.set_all();
|
||||
return test_quick_select(thd, tmp, 0, limit, force_quick_range,
|
||||
FALSE, FALSE, FALSE) < 0;
|
||||
FALSE, FALSE, FALSE) != OK;
|
||||
}
|
||||
|
||||
/*
|
||||
RETURN
|
||||
0 if record must be skipped <-> (cond && cond->val_int() == 0)
|
||||
@@ -1732,13 +1739,25 @@ class SQL_SELECT :public Sql_alloc {
|
||||
rc= -1;
|
||||
return rc;
|
||||
}
|
||||
int test_quick_select(THD *thd, key_map keys, table_map prev_tables,
|
||||
ha_rows limit, bool force_quick_range,
|
||||
bool ordered_output, bool remove_false_parts_of_where,
|
||||
bool only_single_index_range_scan,
|
||||
bool suppress_unusable_key_notes = 0);
|
||||
|
||||
enum quick_select_return_type {
|
||||
IMPOSSIBLE_RANGE = -1,
|
||||
ERROR,
|
||||
OK
|
||||
};
|
||||
|
||||
enum quick_select_return_type
|
||||
test_quick_select(THD *thd, key_map keys, table_map prev_tables,
|
||||
ha_rows limit,
|
||||
bool force_quick_range,
|
||||
bool ordered_output,
|
||||
bool remove_false_parts_of_where,
|
||||
bool only_single_index_range_scan,
|
||||
bool suppress_unusable_key_notes = 0);
|
||||
};
|
||||
|
||||
typedef enum SQL_SELECT::quick_select_return_type quick_select_return;
|
||||
|
||||
|
||||
class SQL_SELECT_auto
|
||||
{
|
||||
|
Reference in New Issue
Block a user