summaryrefslogtreecommitdiff
path: root/sql/item.cc
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-16386: Wrong result when pushdown into the HAVING clause of theGalina Shalygina2018-06-141-4/+7
| | | | | | | | | | | | materialized derived table/view that uses aliases is done The problem appears when a column alias inside the materialized derived table/view t1 definition coincides with the column name used in the GROUP BY clause of t1. If the condition that can be pushed into t1 uses that ambiguous column name this column is determined as a column that is used in the GROUP BY clause instead of the alias used in the projection list of t1. That causes wrong result. To prevent it resolve_ref_in_select_and_group() was changed.
* Merge branch '10.1' into 10.2Sergei Golubchik2018-05-201-4/+4
|\
| * Merge branch '10.0' into 10.1Sergei Golubchik2018-05-191-4/+4
| |\
| | * Merge branch '5.5' into 10.0Sergei Golubchik2018-05-191-4/+4
| | |\
| | | * MDEV-15318 CREATE .. SELECT VALUES produces invalid table structureSergei Golubchik2018-05-171-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | When Item_insert_value needs a dummy field, use zero-length Field_string, not Field_null. The latter isn't compatible with CREATE ... SELECT.
* | | | MDEV-14750 Valgrind Invalid read, ASAN heap-use-after-free in ↵Sergei Golubchik2018-05-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Item_ident::print upon SHOW CREATE on partitioned table items in the partitioning function were taking the table name from the table's field (in set_field(from_field) in Item_field::fix_fields) and field's table_name is TABLE::alias. But alias is changed for every statement, and can be realloced if next statement uses a longer alias. But partitioning items are fixed once and live as long as the TABLE does. So if an alias is realloced, pointers to the old alias string will become invalid. Fix partitioning item table_name to point to the actual table name instead.
* | | | cleanup: vcol_in_partition_func_processorSergei Golubchik2018-05-151-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | rename to post_fix_fields_part_expr_processor() because it's only used after fix_fields in fix_fields_part_func() and can be used for various post-fix_fields fixups
* | | | Merge branch '10.1' into 10.2Sergei Golubchik2018-05-101-1/+9
|\ \ \ \ | |/ / /
| * | | Merge branch '10.0' into 10.1Sergei Golubchik2018-05-051-1/+9
| |\ \ \ | | |/ /
| | * | Merge branch '5.5' into 10.0Sergei Golubchik2018-04-291-0/+7
| | |\ \ | | | |/
| | | * MDEV-15035 Wrong results when calling a stored procedureIgor Babaev2018-04-251-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | multiple times with different arguments. If the ON expression of an outer join is an OR formula with one of the disjunct being a constant formula then the expression cannot be null-rejected if the constant formula is true. Otherwise it can be null-rejected and if so the outer join can be converted into inner join. This optimization was added in the patch for mdev-4817. Yet the code had a defect: if the query was used in a stored procedure with parameters and the constant item contained some of them then the value of this constant item depended on the values of the parameters. With some parameters it may be true, for others not. The validity of conversion to inner join is checked only once and it happens only for the first call of procedure. So if the parameters in the first call allowed the conversion it was done and next calls used the transformed query though there could be calls whose parameters made the conversion invalid. Fixed by cheking whether the constant disjunct in the ON expression originally contained an SP parameter. If so the expression is not considered as null-rejected. For this check a new item's attribute was intruduced: Item::with_param. It is calculated for each item by fix fields() functions. Also moved the call of optimize_constant_subqueries() in JOIN::optimize after the call of simplify_joins(). The reason for this is that after the optimization introduced by the patch for mdev-4817 simplify_joins() can use the results of execution of non-expensive constant subqueries and this is not valid.
* | | | Fixed mdev-15765 BETWEEN not working in certain casesIgor Babaev2018-04-101-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | The implementations of the convert_to_basic_const_item() virtual function for the Item_cache classes should call cache_value() when value_cached == NULL.
* | | | MDEV-15570 Assertion `Item_cache_temporal::field_type() != MYSQL_TYPE_TIME' ↵Sergei Golubchik2018-03-231-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | failed in Item_cache_temporal::val_datetime_packed remove an assert. TIME value can be used (and cached) in a datetime context
* | | | Merge branch '10.1' into 10.2Vicențiu Ciorbaru2018-03-211-6/+8
|\ \ \ \ | |/ / /
| * | | MDEV-15321:different results when using value of ↵Varun Gupta2018-03-161-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | optimizer_use_condition_selectivity=4 and =1 To disallow equality propagation for DATETIME with non-zero YYYYMMDD part we were setting null_value to true. This caused issues when we were calculating selectivity for a condition as this returned IMPOSSIBLE WHERE. The issue is resolved by not setting null_value to true for DATETIME with non-zero YYYYMMDD.
* | | | MDEV-11839 move value caching from get_datetime_value to fix_fields timeSergei Golubchik2018-03-141-18/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor get_datetime_value() not to create Item_cache_temporal(), but do it always in ::fix_fields() or ::fix_length_and_dec(). Creating items at the execution time doesn't work very well with virtual columns and check constraints that are fixed and executed in different THDs.
* | | | bugfix: Item_cache_temporal::convert_to_basic_const_item assumed DATETIMESergei Golubchik2018-03-141-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | while it should look at the actual field_type() and use get_date() or get_time() as appropriate. test case is in the following commit.
* | | | bugfix: Item_cache_temporal::get_date() didn't set null_valueSergei Golubchik2018-03-141-1/+1
| | | |
* | | | cleanup: extend Item_cache::get_cache() to accept f_typeSergei Golubchik2018-03-141-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | Do not assume that it's always item->field_type() - this is not the case in temporal comparisons (e.g. when comparing DATETIME column with a TIME literal).
* | | | cleanup: add Item::convert_time_to_datetime() helperSergei Golubchik2018-03-141-7/+3
| | | | | | | | | | | | | | | | will be used in following commits
* | | | MDEV-15289 Binding an out-of-range DATETIME value in binary protocol breaks ↵Alexander Barkov2018-02-161-1/+1
| | | | | | | | | | | | | | | | replication
* | | | MDEV-13508 ALTER TABLE that renames columns and CHECK constraintsMonty2018-02-101-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | Fixed by adding Item::rename_fields_processor Signed-off-by: Monty <monty@mariadb.org>
* | | | Merge branch 'github/10.1' into 10.2Sergei Golubchik2018-02-061-4/+4
|\ \ \ \ | |/ / /
| * | | Merge branch 'github/10.0' into 10.1Sergei Golubchik2018-02-021-4/+4
| |\ \ \ | | |/ /
| | * | Merge remote-tracking branch '5.5' into 10.0Vicențiu Ciorbaru2018-01-241-3/+3
| | |\ \ | | | |/
| | | * MDEV-14786: Server crashes in Item_cond::transform on 2nd execution of SP ↵Oleksandr Byelkin2018-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | querying from a view MDEV-14957: JOIN::prepare gets unusable "conds" as argument Do not touch merged derived (it is irreversible) Fix first argument of in_optimizer for calls possible before fix_fields()
| | | * Merge branch 'mysql/5.5' into 5.5Sergei Golubchik2018-01-181-2/+2
| | | |\
| | | | * Bug #26881946: INCORRECT BEHAVIOR WITH "VALUES"Sreeharsha Ramanavarapu2017-11-161-13/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue: ------ VALUES doesn't have a type() function and is considered a Item_field. Solution for 5.7: ----------------- Add a new type() function for Item_values_insert. On 8.0 and trunk it was fixed by Mithun's Bug#19601973. Solution for 5.6: ----------------- Additionally Bug#17458914 is backported. This will address the problem of using VALUES() in INSERT ... ON DUPLICATE KEY UPDATE. Create a field object only if it is in the UPDATE clause, else return a NULL item. This will also address the problems mentioned in Bug#14789787 and Bug#16756402. Solution for 5.5: ----------------- As mentioned above Bug#17458914 is backported. Additionally Bug#14786324 is also backported. When VALUES() is detected outside its meaningful place, it should be treated as NULL and is thus replaced with a Field_null object, with the same name as the original field. Fields with type NULL are generally not handled well inside the server (e.g Innodb will not accept them and it is impossible to create them in regular tables). So create a new const NULL item instead.
* | | | | MDEV-15133: array bound (bulk) parameters of NULL propagate on next rowsOleksandr Byelkin2018-01-311-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Setting non_null value drops null_value flag. Part 1 of 3. Part 2 will be for 10.3 including change of ps.test results. Part 3 is test for Connector C.
* | | | | MDEV-15057 Crash when using an unknown identifier as an SP parameterMonty2018-01-241-13/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It crashed because we accessed lex->current_select when it was a NULL, which is the case for SP parameters or local variables.
* | | | | Merge remote-tracking branch 'origin/10.1' into 10.2Vicențiu Ciorbaru2017-12-221-1/+2
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.0' into 10.1Vicențiu Ciorbaru2017-12-201-1/+2
| |\ \ \ \ | | |/ / /
| | * | | Merge remote-tracking branch '5.5' into 10.0Vicențiu Ciorbaru2017-12-201-1/+2
| | |\ \ \ | | | |/ /
| | | * | Revert "Remove use of volatile in stored_field_cmp_to_item"Vicențiu Ciorbaru2017-12-061-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 7603463a46b288c1b5630348e36c622e4c2abb09. The commit itself is fine, however when disabling volatile, compiler optimizations mess up our double results due to precision differences. Revert the patch till a proper solution is found.
| | | * | Remove use of volatile in stored_field_cmp_to_itemDaniel Black2017-12-051-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was added in c79641594348 but would hurt all other compilers because of Visual Studio. Hopefully this has been fixed now. Signed-off-by: Daniel Black <daniel@linux.vnet.ibm.com>
| | | * | Fixed bug MDEV-14368 Improper error for a grouping query thatIgor Babaev2017-11-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | uses alias in HAVING when sql_mode = 'ONLY_FULL_GROUP_BY' This patch corrects the patch for bug#18739: non-standard HAVING extension was allowed in strict ANSI sql mode added in 2006 by commit 4b7c4cd27f68b9aac1970b9f21c50d4eee35df7d. As a result of incompleteness of the fix in the above commit if a query with GROUP BY contained an aggregate function with an alias and this alias was used in the HAVING clause of the query the server reported an error when sql_mode was set to 'ONLY_FULL_GROUP_BY'.
* | | | | MDEV-14613: Assertion `fixed == 0' failed in Item_func::fix_fieldsOleksandr Byelkin2017-12-201-2/+4
| | | | | | | | | | | | | | | | | | | | fix_fields calls fixed.
* | | | | MDEV-14435 Different UNSIGNED flag of out user variable for YEAR parameter ↵Alexander Barkov2017-11-181-0/+1
| | | | | | | | | | | | | | | | | | | | for direct vs prepared CALL
* | | | | MDEV-14434 Wrong result for CHARSET(CONCAT(?,const))Alexander Barkov2017-11-181-0/+5
| | | | |
* | | | | Merge remote-tracking branch 'origin/10.1' into 10.2Alexander Barkov2017-11-091-5/+20
|\ \ \ \ \ | |/ / / /
| * | | | Merge remote-tracking branch 'origin/10.0' into 10.1Alexander Barkov2017-11-091-5/+20
| |\ \ \ \ | | |/ / /
| | * | | MDEV-14164: Unknown column error when adding aggregate to function in oracle ↵Oleksandr Byelkin2017-11-091-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 branch '10.1' into 10.2Sergei Golubchik2017-10-241-5/+11
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.0' into 10.1Sergei Golubchik2017-10-221-5/+11
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '5.5' into 10.0Sergei Golubchik2017-10-181-4/+8
| | |\ \ \ | | | |/ /
| | | * | Bug#26361149 MYSQL SERVER CRASHES AT: COL IN(IFNULL(CONST, COL), ↵mariadb-5.5.58Sergei Golubchik2017-10-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NAME_CONST('NAME', NULL)) based on: commit f7316aa0c9a Author: Ajo Robert <ajo.robert@oracle.com> Date: Thu Aug 24 17:03:21 2017 +0530 Bug#26361149 MYSQL SERVER CRASHES AT: COL IN(IFNULL(CONST, COL), NAME_CONST('NAME', NULL)) Backport of Bug#19143243 fix. NAME_CONST item can return NULL_ITEM type in case of incorrect arguments. NULL_ITEM has special processing in Item_func_in function. In Item_func_in::fix_length_and_dec an array of possible comparators is created. Since NAME_CONST function has NULL_ITEM type, corresponding array element is empty. Then NAME_CONST is wrapped to ITEM_CACHE. ITEM_CACHE can not return proper type(NULL_ITEM) in Item_func_in::val_int(), so the NULL_ITEM is attempted compared with an empty comparator. The fix is to disable the caching of Item_name_const item.
| | | * | MDEV-13459 Warnings, when compiling with gcc-7.xSergei Golubchik2017-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | mostly caused by -Wimplicit-fallthrough
| | | * | Cleanup usage of DBUG_ASSERTS.Oleksandr Byelkin2017-10-131-2/+1
| | | | |
| | | * | MDEV-9208: Function->Function->View = Mysqld segfault (Server crashes in ↵Oleksandr Byelkin2017-10-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dependency_marker::visit_field on 2nd execution with merged subquery) Prevent crossing name resolution border in finding item tables.
| | * | | MDEV-9886 Illegal mix of collations with a view comparing a field to a ↵Alexander Barkov2017-10-071-1/+3
| | | | | | | | | | | | | | | | | | | | binary constant