summaryrefslogtreecommitdiff
path: root/sql/item_row.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-1/+1
|\
| * 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
| | * | | cleanup: extend Item_cache::get_cache() to accept f_typeSergei Golubchik2018-03-141-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* | | | | MDEV-17317 Add THD* parameter into Item::get_date() and stricter data type ↵Alexander Barkov2018-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | control to "fuzzydate"
* | | | | MDEV-16592 Change Item::with_sum_func from a member to a virtual methodAlexander Barkov2018-06-271-1/+5
| | | | |
* | | | | MDEV-16388 Replace member Item::fixed to virtual method is_fixed()Alexander Barkov2018-06-051-5/+7
| | | | |
* | | | | MDEV-16309 Split ::create_tmp_field() into virtual methods in ItemAlexander Barkov2018-05-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Detailed: changes: 1. Moving Field specific code into new methods on Field: - Field *Field::create_tmp_field(...) - virtual void init_for_tmp_table(...) 2. Removing virtual Item::create_tmp_field(). Adding instead a new virtual method Item::create_tmp_field_ex(). Note, a virtual create_tmp_field() still exists, but only for Item_sum. This resembles 10.0 code structure. Perhaps create_tmp_field() should be removed from Item_sum and Item_sum descendants should override create_tmp_field_ex() directly. This can be done in a separate commit. 3. Adding helper classes Tmp_field_src and Tmp_field_param, to make the API for Item::create_tmp_field_ex() smaller and easier to extend in the future. 4. Decomposing the public function create_tmp_field() into virtual implementations for Item and a number of its descendants: - Item_basic_value - Item_sp_variable - Item_name_const - Item_result_field - Item_field - Item_ref - Item_type_holder - Item_row - Item_func_sp - Item_func_user_var - Item_sum - Item_sum_field - Item_proc 5. Adding DBUG_ASSERT-only virtual implementations for Item types that should not appear in create_tmp_table_ex(), for easier debugging: - Item_nodeset_func - Item_nodeset_to_const_comparator - Item_null_result - Item_copy - Item_ident_for_show - Item_user_var_as_out_param 6. Moving public function create_tmp_field_from_field() as a method to Item_field. 7. Removing Item::set_result_field(). It's not needed any more. 8. Cleanup: Removing the enum value "EXPR_CACHE_ITEM", as it's not used for a very long time.
* | | | | MDEV-12387 Push conditions into materialized subqueriesGalina Shalygina2018-05-151-0/+5
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The logic and the implementation scheme are similar with the MDEV-9197 Pushdown conditions into non-mergeable views/derived tables How the push down is made on the example: select * from t1 where a>3 and b>10 and (a,b) in (select x,max(y) from t2 group by x); --> select * from t1 where a>3 and b>10 and (a,b) in (select x,max(y) from t2 where x>3 group by x having max(y)>10); The implementation scheme: 1. Search for the condition cond that depends only on the fields from the left part of the IN subquery (left_part) 2. Find fields F_group in the select of the right part of the IN subquery (right_part) that are used in the GROUP BY 3. Extract from the cond condition cond_where that depends only on the fields from the left_part that stay at the same places in the left_part (have the same indexes) as the F_group fields in the projection of the right_part 4. Transform cond_where so it can be pushed into the WHERE clause of the right_part and delete cond_where from the cond 5. Transform cond so it can be pushed into the HAVING clause of the right_part The optimization is made in the Item_in_subselect::pushdown_cond_for_in_subquery() and is controlled by the variable condition_pushdown_for_subquery. New test file in_subq_cond_pushdown.test is created. There are also some changes made for setup_jtbm_semi_joins(). Now it is decomposed into the 2 procedures: setup_degenerate_jtbm_semi_joins() that is called before optimize_cond() for cond and setup_jtbm_semi_joins() that is called after optimize_cond(). New setup_jtbm_semi_joins() is made in the way so that the result of its work is the same as if it was called before optimize_cond(). The code that is common for pushdown into materialized derived and into materialized IN subqueries is factored out into pushdown_cond_for_derived(), Item_in_subselect::pushdown_cond_for_in_subquery() and st_select_lex::pushdown_cond_into_where_clause().
* | | | Cleanup: renaming methods make_field(Send_field*) to make_send_field(..)Alexander Barkov2018-04-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Renaming methods: - Field::make_field(Send_field*) to make_send_field(..) - Item::make_field(THD *,Send_field *) to make_send_field(..) - Item::init_make_field(Send_field *, enum_field_type) to init_make_send_field(..) These names looked similar to other functions that are used for a very different purpose (creating Field instances): - Public function "Field * make_field(..)" - Method "Field *Column_defitinion::make_field(..)" The rename makes it's easier to search the code using "grep".
* | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2018-02-151-0/+5
|\ \ \ \
| * | | | MDEV-15293 CAST(AS TIME) returns bad results for ↵Alexander Barkov2018-02-131-0/+5
| | | | | | | | | | | | | | | | | | | | LAST_VALUE(),NAME_CONST(),SP variable
* | | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-11-301-1/+3
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-14517 Cleanup for Item::with_subselect and Item::has_subquery()Alexander Barkov2017-11-281-1/+3
| | | | |
* | | | | Remove not used mem_root argument from build_clone(), get_copy() and ↵Michael Widenius2017-11-231-3/+3
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | get_item_copy() TODO: - Make get_thd_memroot() inline - To do this, we need to reduce dependence of include files, especially so that sql_class.h is not depending in item.h
* | | | Merge remote-tracking branch 'origin/10.2' into bb-10.2-extMonty2017-11-091-1/+1
|\ \ \ \ | |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mysql-test/r/cte_recursive.result mysql-test/r/derived_cond_pushdown.result mysql-test/t/cte_recursive.test mysql-test/t/derived_cond_pushdown.test sql/datadict.cc sql/handler.cc
| * | | Merge remote-tracking branch 'origin/10.1' into 10.2Alexander Barkov2017-11-091-1/+1
| |\ \ \ | | |/ /
| | * | Merge remote-tracking branch 'origin/10.0' into 10.1Alexander Barkov2017-11-091-1/+1
| | |\ \
| | | * | MDEV-14164: Unknown column error when adding aggregate to function in oracle ↵Oleksandr Byelkin2017-11-091-1/+1
| | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 remote-tracking branch 'origin/10.2' into bb-10.2-extAlexander Barkov2017-10-301-7/+4
|\ \ \ \ | |/ / /
| * | | Merge branch '10.1' into 10.2Sergei Golubchik2017-10-241-7/+4
| |\ \ \ | | |/ /
| | * | Merge branch '10.0' into 10.1Sergei Golubchik2017-10-221-7/+4
| | |\ \ | | | |/
| | | * MDEV-9619: Assertion `null_ref_table' failed in virtual table_map ↵Oleksandr Byelkin2017-10-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Item_direct_view_ref::used_tables() const on 2nd execution of PS Refer left expression indirectly in case it changes from execution to execution.
* | | | Merge 10.2 into bb-10.2-extMarko Mäkelä2017-06-271-0/+10
|\ \ \ \ | |/ / /
| * | | Fixed the bug mdev-12845.Igor Babaev2017-06-221-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fills in a serious flaw in the code that supports condition pushdown into materialized views / derived tables. If a predicate happened to contain a reference to a mergeable view / derived table and it does not depended directly on the target materialized view / derived table then the predicate was not considered as a subject to pusdown to this view / derived table.
* | | | MDEV-12719 Determine Item::result_type() from Item::type_handler()Alexander Barkov2017-05-071-1/+0
| | | |
* | | | MDEV-12718 Determine Item::cmp_type() from Item::type_handler()Alexander Barkov2017-05-071-1/+0
| | | |
* | | | MDEV-12714 Determine Item::field_type() from Item::type_handler()Alexander Barkov2017-05-061-5/+0
| | | |
* | | | Adding "const" qualifier to Item::cols(), and to the "Item *cmp" parameter ↵Alexander Barkov2017-05-061-1/+1
| | | | | | | | | | | | | | | | to Type_handler::make_const_item_for_comparison()
* | | | Merge remote-tracking branch 'origin/10.2' into bb-10.2-extAlexander Barkov2017-04-051-0/+7
|\ \ \ \ | |/ / /
| * | | Fixed bug mdev-10454.Igor Babaev2017-04-031-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch actually fixes the old defect of the optimizer that could not extract keys for range access from IN predicates with row arguments. This problem was resolved in the mysql-5.7 code. The patch supersedes what was done there: - it can build range access when not all components of the first row argument are refer to the columns of the table for which the range access is constructed. - it can use equality predicates to build range access to the table that is not referred to in this argument.
* | | | MDEV-11344 Split Arg_comparator::set_compare_func() into virtual methods in ↵Alexander Barkov2016-12-161-0/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Type_handler This patch: - Introduces a new virtuial method Type_handler::set_comparator_func and moves pieces of the code from the switch in Arg_comparator::set_compare_func into the corresponding Type_handler_xxx::set_comparator_func. - Adds Type_handler::get_handler_by_cmp_type() - Moves Type_handler_hybrid_field_type::get_handler_by_result_type() to a static method Type_handler::get_handler_by_result_type(), for symmetry with similar methods: * Type_handler::get_handler_by_field_type() * Type_handler::get_handler_by_real_type() * Type_handler::get_handler_by_cmp_type() - Introduces Type_handler_row, to unify the code for the scalar data types and the ROW data type (currently for comparison purposes only). - Adds public type_handler_row, as it's now needed in item_row.h - Makes type_handler_null public, as it's now needed in item_cmpfunc.h Note, other type_handler_xxx will become public as well later. - Removes the global variable Arg_comparator::comparator_matrix, as it's not needed any more.
* | | Merge branch '10.2-mdev9197-cons' of github.com:shagalla/serverIgor Babaev2016-08-311-0/+3
|\ \ \ | | | | | | | | | | | | into branch 10.2-mdev9197.
| * | | The consolidated patch for mdev-9197.Galina Shalygina2016-08-231-0/+3
| | | |
* | | | cleanup: change Item::walk() to take void* not uchar*Sergei Golubchik2016-06-301-3/+3
| | | | | | | | | | | | | | | | | | | | and remove all related casts to uchar* also remove a couple of unused methods
* | | | MDEV-7563 Support CHECK constraint as in (or close to) SQL StandardMichael Widenius2016-06-301-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-10134 Add full support for DEFAULT - Added support for using tables with MySQL 5.7 virtual fields, including MySQL 5.7 syntax - Better error messages also for old cases - CREATE ... SELECT now also updates timestamp columns - Blob can now have default values - Added new system variable "check_constraint_checks", to turn of CHECK constraint checking if needed. - Removed some engine independent tests in suite vcol to only test myisam - Moved some tests from 'include' to 't'. Should some day be done for all tests. - FRM version increased to 11 if one uses virtual fields or constraints - Changed to use a bitmap to check if a field has got a value, instead of setting HAS_EXPLICIT_VALUE bit in field flags - Expressions can now be up to 65K in total - Ensure we are not refering to uninitialized fields when handling virtual fields or defaults - Changed check_vcol_func_processor() to return a bitmap of used types - Had to change some functions that calculated cached value in fix_fields to do this in val() or getdate() instead. - store_now_in_TIME() now takes a THD argument - fill_record() now updates default values - Add a lookahead for NOT NULL, to be able to handle DEFAULT 1+1 NOT NULL - Automatically generate a name for constraints that doesn't have a name - Added support for ALTER TABLE DROP CONSTRAINT - Ensure that partition functions register virtual fields used. This fixes some bugs when using virtual fields in a partitioning function
* | | Merge branch '10.2' into bb-10.2-mdev9543Sergei Petrunia2016-03-281-1/+10
|\ \ \
| * \ \ Merge branch '10.1' into 10.2Sergei Golubchik2016-03-231-1/+10
| |\ \ \ | | |/ /
| | * | MDEV-9369 IN operator with ( num, NULL ) gives inconsistent resultAlexander Barkov2016-03-211-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on this commit into MySQL-5.7: > commit 8e51b845aafc8b4cdebd763c8aebda262ac2d4cd > Author: Guilhem Bichot <guilhem.bichot@oracle.com> > Date: Mon Nov 4 15:44:55 2013 +0100 > > Bug#13944462 'NULL IN (XX)' RETURNS WRONG RESULTS
* | | | This is the consolidated patch for mdev-8646:bb-10.2-mdev8646Igor Babaev2016-02-091-2/+2
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "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-9215 Detect cmp_type() and result_type() from field_type()Alexander Barkov2015-12-011-0/+5
| | | | | | | | | | | | (A dependency task for MDEV-4912 Add a plugin to field types)
* | | MDEV-8718 - Obsolete sql_strmake() in favor of THD::strmake() and thd_strmake()Sergey Vojtovich2015-11-261-1/+1
|/ /
* | MDEV-6152: Remove calls to current_thd while creating ItemMonty2015-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | - Part 4: Removing calls to sql_alloc() and sql_calloc() Other things: - Added current_thd in some places to make it clear that it's called (easier to remove later) - Move memory allocation from Item_func_case::fix_length_and_dec() to Item_func_case::fix_fields() - Added mem_root to some new calls - Fixed some wrong UNINIT_VAR() calls - Fixed a bug in generate_partition_syntax() in case of errors - Added mem_root to argument to new thread_info - Simplified my_parse_error() call in sql_yacc.yy
* | MDEV-8010 - Avoid sql_alloc() in Items (Patch #1)Sergey Vojtovich2015-08-211-4/+5
| | | | | | | | | | | | | | Added mandatory thd parameter to Item (and all derivative classes) constructor. Added thd parameter to all routines that may create items. Also removed "current_thd" from Item::Item. This reduced number of pthread_getspecific() calls from 290 to 177 per OLTP RO transaction.
* | Fixes done while working on MDEV-4119:Monty2015-07-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed several optimizer issues relatied to GROUP BY: a) Refering to a SELECT column in HAVING sometimes calculated it twice, which caused problems with non determinstic functions b) Removing duplicate fields and constants from GROUP BY was done too late for "using index for group by" optimization to work c) EXPLAIN SELECT ... GROUP BY did wrongly show 'Using filesort' in some cases involving "Using index for group-by" a) was fixed by: - Changed last argument to Item::split_sum_func2() from bool to int to allow more flags - Added flag argument to Item::split_sum_func() to allow on to specify if the item was in the SELECT part - Mark all split_sum_func() calls from SELECT with SPLIT_SUM_SELECT - Changed split_sum_func2() to do nothing if called with an argument that is not a sum function and doesn't include sum functions, if we are not an argument to SELECT. This ensures that in a case like select a*sum(b) as f1 from t1 where a=1 group by c having f1 <= 10; That 'a' in the SELECT part is stored as a reference in the temporary table togeher with sum(b) while the 'a' in having isn't (not needed as 'a' is already a reference to a column in the result) b) was fixed by: - Added an extra remove_const() pass for GROUP BY arguments before make_join_statistics() in case of one table SELECT. This allowes get_best_group_min_max() to optimize things better. c) was fixed by: - Added test for group by optimization in JOIN::exec_inner for select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX item.cc: - Simplifed Item::split_sum_func2() - Split test to make them faster and easier to read - Changed last argument to Item::split_sum_func2() from bool to int to allow more flags - Added flag argument to Item::split_sum_func() to allow on to specify if the item was in the SELECT part - Changed split_sum_func2() to do nothing if called with an argument that is not a sum function and doesn't include sum functions, if we are not an argument to SELECT. opt_range.cc: - Simplified get_best_group_min_max() by calcuating first how many group_by elements. - Use join->group instead of join->group_list to test if group by, as join->group_list may be NULL if everything was optimized away. sql_select.cc: - Added an extra remove_const() pass for GROUP BY arguments before make_join_statistics() in case of one table SELECT. - Use group instead of group_list to test if group by, as group_list may be NULL if everything was optimized away. - Moved printing of "Error in remove_const" to remove_const() instead of having it in caller. - Simplified some if tests by re-ordering code. - update_depend_map_for_order() and remove_const() fixed to handle the case where make_join_statistics() has not yet been called (join->join_tab is 0 in this case)
* | Deriving Item_row from Item_args and sharing more codeAlexander Barkov2015-04-241-11/+27
| | | | | | | | between Item_func, Item_sum, Item_row.
* | MDEV-8024 Remove excessive update_used_tables() callsAlexander Barkov2015-04-221-6/+8
|/
* 5.3 mergeSergei Golubchik2012-01-131-1/+2
|\