summaryrefslogtreecommitdiff
path: root/sql/item.h
Commit message (Collapse)AuthorAgeFilesLines
* post-merge: -Werror fixes in 10.3Sergei Golubchik2019-03-291-1/+1
|
* Merge 10.2 into 10.3Marko Mäkelä2019-03-261-0/+7
|\
| * Merge 10.1 into 10.2Marko Mäkelä2019-03-261-0/+7
| |\
| | * MDEV-18968 Both (WHERE 0.1) and (WHERE NOT 0.1) return empty setAlexander Barkov2019-03-261-0/+7
| | |
| * | Backporting MDEV-15597 Add class Load_data_outvar and avoid using ↵Alexander Barkov2019-02-231-1/+44
| | | | | | | | | | | | | | | | | | Item::STRING_ITEM for Item_user_var_as_out_param detection This is a part of "MDEV-18045 Backporting the MDEV-15497 changes to 10.2 branch"
* | | MDEV-19008 Slow EXPLAIN SELECT ... WHERE col IN (const1,const2,(subquery))Alexander Barkov2019-03-221-0/+10
| | |
* | | MDEV-18150 Assertion `decimals_to_set <= 38' failed in ↵Alexander Barkov2019-01-101-14/+0
| | | | | | | | | | | | Item_func_round::fix_length_and_dec_decimal
* | | Merge 10.2 into 10.3Marko Mäkelä2018-12-181-0/+1
|\ \ \ | |/ /
| * | MDEV-14576 Include full name of object in message about incorrect value for ↵Alexey Botchkov2018-12-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | column. The error message modified. Then the TABLE_SHARE::error_table_name() implementation taken from 10.3, to be used as a name of the table in this message.
* | | Merge 10.2 into 10.3Marko Mäkelä2018-11-191-0/+6
|\ \ \ | |/ /
| * | Merge branch '10.1' into 10.2Oleksandr Byelkin2018-11-151-0/+4
| |\ \ | | |/
| | * Merge branch '10.0' into 10.1Oleksandr Byelkin2018-11-151-0/+4
| | |\
| | | * Merge branch '5.5' into 10.0Oleksandr Byelkin2018-11-151-0/+4
| | | |\
| | | | * Backport for "MDEV-17698 MEMORY engine performance regression"Alexander Barkov2018-11-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, backporting a part of: MDEV-11485 Split Item_func_between::val_int() into virtual methods in Type_handler for easier merge to 10.3.
| * | | | MDEV-16217: Assertion `!table || (!table->read_set || ↵bb-10.2-MDEV-16217Oleksandr Byelkin2018-11-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bitmap_is_set(table->read_set, field_index))' failed in Field_num::get_date - clean up DEFAULT() to work only with default value and correctly print itself. - fix of DBUG_ASSERT about fields read/write - fix of field marking for write based really on the thd->mark_used_columns flag
| * | | | MDEV-17574 SIGSEGV or Assertion `producing_item != __null' inIgor Babaev2018-11-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Item_direct_view_ref::derived_field_transformer_for_where upon updating a view The condition pushed into a materialized derived / view mast be adjusted for the new context: its column references must be substituted for references to the columns of the underlying tables if the condition is pushed into WHERE. The substitution is performed by the 'transform' method. If the materialized derived is used in a mergeable view then the references to the columns of the view are represented by Item_direct_view_ref objects. The transform method first processes the item wrapped in such an object and only after this it transforms the object itself. The transformation procedure of an Item_direct_view_ref object has to know whether the item it wraps has been substituted. If so the procedure does not have to do anything. In the code before this patch it was not possible for the transformation procedure used by an Item_direct_view_ref object to find out whether a substitution for the wrapped item had happened.
* | | | | MDEV-17698 MEMORY engine performance regressionAlexander Barkov2018-11-141-0/+4
| | | | |
* | | | | MDEV-17411 Wrong WHERE optimization with simple CASE and searched CASEAlexander Barkov2018-10-111-0/+9
| | | | |
* | | | | Merge branch '10.2' into 10.3Sergei Golubchik2018-09-281-109/+12
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.1' into 10.2Sergei Golubchik2018-09-241-99/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.0' into 10.1Sergei Golubchik2018-09-231-91/+1
| | |\ \ \ | | | |/ /
| | | * | Merge remote-tracking branch 'origin/5.5' into bb-10.0-barbb-10.0-barAlexander Barkov2018-09-211-1/+1
| | | |\ \ | | | | |/
| | | | * Fixing the comment not to mention the removed class Item_copy_int.Alexander Barkov2018-09-211-1/+1
| | | | |
| | | * | Merge remote-tracking branch 'origin/5.5' into 10.0Alexander Barkov2018-09-211-90/+0
| | | |\ \ | | | | |/
| | | | * MDEV-17250 Remove unused Item_copy_xxxAlexander Barkov2018-09-201-90/+0
| | | | |
| | | | * MDEV-16820 Lost 'Impossible where' from query with inexpensive subqueryIgor Babaev2018-07-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes another problem introduced by the patch for mdev-4817. The latter changed Item_cond::fix_fields() in such a way that it could call the virtual method is_expensive(). With the first its call the method saves the result in Item::is_expensive_cache. For all next calls the method returns the result from this cache. So if the item once was determined as expensive the method always returns true. For subqueries it's not good, because non-optimized subqueries always is considered as expensive. It means that the cache should be invalidated after the call of optimize_constant_subqueries().
| | | * | MDEV-16820 Lost 'Impossible where' from query with inexpensive subqueryIgor Babaev2018-07-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes another problem introduced by the patch for mdev-4817. The latter changed Item_cond::fix_fields() in such a way that it could call the virtual method is_expensive(). With the first its call the method saves the result in Item::is_expensive_cache. For all next calls the method returns the result from this cache. So if the item once was determined as expensive the method always returns true. For subqueries it's not good, because non-optimized subqueries always is considered as expensive. It means that the cache should be invalidated after the call of optimize_constant_subqueries().
| | * | | MDEV-16820 Lost 'Impossible where' from query with inexpensive subqueryIgor Babaev2018-07-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes another problem introduced by the patch for mdev-4817. The latter changed Item_cond::fix_fields() in such a way that it could call the virtual method is_expensive(). With the first its call the method saves the result in Item::is_expensive_cache. For all next calls the method returns the result from this cache. So if the item once was determined as expensive the method always returns true. For subqueries it's not good, because non-optimized subqueries always is considered as expensive. It means that the cache should be invalidated after the call of optimize_constant_subqueries().
| * | | | MDEV-17154 Multiple selects from parametrized CTE fails with syntax errorIgor Babaev2018-09-141-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fills a serious flaw in the implementation of common table expressions. Before this patch an attempt to prepare a statement from a query with a parameter marker in a CTE that was used more than once in the query ended up with a bogus error message. Similarly if a statement in a stored procedure contained a CTE whose specification used a local variables and this CTE was referred to more than once in the statement then the server failed to execute the stored procedure returning a bogus error message on a non-existing field. The problems appeared due to incorrect handling of parameter markers / local variables in CTEs that were referred more than once. This patch fixes the problems by differentiating between the original occurrences of a parameter marker / local variable used in the specification of a CTE and the corresponding occurrences used in copies of this specification. These copies are substituted instead of non-first references to the CTE. The idea of the fix and even some code were taken from the MySQL implementation of the common table expressions.
* | | | | Merge 10.2 into 10.3Marko Mäkelä2018-07-261-0/+5
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-16820 Lost 'Impossible where' from query with inexpensive subqueryIgor Babaev2018-07-251-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes another problem introduced by the patch for mdev-4817. The latter changed Item_cond::fix_fields() in such a way that it could call the virtual method is_expensive(). With the first its call the method saves the result in Item::is_expensive_cache. For all next calls the method returns the result from this cache. So if the item once was determined as expensive the method always returns true. For subqueries it's not good, because non-optimized subqueries always is considered as expensive. It means that the cache should be invalidated after the call of optimize_constant_subqueries().
| * | | | Merge branch '10.1' into 10.2Sergei Golubchik2018-06-211-0/+7
| |\ \ \ \ | | |/ / /
| | * | | MDEV-16190 Server crashes in Item_null_result::field_type on SELECT with ↵Alexander Barkov2018-06-111-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | time field, ROLLUP and HAVING virtual Item_null_result::get_date() was not overridden. It used the inherited Item::get_date(), which tests field_type(), which in case of Item_null_result calls result_field->field_type(), and result_field is not really always set (e.g. it's not set in the test case from the bug report). Overriding Item_null::get_date() like it's done for other val_xxx() methods. This make the code more symmetric across data types. In the new reduction, get_date() immediately returns NULL without entering into any data type specific code.
* | | | | MDEV-16471 mysqldump throws "Variable 'sql_mode' can't be set to the value ↵Alexander Barkov2018-06-211-1/+7
| | | | | | | | | | | | | | | | | | | | of 'NULL' (1231)"
* | | | | Merge commit '6b8802e8dd5467556a024d807a1df23940b00895' into bb-10.3-fix_len_decbb-10.3-fix_len_decOleksandr Byelkin2018-06-191-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-11071: Assertion `thd->transaction.stmt.is_empty()' failed in ↵Oleksandr Byelkin2018-06-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Locked_tables_list::unlock_locked_table fix_length_and_dec now return result (error/OK)
* | | | | MDEV-16385 ROW SP variable is allowed in unexpected contextAlexander Barkov2018-06-051-4/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem described in the bug report happened because the code did not test check_cols(1) after fix_fields() in a few places. Additionally, fix_fields() could be called multiple times for SP variables, because they are all fixed at a early stage in append_for_log(). Solution: 1. Adding a few helper methods - fix_fields_if_needed() - fix_fields_if_needed_for_scalar() - fix_fields_if_needed_for_bool() - fix_fields_if_needed_for_order_by() and using it in many cases instead of fix_fields() where the "fixed" status is not definitely known to be "false". 2. Adding DBUG_ASSERT(!fixed) into Item_splocal*::fix_fields() to catch double execution. 3. Adding tests. As a good side effect, the patch removes a lot of duplicate code (~60 lines): if (!item->fixed && item->fix_fields(..) && item->check_cols(1)) return true;
* | | | | Addressing Monty's review suggestions for MDEV-11952 Oracle-style packages ↵Alexander Barkov2018-05-211-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (partial) - Using array_elements() instead of a constant to iterate through an array - Adding some comments - Adding new-line function comments - Using STRING_WITH_LEN instead of C_STRING_WITH_LEN
* | | | | MDEV-14520: Custom aggregate functions work incorrectly with WITH ROLLUP clauseVarun Gupta2018-05-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Queries involving rollup need all aggregate function to have copy_or_same function where we create a copy of item_sum items for each sum level. Implemented copy_or_same function for the custom aggregate function class (Item_sum_sp)
* | | | | Merge 10.2 into 10.3Marko Mäkelä2018-05-171-4/+3
|\ \ \ \ \ | |/ / / /
| * | | | cleanup: vcol_in_partition_func_processorSergei Golubchik2018-05-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | MDEV-15576: Server crashed in Cached_item_str::cmp / sortcmp or Assertion ↵Oleksandr Byelkin2018-05-151-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `item->null_value' failed in Type_handler_temporal_result::make_sort_key upon SELECT with NULLIF and ROLLUP Fixed null_value processing and is_null() usage.
* | | | | MDEV-16170 Server crashes in Item_null_result::type_handler on SELECT with ↵Monty2018-05-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ROLLUP Problem was that I in a previous patch enabled ifdef:ed code intended for 10.3 but that never worked. Reverted to original code
* | | | | MDEV-16094 Crash when using AS OF with a stored functionAlexander Barkov2018-05-151-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-16100 FOR SYSTEM_TIME erroneously resolves string user variables as transaction IDs Problem: Vers_history_point::resolve_unit() tested item->result_type() before item->fix_fields() was called. - Item_func_get_user_var::result_type() returned REAL_RESULT by default. This caused MDEV-16100. - Item_func_sp::result_type() crashed on assert. This caused MDEV-16094 Changes: 1. Adding item->fix_fields() into Vers_history_point::resolve_unit() before using data type specific properties of the history point expression. 2. Adding a new virtual method Type_handler::Vers_history_point_resolve_unit() 3. Implementing type-specific Type_handler_xxx::Type_handler::Vers_history_point_resolve_unit() in the way to: a. resolve temporal and general purpose string types to TIMESTAMP b. resolve BIT and general purpose INT types to TRANSACTION c. disallow use of non-relevant data type expressions in FOR SYSTEM_TIME Note, DOUBLE and DECIMAL data types are disallowed intentionally. - DOUBLE does not have enough precision to hold huge BIGINT UNSIGNED values - DECIMAL rounds on conversion to INT Both lack of precision and rounding might potentionally lead to very unpredictable results when a wrong transaction ID would be chosen. If one really wants dangerous use of DOUBLE and DECIMAL, explicit CAST can be used: FOR SYSTEM_TIME AS OF CAST(double_or_decimal AS UNSIGNED) QQ: perhaps DECIMAL(N,0) could still be allowed. 4. Adding a new virtual method Item::type_handler_for_system_time(), to make HEX hybrids and bit literals work as TRANSACTION rather than TIMESTAMP. 5. sql_yacc.yy: replacing the rule temporal_literal to "TIMESTAMP TEXT_STRING". Other temporal literals now resolve to TIMESTAMP through the new Type_handler methods. No special grammar needed. This removed a few shift/resolve conflicts. (TIMESTAMP related conflicts in "history_point:" will be removed separately) 6. Removing the "timestamp_only" parameter from vers_select_conds_t::resolve_units() and Vers_history_point::resolve_unit(). It was a hint telling that a table did not have any TRANSACTION-aware system time columns, so it's OK to resolve to TIMESTAMP in case of uncertainty. In the new reduction it works as follows: - the decision between TIMESTAMP and TRANSACTION is first made based only on the expression data type only - then, in case if the expression resolved to TRANSACTION, the table is checked if TRANSACTION-aware columns really exist. This way is safer against possible ALTER TABLE statements changing ROW START and ROW END columns from "BIGINT UNSIGNED" to "TIMESTAMP(x)" or the other way around.
* | | | | Merge branch '10.2' into 10.3Sergei Golubchik2018-05-111-0/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.1' into 10.2Sergei Golubchik2018-05-101-0/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.0' into 10.1Sergei Golubchik2018-05-051-0/+1
| | |\ \ \ | | | |/ /
| | | * | Merge branch '5.5' into 10.0Sergei Golubchik2018-04-291-0/+1
| | | |\ \ | | | | |/
| | | | * MDEV-15035 Wrong results when calling a stored procedureIgor Babaev2018-04-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | Add likely/unlikely to speed up executionMonty2018-05-071-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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()