summaryrefslogtreecommitdiff
path: root/mysql-test/r/subselect4.result
Commit message (Collapse)AuthorAgeFilesLines
* This is the consolidated patch for mdev-8646:bb-10.2-mdev8646Igor Babaev2016-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | "Re-factor the code for post-join operations". The patch mainly contains the code ported from mysql-5.6 and created for two essential architectural changes: 1. WL#5558: Resolve ORDER BY execution method at the optimization stage 2. WL#6071: Inline tmp tables into the nested loops algorithm The first task was implemented for mysql-5.6 by Ole John Aske. It allows to make all decisions on ORDER BY operation at the optimization stage. The second task implemented for mysql-5.6 by Evgeny Potemkin adds JOIN_TAB nodes for post-join operations that require temporary tables. It allows to execute these operations within the nested loops algorithm that used to be used before this task only for join queries. Besides these task moves all planning on the execution of these operations from the execution phase to the optimization phase. Some other re-factoring changes of mysql-5.6 were pulled in, mainly because it was easier to pull them in than roll them back. In particular all changes concerning Ref_ptr_array were incorporated. The port required some changes in the MariaDB code that concerned the functionality of EXPLAIN and ANALYZE. This was done mainly by Sergey Petrunia.
* MDEV-6513 deprecate engine_condition_pushdown value of the @@optimizer_switchSergei Golubchik2014-10-101-0/+4
| | | | | | * ignore the OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN bit * issue a deprecation warning on 'engine_condition_pushdown=on' * remove unused remains of the old pre-5.5 engine_condition_pushdown variable
* 5.5 mergeSergei Golubchik2014-03-261-0/+22
|\
| * 5.3-mergeSergei Golubchik2014-03-161-0/+22
| |\
| | * Fixed bug mdev-5686.Igor Babaev2014-03-061-0/+22
| | | | | | | | | | | | | | | | | | The calls of the function remove_eq_conds() may change the and/or structure of the where conditions. So JOIN::equal_cond should be updated for non-recursive calls of remove_eq_conds().
* | | 10.0-base mergeSergei Golubchik2014-02-261-0/+27
|\ \ \
| * \ \ 5.5 mergeSergei Golubchik2014-02-251-0/+27
| |\ \ \ | | |/ /
| | * | Merge 5.3->5.5Igor Babaev2014-02-101-0/+27
| | |\ \ | | | |/
| | | * Fixed bug mdev-5468.Igor Babaev2014-02-051-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The field JOIN::select_lex->where should be updated after the call of remove_eq_conds() in the function make_join_statistics(). This matters for subselects.
* | | | 10.0-base mergeSergei Golubchik2013-12-161-0/+22
|\ \ \ \ | |/ / /
| * | | 5.5 mergeSergei Golubchik2013-11-231-0/+22
| |\ \ \ | | |/ /
| | * | Merge 5.3->5.5Igor Babaev2013-11-211-0/+22
| | |\ \ | | | |/
| | | * Another attempt to fix bug mdev-5103.Igor Babaev2013-11-211-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The earlier pushed fix for the bug was incomplete. It did not remove the main cause of the problem: the function remove_eq_conds() removed always true multiple equalities from any conjunct, but did not adjust the list of them stored in Item_cond_and::cond_equal.current_level. Simplified the test case for the bug and moved it to another test file. The fix triggered changes in EXPLAIN EXTENDED for some queries.
| | * | Merge 5.3->5.5Igor Babaev2013-08-271-1/+1
| | |\ \ | | | |/
| | * | Merge 5.3->5.5.Igor Babaev2013-08-181-1/+1
| | |\ \ | | | |/ | | | | | | | | | | | | | | | | | | | | In particular: Merged the patch for bug mdev-4418 from 5.3 into 5.5. Fixed a bug in the patch that should be backported to 5.3.
* | | | Merge 10.0-base -> 10.0Sergey Petrunya2013-10-161-8/+8
|\ \ \ \ | |/ / /
| * | | [SHOW] EXPLAIN UPDATE/DELETE, code re-structuringSergey Petrunya2013-06-181-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Part 2 of: - Pass more tests - select with subselects is now shown with type=PRIMARY where it used to be (incorrectly) 'SIMPLE'
* | | | MDEV-4865 Change related to --log option/variable was merged partiallySergei Golubchik2013-08-131-19/+6
| | | | | | | | | | | | | | | | | | | | Complete the merge of magne.mahre@oracle.com-20101102115354-vxcaxminmzglzalk (WL#5185 Remove deprecated 5.1 features)
* | | | 10.0-monty mergeSergei Golubchik2013-07-211-1/+1
|\ \ \ \ | |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | includes: * remove some remnants of "Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING" * introduce LOCK_share, now LOCK_ha_data is strictly for engines * rea_create_table() always creates .par file (even in "frm-only" mode) * fix a 5.6 bug, temp file leak on dummy ALTER TABLE
| * | | Fix a number of trivial test failures by updating error message:Sergey Petrunya2013-07-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | "Unknown table tbl" is now "Unknown table database.tbl" (part#3)
* | | | Merge 5.5->10.0-baseIgor Babaev2013-03-311-5/+19
|\ \ \ \ | |/ / / |/| / / | |/ /
| * | Fix for MDEV-4144unknown2013-03-291-5/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis: The reason for the inefficent plan was that Item_subselect::is_expensive() didn't detect the special case when a subquery was optimized, but had no join plan because it either has no table, or its tables have been optimized away, or the optimizer detected that the result set is empty. Solution: Identify the special cases above in the Item_subselect::is_expensive(), and consider such degenerate subqueries inexpensive.
* | | MDEV-537 Make multi-column non-top level subqueries to be executed via index ↵unknown2013-02-071-2/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (index/unique subquery) instead of single_select_engine This task changes the IN-EXISTS rewrite for multi-column subqueries "(a, b) IN (select b, c ...)" to work in the same way as for single-column subqueries "a IN (select b ...) with respect to the injection of NULL-rejecting predicates. More specifically, the method Item_in_subselect::create_row_in_to_exists_cond() adds Item_is_not_null_test and Item_func_trig_cond only if the left IN operand can be NULL. Not having these predicates when not necessary, makes it possible to rewrite the subquery into a "unique_subquery" or "index_subquery" when there is a suitable index on the only subquery table.
* | Merge 5.3->5.5Igor Babaev2013-01-231-0/+21
|\ \ | |/
| * MDEV-4056 fix.unknown2013-01-161-0/+21
| | | | | | | | | | | | The problem was that maybe_null of Item_row and its componetes was unsynced after update_used_tables() (and so pushed_cond_guards was not initialized but then requested). Fix updates Item_row::maybe_null on update_used_tables().
* | 5.3 mergeSergei Golubchik2013-01-151-0/+26
|\ \ | |/
| * MDEV-3928: Assertion `example' failed in Item_cache::is_expensive_processor ↵unknown2012-12-191-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with a 2-level IN subquery Analysis: The following call stack shows that it is possible to set Item_cache::value_cached, and the relevant value without setting Item_cache::example. #0 Item_cache_temporal::store_packed at item.cc:8395 #1 get_datetime_value at item_cmpfunc.cc:915 #2 resolve_const_item at item.cc:7987 #3 propagate_cond_constants at sql_select.cc:12264 #4 propagate_cond_constants at sql_select.cc:12227 #5 optimize_cond at sql_select.cc:13026 #6 JOIN::optimize at sql_select.cc:1016 #7 st_select_lex::optimize_unflattened_subqueries at sql_lex.cc:3161 #8 JOIN::optimize_unflattened_subqueries at opt_subselect.cc:4880 #9 JOIN::optimize at sql_select.cc:1554 The fix is to set Item_cache_temporal::example even when the value is set directly by Item_cache_temporal::store_packed. This makes the Item_cache_temporal object consistent.
| * Merge MariaDB 5.1.66 -> 5.2 -> 5.3unknown2012-11-091-1/+1
| |\
* | | MDEV-3902 Assertion `record_length == m_record_length' failed at ↵unknown2012-12-211-0/+18
| | | | | | | | | | | | | | | | | | Filesort_buffer::alloc_sort_buffer This bug is a duplicate of mdev-3899 so adding a test case only.
* | | MDEV-3899 Valgrind warnings (blocks are definitely lost) in filesort on IN ↵unknown2012-12-201-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | subquery with SUM and DISTINCT Analysys: In the beginning of JOIN::cleanup there is code that is supposed to free all filesort buffers. The code assumes that the table being sorted is the first non-constant table. To get this table it calls: first_top_level_tab(this, WITHOUT_CONST_TABLES) However, first_top_level_tab() instead returned the wrong table - the first one in the plan, instead of the first non-constant table. There is no other place outside filesort() where sort buffers may be freed. As a result, the sort buffer was not freed, and there was a memory leak. Solution: Change first_top_level_tab(), to test for WITH_CONST_TABLES instead of WITHOUT_CONST_TABLES.
* | | mysql-5.5.28Sergei Golubchik2012-10-161-5/+5
|\ \ \
* \ \ \ Merged the fix for bug lp:1009187, mdev-373unknown2012-09-181-0/+159
|\ \ \ \ | | |/ / | |/| |
| * | | - Merged the fix for bug lp:1009187, mdev-373.unknown2012-09-171-0/+84
| |\ \ \ | | | |/ | | |/| | | | | - Performed some refactoring and simplification that was enabled and required by the merge.
| | * | Fix bug lp:1009187, mdev-373, mysql bug#58628unknown2012-09-141-0/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis: The queries in question use the [unique | index]_subquery execution methods. These methods reuse the ref keys constructed by create_ref_for_key(). The way create_ref_for_key() works is that it doesn't store in ref.key_copy[] store_key elements that represent constants. In particular it doesn't store the store_key for NULL constants. The execution of [unique | index]_subquery calls subselect_uniquesubquery_engine::copy_ref_key, which in addition to copy the left IN argument into a index lookup key, is supposed to detect if the left IN argument contains NULLs. Since the store_key for the NULL constant is not copied into the key array, the null is not detected, and execution erroneously proceeds as if it should look for a complete match. Solution: The solution (unlike MySQL) is to reuse already computed information about NULL presence. Item_in_optimizer::val_int already finds out if the left IN operand contains NULLs. The fix propagates this to the execution methods subselect_[unique | index]subquery_engine::exec so it knows if there were NULL values independent of the presence of keys. In addition the patch siplifies copy_ref_key() and the logic that hanldes the case of NULLs in the left IN operand.
* | | | MDEV-410: EXPLAIN shows type=range, while SHOW EXPLAIN and userstat show ↵Sergey Petrunya2012-07-251-42/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | full table scan is used - Make Item_subselect::fix_fields() ignore UNCACHEABLE_EXPLAIN flag when deciding whether the subquery item should be marked as constant.
* | | | Merged the fix for bug lp:944706, mdev-193unknown2012-06-191-25/+28
|\ \ \ \
| * \ \ \ Merge the fix for lp:944706, mdev-193unknown2012-06-061-26/+29
| |\ \ \ \
| | * | | | Patch for mdev-287: CHEAP SQ: A query with subquery in SELECT list, EXISTS, ↵unknown2012-05-301-60/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | inner joins takes hundreds times longer Analysis: The fix for lp:944706 introduces early subquery optimization. While a subquery is being optimized some of its predicates may be removed. In the test case, the EXISTS subquery is constant, and is evaluated to TRUE. As a result the whole OR is TRUE, and thus the correlated condition "b = alias1.b" is optimized away. The subquery becomes non-correlated. The subquery cache is designed to work only for correlated subqueries. If constant subquery optimization is disallowed, then the constant subquery is not evaluated, the subquery remains correlated, and its execution is cached. As a result execution is fast. However, when the constant subquery was optimized away, it was neither cached by the subquery cache, nor it was cached by the internal subquery caching. The latter was due to the fact that the subquery still appeared as correlated to the subselect_XYZ_engine::exec methods, and they re-executed the subquery on each call to Item_subselect::exec. Solution: The solution is to update the correlated status of the subquery after it has been optimized. This status consists of: - st_select_lex::is_correlated - Item_subselect::is_correlated - SELECT_LEX::uncacheable - SELECT_LEX_UNIT::uncacheable The status is updated by st_select_lex::update_correlated_cache(), and its caller st_select_lex::optimize_unflattened_subqueries. The solution relies on the fact that the optimizer already called st_select_lex::update_used_tables() for each subquery. This allows to efficiently update the correlated status of each subquery without walking the whole subquery tree. Notice that his patch is an improvement over MySQL 5.6 and older, where subqueries are not pre-optimized, and the above analysis is not possible.
| | * | | | Fix for bug lp:944706, task MDEV-193unknown2012-05-171-16/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch enables back constant subquery execution during query optimization after it was disabled during the development of MWL#89 (cost-based choice of IN-TO-EXISTS vs MATERIALIZATION). The main idea is that constant subqueries are allowed to be executed during optimization if their execution is not expensive. The approach is as follows: - Constant subqueries are recursively optimized in the beginning of JOIN::optimize of the outer query. This is done by the new method JOIN::optimize_constant_subqueries(). This is done so that the cost of executing these queries can be estimated. - Optimization of the outer query proceeds normally. During this phase the optimizer may request execution of non-expensive constant subqueries. Each place where the optimizer may potentially execute an expensive expression is guarded with the predicate Item::is_expensive(). - The implementation of Item_subselect::is_expensive has been extended to use the number of examined rows (estimated by the optimizer) as a way to determine whether the subquery is expensive or not. - The new system variable "expensive_subquery_limit" controls how many examined rows are considered to be not expensive. The default is 100. In addition, multiple changes were needed to make this solution work in the light of the changes made by MWL#89. These changes were needed to fix various crashes and wrong results, and legacy bugs discovered during development.
* | | | | | 5.3->5.5 mergeSergey Petrunya2012-06-181-0/+55
|\ \ \ \ \ \ | |/ / / / / |/| | / / / | | |/ / / | |/| | |
| * | | | Fix bug lp:1008773unknown2012-06-141-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis: Queries with implicit grouping (there is aggregate, but no group by) follow some non-obvious semantics in the case of empty result set. Aggregate functions produce some special "natural" value depending on the function. For instance MIN/MAX return NULL, COUNT returns 0. The complexity comes from non-aggregate expressions in the select list. If the non-aggregate expression is a constant, it can be computed, so we should return its value, however if the expression is non-constant, and depends on columns from the empty result set, then the only meaningful value is NULL. The cause of the wrong result was that for subqueries the optimizer didn't make a difference between constant and non-constant ones in the case of empty result for implicit grouping. Solution: In all implementations of Item_subselect::no_rows_in_result() check if the subquery predicate is constant. If it is constant, do not set it to the default value for implicit grouping, instead let it be evaluated.
* | | | | Mergeunknown2012-06-061-50/+65
|\ \ \ \ \ | |/ / / / | | / / / | |/ / / |/| | |
| * | | Fixed bug lp:1000649unknown2012-06-051-50/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis: When the method JOIN::choose_subquery_plan() decided to apply the IN-TO-EXISTS strategy, it set the unit and select_lex uncacheable flag to UNCACHEABLE_DEPENDENT_INJECTED unconditionally. As result, even if IN-TO-EXISTS injected non-correlated predicates, the subquery was still treated as correlated. Solution: Set the subquery as correlated only if the injected predicate(s) depend on the outer query.
* | | | Merge 5.3->5.5.Igor Babaev2012-03-011-35/+18
|\ \ \ \ | |/ / /
| * | | lp:938977 - Query performance with join/index super slow on MariaDB 5.3.4RCSergei Golubchik2012-02-281-31/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | make sure that stored routines are evaluated (that is, de facto - cached) in convert_const_to_int(). revert the fix for lp:806943 because it cannot be repeated anymore. add few tests for convert_const_to_int()
| * | | Merge.Igor Babaev2012-02-241-2/+2
| |\ \ \
| | * | | Fixed LP bug #939009.Igor Babaev2012-02-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The result of materialization of the right part of an IN subquery predicate is placed into a temporary table. Each row of the materialized table is distinct. A unique key over all fields of the temporary table is defined and created. It allows to perform key look-ups into the table. The table created for a materialized subquery can be accessed by key as any other table. The function best_access-path search for the best access to join a table to a given partial join. With some where conditions this function considers a possibility of a ref_or_null access. If such access employs the unique key on the temporary table then when estimating the cost this access the function tries to use the array rec_per_key. Yet, such array is not built for this unique key. This causes a crash of the server. Rows returned by the subquery that contain nulls don't have to be placed into temporary table, as they cannot be match any row produced by the left part of the subquery predicate. So all fields of the temporary table can be defined as non-nullable. In this case any ref_or_null access to the temporary table does not make any sense and it does not make sense to estimate such an access. The fix makes sure that the temporary table for a materialized IN subquery is defined with columns that are all non-nullable. The also ensures that any row with nulls returned by the subquery is not placed into the temporary table.
| * | | | BUG#934597: Assertion `! is_set()' failed in ↵Sergey Petrunya2012-02-241-0/+14
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | Diagnostics_area::set_ok_status(THD... - After the exec_const_cond->val_int() call, check for error and return. (if we don't do it, we will eventually hit an error when trying to set status OK in the diagnostics area, which already has an error status).
* | | | 5.3.4 mergeSergei Golubchik2012-02-151-4/+4
|\ \ \ \ | |/ / /
| * | | Merge 5.2->5.3 in preparation for the release of mariadb-5.3.4-rc.Igor Babaev2012-02-011-4/+4
| |\ \ \ | | |/ /