summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-18727 improve DML operation of System Versioning (10.4)Aleksey Midenkov2019-11-251-2/+14
| | | | | | | UPDATE, DELETE: replace linear search of current/historical records with vers_setup_conds(). Additional DML cases in view.test
* MDEV-19956 Queries with subqueries containing UNION are not parsedIgor Babaev2019-09-231-12/+36
| | | | | | | | Shift-Reduce conflicts prevented parsing some queries with subqueries that used set operations when the subqueries occurred in expressions or in IN predicands. The grammar rules for query expression were transformed in order to avoid these conflicts. New grammar rules employ an idea taken from MySQL 8.0.
* Merge 10.3 into 10.4Marko Mäkelä2019-09-231-0/+1
|\ | | | | | | Disable MDEV-20576 assertions until MDEV-20595 has been fixed.
| * MDEV-20229 CTE defined with table value constructor cannot be used in viewsIgor Babaev2019-09-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A CTE can be defined as a table values constructor. In this case the CTE is always materialized in a temporary table. If the definition of the CTE contains a list of the names of the CTE columns then the query expression that uses this CTE can refer to the CTE columns by these names. Otherwise the names of the columns are taken from the names of the columns in the result set of the query that specifies the CTE. Thus if the column names of a CTE are provided in the definition the columns of result set should be renamed. In a general case renaming of the columns is done in the select lists of the query specifying the CTE. If a CTE is specified by a table value constructor then there are no such select lists and renaming is actually done for the columns of the result of materialization. Now if a view is specified by a query expression that uses a CTE specified by a table value constructor saving the column names of the CTE in the stored view definition becomes critical: without these names the query expression is not able to refer to the columns of the CTE. This patch saves the given column names of CTEs in stored view definitions that use them.
* | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-4/+38
|\ \ | |/
| * 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-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+40
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-9959: A serious MariaDB server performance bugVarun Gupta2019-04-301-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | If a derived table has SELECT DISTINCT, provide index statistics for it so that the join optimizer in the upper select knows that ref access to the table will produce one row.
* | | | | MDEV-9234 Add Type_handler::union_element_finalize()10.4-stagingAlexander Barkov2019-04-231-5/+5
| | | | |
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-03-201-9/+18
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MDEV-17262 commit 26432e49d37a37d09b862bb49a021e44bdf4789c was skipped. In Galera 4, the implementation would seem to require changes to the streaming replication. In the tests archive.rnd_pos main.profiling, disable_ps_protocol for SHOW STATUS and SHOW PROFILE commands until MDEV-18974 has been fixed.
| * | | | Merge branch '10.2' into 10.3Sergei Golubchik2019-03-171-9/+18
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.1' into 10.2Sergei Golubchik2019-03-151-9/+18
| | |\ \ \ | | | |/ /
| | | * | Fix of prepared CREATE VIEW with global ORDER/GROUPOleksandr Byelkin2019-03-121-10/+21
| | | | |
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-03-061-2/+3
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-03-051-2/+3
| |\ \ \ \ | | |/ / / | | | | | | | | | | | | | | | | | | | | FIXME: Properly resolve conflicts between MDEV-18883 and MDEV-7742/MDEV-8305, and record the correct result for main.log_slow
| | * | | Merge 10.1 into 10.2Marko Mäkelä2019-03-041-2/+3
| | |\ \ \ | | | |/ /
| | | * | Merge branch '10.0' into 10.1Oleksandr Byelkin2019-03-011-2/+3
| | | |\ \
| | | | * \ Merge branch '5.5' into 10.0Oleksandr Byelkin2019-02-281-2/+3
| | | | |\ \ | | | | | |/
| | | | | * MDEV-17055: Server crashes in find_order_in_list upon 2nd (3rd) execution of ↵Oleksandr Byelkin2019-02-281-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SP with UPDATE 1. Always drop merged_for_insert flag on cleanup (there could be errors which prevent TABLE to be assigned) 2. Make more precise cleanup of select parts which was touched
* | | | | | Merge 10.3 into 10.4Marko Mäkelä2018-12-041-2/+5
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge 10.2 into 10.3Marko Mäkelä2018-12-041-2/+5
| |\ \ \ \ \ | | |/ / / /
| | * | | | MDEV-17871 Crash when running explain with CTEIgor Babaev2018-12-011-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the with clause of a query contains a recursive CTE that is not used then processing of EXPLAIN for this query does not require optimization of the unit specifying this CTE. In this case if 'derived' is the TABLE_LIST object created for this CTE then derived->derived_result is NULL and any assignment to derived->derived_result->table causes a crash. After fixing this problem in the code of st_select_lex_unit::prepare() EXPLAIN for such a query worked without crashes. Yet an execution plan for the recursive CTE appeared there. The cause of this problem was an incorrect condition used in JOIN::save_explain_data_intern() that determined whether CTE was to be optimized or not. A similar condition was used in select_describe() and this patch has corrected it as well.
* | | | | | Merge 10.3 into 10.4Marko Mäkelä2018-10-051-1/+33
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge branch '10.2' into 10.3Sergei Golubchik2018-09-281-1/+33
| |\ \ \ \ \ | | |/ / / /
| | * | | | MDEV-17201 dropped anchor rows with non-null recursion queryIgor Babaev2018-09-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function st_select_lex_unit::exec_recursive() missed resetting of select_limit_cnt and offset_limit_cnt before execution of union parts. As a result recursive CTEs specified by UNIONs whose SELECTs contained LIMIT/OFFSET could return wrong sets of records.
| | * | | | MDEV-17024 Crash on large queryIgor Babaev2018-09-071-1/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This problem manifested itself when a join query used two or more materialized CTE such that each of them employed the same recursive CTE. The bug caused a crash. The crash happened because the cleanup() function was performed premature for recursive CTE. This clean up was induced by the cleanup of the first CTE referenced the recusrsive CTE. This cleanup destroyed the structures that would allow to read from the temporary table containing the rows of the recursive CTE and an attempt to read these rows for the second CTE referencing the recursive CTE triggered a crash. The clean up for a recursive CTE R should be performed after the cleanup of the last materialized CTE that uses R.
* | | | | | Merge 10.3 into 10.4Marko Mäkelä2018-09-111-0/+2
|\ \ \ \ \ \ | |/ / / / /
| * | | | | MDEV-17017 Explain for query using derived table specified with a tableIgor Babaev2018-08-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | value constructor shows wrong number of rows If the specification of a derived table contained a table value constructor then the optimizer incorrectly estimated the number of rows in the derived table. This happened because the optimizer did not take into account the number of rows in the constructor. The wrong estimate could lead to choosing inefficient execution plans.
* | | | | | MDEV-11953: support of brackets in UNION/EXCEPT/INTERSECT operationsOleksandr Byelkin2018-07-041-3/+3
| | | | | |
* | | | | | Merge remote-tracking branch 'origin/10.3' into 10.4Alexander Barkov2018-07-031-3/+3
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge branch '10.2' into 10.3Sergei Golubchik2018-06-301-3/+3
| |\ \ \ \ \ | | |/ / / /
| | * | | | Add PART_INDIRECT_KEY_FLAGMonty2018-06-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to mark that a field is indirectly part of a key, which simplifes checking if we need to have this field up to date to evaluate a key. For example: CREATE TABLE t1 (a int, b int as (a) virtual, c int as (b) virtual, index(c)) would mark a and b with PART_INDIRECT_KEY_FLAG. c is marked with PART_KEY_FLAG as before.
* | | | | | MDEV-16388 Replace member Item::fixed to virtual method is_fixed()Alexander Barkov2018-06-051-2/+2
|/ / / / /
* | | | | Merge 10.2 into 10.3Marko Mäkelä2018-06-041-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-16353 Server crash on query with CTEIgor Babaev2018-05-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug caused crashes for queries with unreferenced non-recursive CTEs specified by unions.It happened because the function st_select_lex_unit::prepare() tried to use the value of the field 'derived' that could not be set for unferenced CTEs as there was no derived table associated with an unreferenced CTE.
* | | | | Merge branch 'github/10.2' into 10.3Sergei Golubchik2018-05-221-1/+29
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-15581 Incorrect result (missing row) with UNION DISTINCT in anchor partsIgor Babaev2018-05-171-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current code does not support recursive CTEs whose specifications contain a mix of ALL UNION and DISTINCT UNION operations. This patch catches such specifications and reports errors for them.
| * | | | MDEV-16212 Memory leak with recursive CTE that uses global ORDER BYIgor Babaev2018-05-171-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with recursive subquery There were two problems: 1. The code did not report that usage of global ORDER BY / LIMIT clauses was not supported yet. 2. The code just reset fake_select_lex of the the unit specifying a recursive CTE to NULL and that caused memory leaks in some cases.
* | | | | Merge 10.2 into 10.3Marko Mäkelä2018-05-171-2/+3
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-14695: Assertion `n < m_size' failed in ↵Varun Gupta2018-05-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bounds_checked_array<Element_type>::operator In this issue we hit the assert because we are adding addition fields to the field JOIN::all_fields list. This is done because HEAP tables can't index BIT fields so we need to use an additional hidden field for grouping because later it will be converted to a LONG field. Original field will remain of the BIT type and will be returned. This happens when we convert DISTINCT to GROUP BY. The solution is to take into account the number of such hidden fields that would be added to the field JOIN::all_fields list while calculating the size of the ref_pointer_array.
* | | | | MDEV-15465 Server crash or ASAN heap-use-after-free in ↵Alexey Botchkov2018-05-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Item_func_match::cleanup upon using FT search with partitioning. Partition engine FT keys are implemented in such a way that the FT function's cleanup() methods use table's internals. So calling them after close_thread_tables is unsafe.
* | | | | MDEV-15159 NULL is treated as 0 in CTEIgor Babaev2018-05-141-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Forced columns of recursive CTEs to be nullable. SQL standard requires this only from recursive columns, but in our code so far we do not differentiate between recursive and non-recursive columns when aggregating types of the union that specifies a recursive CTE.
* | | | | cleanup: versioning style fixesSergei Golubchik2018-05-121-3/+3
| | | | | | | | | | | | | | | | | | | | rename LString/XString classes, remove unused ones
* | | | | MDEV-14820 System versioning is applied incorrectly to CTEsSergei Golubchik2018-05-121-26/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make sure that SELECT_LEX_UNIT::derived, behaves as documented (points to the "TABLE_LIST representing this union in the embedding select"). For recursive CTE this was not necessarily the case, it could've pointed to the TABLE_LIST inside the CTE, not in the embedding select. To fix: * don't update unit->derived in mysql_derived_prepare(), pass derived as an argument to st_select_lex_unit::prepare() * prefer to set unit->derived in TABLE_LIST::init_derived() to the TABLE_LIST in the embedding select, not to the recursive reference. Fail if there are many TABLE_LISTs in the embedding select with conflicting FOR SYSTEM_TIME clauses. cleanup: * remove redundant THD* argument from st_select_lex_unit::prepare()
* | | | | cleanup: hide HA_ERR_RECORD_DELETED in ha_rnd_next()Sergei Golubchik2018-05-121-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | it's internal storage engine error, don't let it leak into the upper layer.
* | | | | Add likely/unlikely to speed up executionMonty2018-05-071-29/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added to: - if (error) - Lex - sql_yacc.yy and sql_yacc_ora.yy - In header files to alloc() calls - Added thd argument to thd_net_is_killed()