diff options
author | Igor Babaev <igor@askmonty.org> | 2018-05-22 12:09:05 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2018-05-22 12:09:05 -0700 |
commit | 6a04c2a1aa60e67c07d4e6ada63f65cc3b26a5a9 (patch) | |
tree | c602e72328a69ad6a77856040a237fd1ec6e3853 /sql/sql_select.cc | |
parent | 27a7365f42ce0184a004e09b3bb1cadb868c8f64 (diff) | |
download | mariadb-git-6a04c2a1aa60e67c07d4e6ada63f65cc3b26a5a9.tar.gz |
MDEV-16235 Server crashes in my_utf8_uni or in my_strtod_int
upon SELECT .. LIMIT 0
The code must differentiate between a SELECT with contradictory
WHERE/HAVING and one with LIMIT 0.
Also for the latter printed 'Zero limit' instead of 'Impossible where'
in the EXPLAIN output.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1e9f1c0848b..d6d269a700f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1136,10 +1136,19 @@ JOIN::optimize() if (cond_value == Item::COND_FALSE || having_value == Item::COND_FALSE || (!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS))) { /* Impossible cond */ - DBUG_PRINT("info", (having_value == Item::COND_FALSE ? - "Impossible HAVING" : "Impossible WHERE")); - zero_result_cause= having_value == Item::COND_FALSE ? - "Impossible HAVING" : "Impossible WHERE"; + if (unit->select_limit_cnt) + { + DBUG_PRINT("info", (having_value == Item::COND_FALSE ? + "Impossible HAVING" : "Impossible WHERE")); + zero_result_cause= having_value == Item::COND_FALSE ? + "Impossible HAVING" : "Impossible WHERE"; + } + else + { + DBUG_PRINT("info", ("Zero limit")); + zero_result_cause= "Zero limit"; + conds= 0; + } table_count= top_join_tab_count= 0; error= 0; goto setup_subq_exit; |