summaryrefslogtreecommitdiff
path: root/sql/item_subselect.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.4 into 10.5Marko Mäkelä2020-12-021-1/+7
|\
| * Merge 10.3 into 10.4Marko Mäkelä2020-12-011-1/+7
| |\
| | * MDEV-21265: IN predicate conversion to IN subquery should be allowed for a ↵Varun Gupta2020-11-301-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | broader set of datatype comparison Allow materialization strategy when collations on the inner and outer sides of an IN subquery are the same and the character set of the inner side is a proper subset of the character set on the outer side. This allows conversion from utf8mb3 to utf8mb4 as the former is a subset of the later. This is only allowed when IN predicate is converted to an IN subquery Backported part of the patch (d6a00d9b18f) of MDEV-17905.
* | | Merge 10.4 into 10.5Marko Mäkelä2020-10-301-1/+1
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-10-291-1/+1
| |\ \ | | |/
| | * Merge 10.2 into 10.3Marko Mäkelä2020-10-281-1/+1
| | |\
| | | * precedence bugfixingSergei Golubchik2020-10-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fix printing precedence for BETWEEN, LIKE/ESCAPE, REGEXP, IN don't use precedence for printing CASE/WHEN/THEN/ELSE/END fix parsing precedence of BETWEEN, LIKE/ESCAPE, REGEXP, IN support predicate arguments for IN, BETWEEN, SOUNDS LIKE, LIKE/ESCAPE, REGEXP use %nonassoc for unary operators fix parsing of IS TRUE/FALSE/UNKNOWN/NULL remove parser_precedence test as superseded by the precedence test
* | | | Merge 10.4 into 10.5Marko Mäkelä2020-08-101-0/+4
|\ \ \ \ | |/ / /
| * | | Merge 10.3 into 10.4Marko Mäkelä2020-08-101-0/+4
| |\ \ \ | | |/ /
| | * | Merge 10.2 into 10.3Marko Mäkelä2020-08-101-0/+4
| | |\ \ | | | |/
| | | * Merge 10.1 into 10.2Marko Mäkelä2020-08-101-0/+4
| | | |\
| | | | * MDEV-9513: Assertion `join->group_list || !join->is_in_subquery()' failed in ↵Varun Gupta2020-08-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | create_sort_index Removing the ORDER BY clause from the UNION when UNION is inside an IN/ALL/ANY/EXISTS subquery. The rewrites are done for subqueries but this rewrite is not done for the fake_select of the UNION.
* | | | | Merge branch '10.4' into 10.5Oleksandr Byelkin2020-08-041-4/+4
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2020-08-031-4/+4
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.2' into 10.3Oleksandr Byelkin2020-08-031-4/+4
| | |\ \ \ | | | |/ /
| | | * | Merge branch '10.1' into 10.2Oleksandr Byelkin2020-08-021-4/+4
| | | |\ \ | | | | |/
| | | | * Code comment spellfixesIan Gilfillan2020-07-221-4/+4
| | | | |
* | | | | fix clang compilationEugene Kosov2020-07-061-72/+77
| | | | |
* | | | | MDEV-23071 remove potentially dangerouws casting to Item_in_subselectOleksandr Byelkin2020-07-061-12/+19
| | | | | | | | | | | | | | | | | | | | Remove types casting with a help of virtual functions.
* | | | | MDEV-14347 CREATE PROCEDURE returns no error when using an unknown variableAlexander Barkov2020-06-101-0/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CREATE PROCEDURE did not detect unknown SP variables in assignments like this: SET var=a_long_var_name_with_a_typo; The error happened only during the SP execution time, and only of the control flow reaches the erroneous statement. Fixing most expressions to detect unknown identifiers. This includes simple subqueries without tables: - Query specification: SELECT list, WHERE, HAVING (inside aggregate functions) clauses, e.g. SET var= (SELECT unknown_ident+1); SET var= (SELECT 1 WHERE unknown_identifier); SET var= (SELECT 1 HAVING SUM(unknown_identifier); - Table value constructor: VALUES clause, e.g.: SET var= (VALUES(unknown_ident)); Note, in some more complex subquery cases unknown variables are still not detected (this will be fixed separately): - Derived tables: SET a=(SELECT unknown_ident FROM (SELECT 1 AS alias) t1); SET res=(SELECT * FROM t1 LEFT OUTER JOIN (SELECT unknown_ident) t2 USING (c1)); - CTE: SET a=(WITH cte1 (a) AS (SELECT unknown_ident) SELECT * FROM cte1); SET a=(WITH cte1 (a,b) AS (VALUES (unknown,2),(3,4)) SELECT * FROM cte1); SET a=(WITH cte1 (a,b) AS (VALUES (1,2),(3,4)) SELECT unknown_ident FROM cte1); - SELECT .. GROUP BY unknown_identifier - SELECT .. ORDER BY unknown_identifier - HAVING with an unknown identifier outside of any aggregate functions: SELECT .. HAVING unknown_identifier;
* | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-2/+2
|\ \ \ \ | |/ / /
| * | | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ \ | | |/ /
| | * | Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| | |\ \ | | | |/
| | | * Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | | |\
| | | | * Update FSF AddressVicențiu Ciorbaru2019-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | * Update wrong zip-code
| * | | | MDEV-17894 Assertion `(thd->lex)->current_select' failed in MYSQLparse(),Igor Babaev2019-05-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | query with VALUES() A table value constructor can be used in all contexts where a select can be used. In particular an ORDER BY clause or a LIMIT clause or both of them can be attached to a table value constructor to produce a new query. Unfortunately execution of such queries was not supported. This patch fixes the problem.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-05-051-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-04-271-1/+1
| |\ \ \ \ | | |/ / /
| | * | | MDEV-16240: Assertion `0' failed in row_sel_convert_mysql_key_to_innobasebb-10.2-MDEV-16240Oleksandr Byelkin2019-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | Set table in row ID position mode before using this function.
* | | | | MDEV-19255 Server crash in st_join_table::save_explain_data or assertionIgor Babaev2019-04-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `sel->quick' failure in JOIN::make_range_rowid_filters upon query with rowid_filter=ON Index ranges can be defined using conditions with inexpensive subqueries. Such a subquery is evaluated when some representation of a possible range sequence is built. After the evaluation the JOIN structure of the subsquery is distroyed. Any attempt to build the above representation may fail because the function that checks whether a subquery is inexpensive in some cases uses the join structure of the subquery. When a range rowid filter is built by a range sequence constructed out of a range condition that uses an inexpensive subquery the representation of the the sequence is built twice. Building the second representation fails due to the described problem with the execution of Item_subselect::is_expensive(). The function was corrected to return the result of the last its invocation if the Item_subselect object has been already evaluated.
* | | | | MDEV-13995 MAX(timestamp) returns a wrong result near DST changeAlexander Barkov2018-12-101-0/+1
| | | | |
* | | | | MDEV-17317 Add THD* parameter into Item::get_date() and stricter data type ↵Alexander Barkov2018-09-281-3/+3
| | | | | | | | | | | | | | | | | | | | control to "fuzzydate"
* | | | | MDEV-16861 Split Item::update_null_value() into a new virtual method in ↵Alexander Barkov2018-07-311-2/+1
| | | | | | | | | | | | | | | | | | | | Type_handler
* | | | | Merge remote-tracking branch 'origin/10.3' into 10.4Alexander Barkov2018-07-031-11/+11
|\ \ \ \ \ | |/ / / /
| * | | | Merge commit '6b8802e8dd5467556a024d807a1df23940b00895' into bb-10.3-fix_len_decbb-10.3-fix_len_decOleksandr Byelkin2018-06-191-11/+11
| |\ \ \ \ | | |/ / /
| | * | | MDEV-11071: Assertion `thd->transaction.stmt.is_empty()' failed in ↵Oleksandr Byelkin2018-06-151-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Locked_tables_list::unlock_locked_table fix_length_and_dec now return result (error/OK)
* | | | | MDEV-16592 Change Item::with_sum_func from a member to a virtual methodAlexander Barkov2018-06-271-1/+4
| | | | |
* | | | | MDEV-12387 Push conditions into materialized subqueriesGalina Shalygina2018-05-151-4/+9
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The logic and the implementation scheme are similar with the MDEV-9197 Pushdown conditions into non-mergeable views/derived tables How the push down is made on the example: select * from t1 where a>3 and b>10 and (a,b) in (select x,max(y) from t2 group by x); --> select * from t1 where a>3 and b>10 and (a,b) in (select x,max(y) from t2 where x>3 group by x having max(y)>10); The implementation scheme: 1. Search for the condition cond that depends only on the fields from the left part of the IN subquery (left_part) 2. Find fields F_group in the select of the right part of the IN subquery (right_part) that are used in the GROUP BY 3. Extract from the cond condition cond_where that depends only on the fields from the left_part that stay at the same places in the left_part (have the same indexes) as the F_group fields in the projection of the right_part 4. Transform cond_where so it can be pushed into the WHERE clause of the right_part and delete cond_where from the cond 5. Transform cond so it can be pushed into the HAVING clause of the right_part The optimization is made in the Item_in_subselect::pushdown_cond_for_in_subquery() and is controlled by the variable condition_pushdown_for_subquery. New test file in_subq_cond_pushdown.test is created. There are also some changes made for setup_jtbm_semi_joins(). Now it is decomposed into the 2 procedures: setup_degenerate_jtbm_semi_joins() that is called before optimize_cond() for cond and setup_jtbm_semi_joins() that is called after optimize_cond(). New setup_jtbm_semi_joins() is made in the way so that the result of its work is the same as if it was called before optimize_cond(). The code that is common for pushdown into materialized derived and into materialized IN subqueries is factored out into pushdown_cond_for_derived(), Item_in_subselect::pushdown_cond_for_in_subquery() and st_select_lex::pushdown_cond_into_where_clause().
* | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2018-02-151-0/+2
|\ \ \ \
| * | | | MDEV-15293 CAST(AS TIME) returns bad results for ↵Alexander Barkov2018-02-131-0/+2
| | | | | | | | | | | | | | | | | | | | LAST_VALUE(),NAME_CONST(),SP variable
* | | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-11-301-0/+1
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-14517 Cleanup for Item::with_subselect and Item::has_subquery()Alexander Barkov2017-11-281-0/+1
| | | | |
* | | | | Remove not used mem_root argument from build_clone(), get_copy() and ↵Michael Widenius2017-11-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | get_item_copy() TODO: - Make get_thd_memroot() inline - To do this, we need to reduce dependence of include files, especially so that sql_class.h is not depending in item.h
* | | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-11-101-2/+2
|\ \ \ \ \ | |/ / / /
| * | | | Merge remote-tracking branch 'origin/10.2' into bb-10.2-extMonty2017-11-091-2/+2
| |\ \ \ \ | | |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mysql-test/r/cte_recursive.result mysql-test/r/derived_cond_pushdown.result mysql-test/t/cte_recursive.test mysql-test/t/derived_cond_pushdown.test sql/datadict.cc sql/handler.cc
| | * | | Merge remote-tracking branch 'origin/10.1' into 10.2Alexander Barkov2017-11-091-2/+2
| | |\ \ \ | | | |/ /
| | | * | Merge remote-tracking branch 'origin/10.0' into 10.1Alexander Barkov2017-11-091-2/+2
| | | |\ \
| | | | * | MDEV-14164: Unknown column error when adding aggregate to function in oracle ↵Oleksandr Byelkin2017-11-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | style procedure FOR loop Make differentiation between pullout for merge and pulout of outer field during exists2in transformation. In last case the field was outer and so we can safely start from name resolution context of the SELECT where it was pulled. Old behavior lead to inconsistence between list of tables and outer name resolution context (which skips one SELECT for merge purposes) which creates problem vor name resolution.
* | | | | | Merge remote-tracking branch 'shagalla/10.3-mdev12172' into 10.3Igor Babaev2017-11-011-0/+2
|\ \ \ \ \ \ | |/ / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | As a result of this merge the code for the following tasks appears in 10.3: - MDEV-12172 Implement tables specified by table value constructors - MDEV-12176 Transform [NOT] IN predicate with long list of values INTO [NOT] IN subquery.
| * | | | | Mistakes corrected.Galina Shalygina2017-10-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TVC can be used in IN subquery and in PARTITION BY struct now. Special variable to control working of optimization added.