summaryrefslogtreecommitdiff
path: root/sql/sql_tvc.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.3 into 10.4Marko Mäkelä2021-03-081-0/+2
|\
| * MDEV-22786 Crashes with nested table value constructorsIgor Babaev2021-03-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug caused crashes of the server when processing queries with nested table value constructors (TVC) . It happened because the grammar rules to parse TVC used the same global lists for both nested TVC and nesting TVC. As a result invalid select trees were constructed for queries with nested TVC and this led to crashes at the prepare stage. This patch provides its own lists structures for each TVC nest level. Besides the patch fixes a bug in the function wrap_tvc() that missed inheritance of the SELECT_LEX::exclude_from_table_unique_test for selects that wrapped TVCs. This inheritance is critical for specifications of derived tables that employ nested TVCs. Approved by dmitry.shulga@mariadb.com
* | Merge 10.3 into 10.4Marko Mäkelä2021-03-051-10/+5
|\ \ | |/
| * MDEV-24919 Crash with subselect formed by table value constructor andIgor Babaev2021-03-011-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | used in set function If a subselect is formed by a table value constructor (TVC) then the following transformation is applied at the prepare stage: VALUES (v1), ... (vn) => SELECT * FROM (VALUES (v1), ... (vn)) tvc_x. The transformation is performed by the function wrap_tvc() that resets THD::LEX::current select to the top level select of the result of the transformation. After the call of wrap_tvc() in the function Item_subselect::wrap_tvc_into_select() the field THD::LEX::current must be reset to the same select as before the call. It was not done. As a result if the subselect formed by a TVC was an argument of a set function then an assertion was hit in the function Item_sum::check_sum_func(). Approved by Oleksandr Byelkin <sanja@mariadb.com>
* | Merge branch '10.3' into 10.4Daniel Black2021-02-251-27/+40
|\ \ | |/
| * MDEV-24910 Crash with SELECT that uses table value constructor as a subselectIgor Babaev2021-02-241-27/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug caused crashes of the server when processing queries with table value constructors (TVC) that contained subqueries and were used itself as subselects. For such TVCs the following transformation is applied at the prepare stage: VALUES (v1), ... (vn) => SELECT * FROM (VALUES (v1), ... (vn)) tvc_x. This transformation allows to reduce the problem of evaluation of TVCs used as subselects to the problem of evaluation of regular subselects. The transformation is implemented in the wrap_tvc(). The code the function to mimic the behaviour of the parser when processing the result of the transformation. However this imitation was not free of some flaws. First the function called the method exclude() that completely destroyed the select tree structures below the transformed TVC. Second the function used the procedure mysql_new_select to create st_select_lex nodes for both wrapping select of the transformation and TVC. This also led to constructing of invalid select tree structures. The patch actually re-engineers the code of wrap_tvc(). Approved by Oleksandr Byelkin <sanja@mariadb.com>
* | Merge branch '10.3' into 10.4Sergei Golubchik2021-02-231-7/+20
|\ \ | |/
| * MDEV-24936 EXPLAIN for query based on table value constructor lacks infoIgor Babaev2021-02-221-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | on used subqueries If a query was based on a table value constructor that contained subqueries then EXPLAIN for such query did not contain any lines explaining the execution plans of the subqueries. This happened because - no optimize() method was called for any subquery used by the table value constructor when EXPLAIN command for the query was processed; - EXPLAIN node created for the table value constructor itself did not assume that some child nodes could be attached to it. Approved by Oleksandr Byelkin <sanja@mariadb.com>
| * MDEV-24840 Crash caused by query with IN subquery containing unionIgor Babaev2021-02-101-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | of two table value costructors This bug affected queries with a [NOT] IN/ANY/ALL subquery whose top level unit contained several table value constructors. The problem appeared because the code of the function Item_subselect::fix_fields() that was responsible for wrapping table value constructors encountered at the top level unit of a [NOT] IN/ANY/ALL subquery did not take into account that the chain of the select objects comprising the unit were not immutable. Approved by Oleksandr Byelkin <sanja@mariadb.com>
* | Merge branch 'bb-10.3-release' into bb-10.4-releaseSergei Golubchik2021-02-121-2/+2
|\ \ | |/ | | | | | | Note, the fix for "MDEV-23328 Server hang due to Galera lock conflict resolution" was null-merged. 10.4 version of the fix is coming up separately
| * MDEV-24675 Server crash when table value constructor uses a subselectIgor Babaev2021-01-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch actually fixes the bug MDEV-24675 and the bug MDEV-24618: Assertion failure when TVC uses a row in the context expecting scalar value The cause of these bugs is the same wrong call of the function that fixes value expressions in the value list of a table value constructor. The assertion failure happened when an expression in the value list is of the row type. In this case an error message was expected, but it was not issued because the function fix_fields_if_needed() was called for to check fields of value expressions in a TVC instead of the function fix_fields_if_needed_for_scalar() that would also check that the value expressions are are of a scalar type. The first bug happened when a table value expression used an expression returned by single-row subselect. In this case the call of the fix_fields_if_needed_for_scalar virtual function must be provided with and address to which the single-row subselect has to be attached. Test cases were added for each of the bugs. Approved by Oleksandr Byelkin <sanja@mariadb.com>
* | Merge 10.3 into 10.4Marko Mäkelä2020-12-011-2/+4
|\ \ | |/
| * MDEV-21265: IN predicate conversion to IN subquery should be allowed for a ↵Varun Gupta2020-11-301-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 remote-tracking branch 'origin/10.3' into 10.4Alexander Barkov2020-05-191-1/+2
|\ \ | |/
| * MDEV-21995 Server crashes in Item_field::real_type_handler with table value ↵Alexander Barkov2020-05-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | constructor 1. Code simplification: Item_default_value handled all these values: a. DEFAULT(field) b. DEFAULT c. IGNORE and had various conditions to distinguish (a) from (b) and from (c). Introducing a new abstract class Item_contextually_typed_value_specification, to handle (b) and (c), so the hierarchy now looks as follows: Item Item_result_field Item_ident Item_field Item_default_value - DEFAULT(field) Item_contextually_typed_value_specification Item_default_specification - DEFAULT Item_ignore_specification - IGNORE 2. Introducing a new virtual method is_evaluable_expression() to determine if an Item is: - a normal expression, so its val_xxx()/get_date() methods can be called - or a just an expression substitute, whose value methods cannot be called. 3. Disallowing Items that are not evalualble expressions in table value constructors.
* | Merge 10.3 into 10.4Marko Mäkelä2020-05-161-1/+8
|\ \ | |/
| * MDEV-22560 Crash on a table value constructor with an SP variableAlexander Barkov2020-05-151-1/+8
| | | | | | | | | | fix_fields_for_tvc() could call fix_fields() for Items that have already been fixed before. Changing fix_fields() to fix_fields_if_needed().
* | Merge 10.3 into 10.4Marko Mäkelä2019-12-131-1/+55
|\ \ | |/ | | | | | | We disable the MDEV-21189 test galera.galera_partition because it times out.
| * MDEV-20900: IN predicate to IN subquery conversion causes performance regressionVarun Gupta2019-12-101-1/+55
| | | | | | | | | | Disable the IN predicate to IN subquery conversion when the types on the left and right hand side of the IN predicate are not of comparable type.
* | MDEV-19956 Queries with subqueries containing UNION are not parsedIgor Babaev2019-09-231-2/+2
| | | | | | | | | | | | | | | | 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 branch '10.3' into 10.4Sergei Golubchik2019-09-061-1/+2
|\ \ | |/
| * MDEV-16871 in_predicate_conversion_threshold cannot be set in my.cnfSergei Golubchik2019-09-041-1/+2
| |
* | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-33/+199
|\ \ | |/
| * MDEV-17894 Assertion `(thd->lex)->current_select' failed in MYSQLparse(),Igor Babaev2019-05-081-33/+199
| | | | | | | | | | | | | | | | | | | | 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-03-201-7/+7
|\ \ | |/ | | | | | | | | | | | | | | | | 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.
| * post-merge: --ps-protocol fixesSergei Golubchik2019-03-171-7/+7
| |
* | Merge 10.3 into 10.4Marko Mäkelä2018-10-171-2/+17
|\ \ | |/
| * MDEV-17222 Reproducible server crash in String_list::append_str orIgor Babaev2018-10-141-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in Field_iterator_table::create_item When IN predicate is converted to IN subquery we have to ensure that any item from the select list of the subquery has some name and this name is unique across the select list. This was not guaranteed by the code before the patch for MDEV-17222. If the name of an item of the select list was not set, and this happened for binary constants, then the server crashed. If the first row in the IN list contained the same constant in two different positions then the server returned an error message. This was fixed by providing all constants in the first row of the IN list with generated names.
* | MDEV-11953: support of brackets in UNION/EXCEPT/INTERSECT operationsOleksandr Byelkin2018-07-041-4/+4
| |
* | MDEV-16388 Replace member Item::fixed to virtual method is_fixed()Alexander Barkov2018-06-051-2/+1
|/
* Add likely/unlikely to speed up executionMonty2018-05-071-1/+1
| | | | | | | | | 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()
* MDEV-16038 Assertion `map->n_bits > 0' failed (my_bitmap.c:386: ↵Igor Babaev2018-04-261-0/+6
| | | | | | | bitmap_is_clear_all) Rows with no elements are not allowed in a table value constructor unless it is used in an INSERT statement.
* MDEV-14835 Server crashes in Field_iterator_table::create_item when number ofGalina Shalygina2018-02-201-1/+1
| | | | | | | | | | | elements of BIGINT or YEAR type in the IN list reaches in_predicate_conversion_threshold The bug appears at the prepare stage when IN-predicate with the long list of values is converted into IN-subquery. It happens because values in the right operand of the IN-predicate that have BIGINT or YEAR types are converted into the Item_int_with_ref. To fix it in the procedure Item_func_in::create_value_list_for_tvc real_item() is taken for each value in the right operand of the IN-predicate.
* Bug fixGalina Shalygina2018-01-251-2/+2
| | | | Wrong conversion
* System Versioning 1.0pre2Aleksey Midenkov2017-11-231-2/+6
|\ | | | | | | Merge branch '10.3' into trunk
| * Handle failures from mallocMichael Widenius2017-11-171-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most "new" failures fixed in the following files: - sql_select.cc - item.cc - item_func.cc - opt_subselect.cc Other things: - Allocate udf_handler strings in mem_root - Required changes in sql_string.h - Add mem_root as argument to some new [] calls - Mark udf_handler strings as thread specific - Removed some comment blocks with code
* | SQL: VIEW of UNION [fixes #293]Aleksey Midenkov2017-11-131-1/+1
|/
* Fixed mdev-14281 Wrong result from query with NOT IN predicate in WHEREIgor Babaev2017-11-051-4/+10
| | | | | | | Conversion of NOT IN predicates into NOT IN subqueries did not work correctly: the predicates actually were converted into IN subqueries. As a result if the conversion was applied for the query with a NOT IN predicate the query could return a wrong result set.
* Remove a type castMarko Mäkelä2017-11-021-2/+2
|
* Fixed compilation failuresMonty2017-11-021-2/+17
| | | | - Also added missing copyright notices
* Merge remote-tracking branch 'shagalla/10.3-mdev12172' into 10.3Igor Babaev2017-11-011-24/+27
| | | | | | | 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/+97
| | | | | TVC can be used in IN subquery and in PARTITION BY struct now. Special variable to control working of optimization added.
* New tests on errors added. Comments corrected. Some procedures corrected.Galina Shalygina2017-09-041-81/+142
|
* Post review changes for the optimization of IN predicates into IN subqueries.Galina Shalygina2017-09-021-119/+170
|
* Memory allocation corrected. New tests added.Galina Shalygina2017-09-011-88/+68
|
* Mistakes corrected. Now all tests in opt_tvc.test file work correctlyGalina Shalygina2017-08-291-1/+0
|
* Mistakes corrected, new error messages addedGalina Shalygina2017-08-291-2/+9
|
* Summarized results of two previous commits (26 July, 25 August)Galina Shalygina2017-08-291-31/+539
|
* New structure Table Value Constructor added in grammar.Galina Shalygina2017-06-291-0/+128
TVC can be used in UNION-statement, in view and in subquery. Files where TVC is defined and its methods are stored added. Methods exec and prepare for TVC added. Tests for TVC added.