summaryrefslogtreecommitdiff
path: root/sql/item.h
Commit message (Collapse)AuthorAgeFilesLines
* This is the consolidated patch for mdev-8646:bb-10.2-mdev8646Igor Babaev2016-02-091-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | "Re-factor the code for post-join operations". The patch mainly contains the code ported from mysql-5.6 and created for two essential architectural changes: 1. WL#5558: Resolve ORDER BY execution method at the optimization stage 2. WL#6071: Inline tmp tables into the nested loops algorithm The first task was implemented for mysql-5.6 by Ole John Aske. It allows to make all decisions on ORDER BY operation at the optimization stage. The second task implemented for mysql-5.6 by Evgeny Potemkin adds JOIN_TAB nodes for post-join operations that require temporary tables. It allows to execute these operations within the nested loops algorithm that used to be used before this task only for join queries. Besides these task moves all planning on the execution of these operations from the execution phase to the optimization phase. Some other re-factoring changes of mysql-5.6 were pulled in, mainly because it was easier to pull them in than roll them back. In particular all changes concerning Ref_ptr_array were incorporated. The port required some changes in the MariaDB code that concerned the functionality of EXPLAIN and ANALYZE. This was done mainly by Sergey Petrunia.
* MDEV-9407 Illegal mix of collation when using GROUP_CONCAT in a VIEWAlexander Barkov2016-01-161-10/+20
| | | | | | | | | | | | | | | | | | MDEV-9408 CREATE TABLE SELECT MAX(int_column) creates different columns for table vs view There were three almost identical pieces of the code: - Field *Item_func::tmp_table_field(); - Field *Item_sum::create_tmp_field(); - Field *create_tmp_field_from_item(); with a difference in very small details (hence the bugs): Only Item_func::tmp_table_field() was correct, the other two were not. Removing the two incorrect pieces of the redundant code. Joining these three functions/methods into a single virtual method Item::create_tmp_field(). Additionally, moving Item::make_string_field() and Item::tmp_table_field_from_field_type() from the public into the protected section of the class declaration, as they are now not needed outside of Item.
* MDEV-9220 Split filesort.cc:make_sortkey() and filesort.cc::sortlength() ↵Alexander Barkov2016-01-121-0/+11
| | | | into virtual methods in Type_handler
* Merge remote-tracking branch 'origin/10.1' into 10.2Alexander Barkov2015-12-291-0/+3
|\
| * MDEV-8605 MariaDB not use DEFAULT value even when inserted NULL for NOT ↵Sergei Golubchik2015-12-211-0/+3
| | | | | | | | | | | | | | | | | | NULLABLE column NOT NULL constraint must be checked *after* the BEFORE triggers. That is for INSERT and UPDATE statements even NOT NULL fields must be able to store a NULL temporarily at least while BEFORE INSERT/UPDATE triggers are running.
* | Changing the parameter of Field::eq_def() from "Field *" to "const Field *"Alexander Barkov2015-12-241-1/+1
| |
* | MDEV-9316 Add Field::store_hex_hybrid()Alexander Barkov2015-12-231-2/+11
| |
* | MDEV-9238 Wrap create_virtual_tmp_table() into a class, split into different ↵Alexander Barkov2015-12-041-0/+11
| | | | | | | | steps
* | MDEV-9215 Detect cmp_type() and result_type() from field_type()Alexander Barkov2015-12-031-13/+12
| | | | | | | | Part8: Derive Item_copy from Type_handler_hybrid_field_type
* | MDEV-9215 Detect cmp_type() and result_type() from field_type()Alexander Barkov2015-12-031-6/+15
| | | | | | | | Part7: Derive Item_cache from Type_handler_hybrid_field_type
* | MDEV-9215 Detect cmp_type() and result_type() from field_type()Alexander Barkov2015-12-031-4/+23
| | | | | | | | Part6: Deriving Item_type_holder from Type_handler_hybrid_real_field_type
* | MDEV-9215 Detect cmp_type() and result_type() from field_type()Alexander Barkov2015-12-021-15/+19
| | | | | | | | Part5: Derive Item_param from Type_handler_hybrid_field_type
* | - MDEV-9215 Detect cmp_type() and result_type() from field_type()Alexander Barkov2015-12-021-11/+8
| | | | | | | | Part3: Deriving Item_splocal from Type_handler_hybrid_field_type
* | MDEV-9215 Detect cmp_type() and result_type() from field_type()Alexander Barkov2015-12-011-1/+0
| | | | | | | | | | Part2: deriving Item_sum_sum from Type_handler_hybrid_field_type, removing "Item_result Item_sum_sum::hybrid_type".
* | MDEV-9215 Detect cmp_type() and result_type() from field_type()Alexander Barkov2015-12-011-3/+14
| | | | | | | | (A dependency task for MDEV-4912 Add a plugin to field types)
* | MDEV-8715 - Obsolete sql_alloc() in favor of THD::alloc() and thd_alloc()Sergey Vojtovich2015-11-261-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The following left in semi-improved state to keep patch size reasonable: - Field operator new: left thd_alloc(current_thd) - Sql_alloc operator new: left thd_alloc(thd_get_current_thd()) - Item_args constructors: left thd_alloc(thd) - Item_func_interval::fix_length_and_dec(): no THD arg, have to call current_thd - Item_func_dyncol_exists::val_int(): same - Item_dyncol_get::val_str(): same - Item_dyncol_get::val_int(): same - Item_dyncol_get::val_real(): same - Item_dyncol_get::val_decimal(): same - Item_singlerow_subselect::fix_length_and_dec(): same
* | MDEV-8716 - Obsolete sql_calloc() in favor of THD::calloc() and thd_calloc()Sergey Vojtovich2015-11-261-3/+2
| |
* | MDEV-8718 - Obsolete sql_strmake() in favor of THD::strmake() and thd_strmake()Sergey Vojtovich2015-11-261-25/+28
|/
* Merge branch '10.0' into 10.1Sergei Golubchik2015-11-191-1/+2
|\
| * MDEV-8525 mariadb 10.0.20 crashing when data is read by Kodi media center ↵Oleksandr Byelkin2015-10-281-0/+2
| | | | | | | | | | | | (http://kodi.tv). Item_direct_view_ref maintains its own item_const() method so should use it when asked of temporary table field to be in sync with it.
| * remove unneded #include's that had a dubious explanationSergei Golubchik2015-10-241-1/+0
| |
* | MDEV-7949: Item_field::used_tables() takes 0.29% in OLTP ROOleksandr Byelkin2015-10-291-1/+6
| | | | | | | | small sixes of used_tables() usage
* | Removing Used_tables_and_const_cache from "class udf_handler".Alexander Barkov2015-10-141-4/+0
| | | | | | | | | | | | | | It was used only temporary, during udf_handler::fix_fields() time, and then copied to the owner Item_func_or_sum object. Changing the code to use the Used_tables_and_const_cache part of the owner Item_sum_or_func object directly.
* | Moving Used_tables_and_const_chache from Item_func to Item_func_or_sumAlexander Barkov2015-10-121-2/+7
| | | | | | | | | | and thus reusing Used_tables_and_const_cache for Item_sum instead of declaring the same members inside Item_sum.
* | MDEV-8921 Wrong result for CAST(AVG(double_column) AS SIGNED)Alexander Barkov2015-10-081-0/+1
| |
* | MDEV-8912 Wrong metadata or type for @c:=string_or_blob_fieldAlexander Barkov2015-10-071-2/+8
| |
* | MDEV-8910 Wrong metadata or field type for MAX(COALESCE(string_field))Alexander Barkov2015-10-071-1/+4
| |
* | Combined fix for MDEV-7267 and MDEV-8864Sergei Petrunia2015-10-061-0/+41
| | | | | | | | | | | | | | | | | | | | | | The problem was that GROUP BY code created Item_field objects that referred to fields in the temp. tables used for GROUP BY. Item_ref and set_items_ref_array() call caused pointers to temp. table fields to occur in many places. This patch introduces Item_temptable_field, which can handle item->print() calls made after the underlying table is freed.
* | A clean-up for MDEV-7950:Alexander Barkov2015-10-041-0/+2
| | | | | | | | | | | | | | | | | | | | - Turning get_mm_tree_for_const() from a static function into a protected method in Item. - Adding a new class Item_bool_func2_with_rev, for the functions and operators that have a reverse function and can use the range optimizer for to optimize "value OP field" as "field REV_OP value". Deriving Item_bool_rowready_func2 and Item_funt_spatial_rel from the new class. - Removing Item_bool_func2::have_rev_func().
* | MDEV-8865 Wrong field type or metadata for COALESCE(signed_int_column, ↵Alexander Barkov2015-09-301-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unsigned_int_column) Item_func_hybrid_field_type did not return correct field_type(), cmp_type() and result_type() in some cases, because cached_result_type and cached_field_type were set in independent pieces of the code and did not properly match to each other. Fix: - Removing Item_func_hybrid_result_type - Deriving Item_func_hybrid_field_type directly from Item_func - Introducing a new class Type_handler which guarantees that field_type(), cmp_type() and result_type() are always properly synchronized and using the new class in Item_func_hybrid_field_type.
* | MDEV-8806 Numeric CAST produce different warnings for strings literals vs ↵Alexander Barkov2015-09-251-9/+34
| | | | | | | | functions
* | Changing a number of functions to aggregate argument character setsAlexander Barkov2015-09-211-34/+86
| | | | | | | | | | and collations from the global name space into private and protected methods in Item_func_or_sum.
* | Moving Item_args::arg_count from "public" to "protected".Alexander Barkov2015-09-211-1/+1
| |
* | Removing global function agg_item_charsets_for_string_result().Alexander Barkov2015-09-211-10/+33
| | | | | | | | | | | | Moving agg_arg_charsets_for_string_result() and agg_arg_charsets_for_string_result_with_comparison() inside "protected" section in Item_func_or_sum.
* | MDEV-8816 Equal field propagation is not applied for WHERE ↵Alexander Barkov2015-09-181-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | varbinary_column>=_utf8'a' COLLATE utf8_general_ci AND varbinary_column='A'; 1. Removing the legacy code that disabled equal field propagation in cases when comparison is done as VARBINARY. This is now correctly handled by the new propagation code in Item_xxx::propagate_equal_fields() and Field_str::can_be_substituted_to_equal_item (the bug fix). 2. Also, removing legacy (pre-MySQL-4.1) Arg_comparator methods compare_binary_string() and compare_e_binary_string(), as VARBINARY comparison is correcty handled in compare_string() and compare_e_string() by the corresponding VARBINARY collation handler implemented in my_charset_bin. (not really a part of the bug fix)
* | MDEV-8793 Wrong result set for SELECT ...Alexander Barkov2015-09-181-1/+44
| | | | | | | | | | | | WHERE COALESCE(time_column)=TIME('00:00:00') AND COALESCE(time_column)=DATE('2015-09-11') MDEV-8814 Wrong result for WHERE datetime_column > TIME('00:00:00')
* | MDEV-8466 CAST works differently for DECIMAL/INT vs DOUBLE for empty stringsAlexander Barkov2015-09-171-7/+0
| | | | | | | | MDEV-8468 CAST and INSERT work differently for DECIMAL/INT vs DOUBLE for a string with trailing spaces
* | MDEV-8795 Equal expression propagation does not work for temporal literalsAlexander Barkov2015-09-131-0/+3
| |
* | MDEV-8740 Wrong result for SELECT..WHERE year_field=10 AND ↵Alexander Barkov2015-09-101-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NULLIF(year_field,2011.1)='2011' MDEV-8754 Wrong result for SELECT..WHERE year_field=2020 AND NULLIF(year_field,2010)='2020' Problems: 1. Item_func_nullif stored a copy of args[0] in a private member m_args0_copy, which was invisible for the inherited Item_func menthods, like update_used_tables(). As a result, after equal field propagation things like Item_func_nullif::const_item() could return wrong result and a non-constant NULLIF() was erroneously treated as a constant at optimize_cond() time. Solution: removing m_args0_copy and storing the return value item in args[2] instead. 2. Equal field propagation did not work well for Item_fun_nullif. Solution: using ANY_SUBST for args[0] and args[1], as they are in comparison, and IDENTITY_SUBST for args[2], as it's not in comparison.
* | MDEV-8706 Wrong result for SELECT..WHERE time_column=TIMESTAMP'2015-08-30 ↵Alexander Barkov2015-09-091-0/+56
| | | | | | | | 00:00:00' AND time_column='00:00:00'
* | MDEV-8766 Wrong result for SELECT..WHERE LENGTH(time_column)=8 AND ↵Alexander Barkov2015-09-081-0/+33
| | | | | | | | time_column=TIMESTAMP'2001-01-01 10:20:31'
* | MDEV-8729 Wrong result for SELECT..WHERE HEX(enum_column)='61' AND ↵Alexander Barkov2015-09-061-67/+1
| | | | | | | | enum_column='a '
* | A clean-up after the patch for MDEV-8747 and MDEV-8749:Alexander Barkov2015-09-061-17/+16
| | | | | | | | | | | | | | | | removing IMPOSSIBLE_RESULT from Item_result, as it's not needed any more. The fact that an Item is not in a comparison context is now always designated by IDENTITY_SUBST in Subst_constraint. Previously IMPOSSIBLE_RESULT and IDENTITY_SUBST co-existed but actually meant the same thing.
* | MDEV-8747 Wrong result for SELECT..WHERE derived_table_column='a' AND ↵Alexander Barkov2015-09-061-19/+30
| | | | | | | | | | | | derived_table_column<>_latin1'A' COLLATE latin1_bin MDEV-8749 Wrong result for SELECT..WHERE derived_table_enum_column='number' AND derived_table_enum_column OP number
* | Merge branch '10.0' into 10.1Sergei Golubchik2015-09-031-3/+4
|\ \ | |/ | | | | | | referenced_by_foreign_key2(), needed for InnoDB to compile, was taken from 10.0-galera
| * Merge commit '96badb16afcf' into 10.0Jan Lindström2015-08-031-3/+4
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: client/mysql_upgrade.c mysql-test/r/func_misc.result mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result mysql-test/suite/innodb/r/innodb-fk.result mysql-test/t/subselect_sj_mat.test sql/item.cc sql/item_func.cc sql/log.cc sql/log_event.cc sql/rpl_utility.cc sql/slave.cc sql/sql_class.cc sql/sql_class.h sql/sql_select.cc storage/innobase/dict/dict0crea.c storage/innobase/dict/dict0dict.c storage/innobase/handler/ha_innodb.cc storage/xtradb/dict/dict0crea.c storage/xtradb/dict/dict0dict.c storage/xtradb/handler/ha_innodb.cc vio/viosslfactories.c
| | * MDEV-7810 Wrong result on execution of a query as a PS (both 1st and further ↵Sergei Golubchik2015-07-311-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | executions) Alternative fix that doesn't cause view.test crash in --ps: Remember when Item_ref was fixed right in the constructor and did not have a full Item_ref::fix_fields() call. Later in PS/SP, after Item_ref::cleanup, we use this knowledge to avoid doing full fix_fields() for items that were never supposed to be fix_field'ed. Simplify the test case.
| | * Fixed crashing bug when using ONLY_FULL_GROUP_BY in a stored ↵Monty2015-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | procedure/trigger that is repeatedly executed. This is MDEV-7601, including it's sub tasks MDEV-7594, MDEV-7555, MDEV-7590, MDEV-7581, MDEV-7589 The problem was that select_lex->non_agg_fields was not properly reset for re-execution and this caused an overwrite of a random memory position. The fix was move non_agg_fields from select_lext to JOIN, which is properly reset.
* | | MDEV-6152: Remove calls to current_thd while creating ItemMonty2015-09-011-2/+2
| | | | | | | | | | | | | | | Part 5: Removing calls to current_thd in net_read calls, creating fields, query_cache, acl and some other places where thd was available
* | | MDEV-8707 Wrong result forAlexander Barkov2015-08-311-1/+8
| | | | | | | | | | | | SELECT..WHERE varchar_column=DATE'2001-01-01' AND varchar_column='2001-01-01'