summaryrefslogtreecommitdiff
path: root/sql/sql_select.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '10.1' into 10.2Sergei Golubchik2016-09-091-2/+3
|\
| * MDEV-10045: Server crashes in Time_and_counter_tracker::incr_loopsOleksandr Byelkin2016-07-221-2/+3
| | | | | | | | Do not set 'optimized' flag until whole optimization procedure is finished.
* | Merge branch '10.2-mdev9197-cons' of github.com:shagalla/serverIgor Babaev2016-08-311-1/+1
|\ \ | | | | | | | | | into branch 10.2-mdev9197.
| * | The consolidated patch for mdev-9197.Galina Shalygina2016-08-231-1/+1
| | |
* | | Merge 10.2 into 10.2-mdev9864.Igor Babaev2016-08-301-2/+0
|\ \ \
| * \ \ Merge branch '10.1' into 10.2Sergei Golubchik2016-06-301-2/+0
| |\ \ \ | | |/ / | |/| / | | |/
| | * MDEV-8989: ORDER BY optimizer ignores equality propagationSergei Petrunia2016-05-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Variant #4 of the fix. Make ORDER BY optimization functions take into account multiple equalities. This is done in several places: - remove_const() checks whether we can sort the first table in the join, or we need to put rows into temp.table and then sort. - test_if_order_by_key() checks whether there are indexes that can be used to produce the required ordering - make_unireg_sortorder() constructs sort criteria for filesort.
| * | Fixed bug mdev-9897.Igor Babaev2016-04-141-2/+3
| | | | | | | | | | | | | | | | | | | | | This bug revealed a serious problem: if the same partition list was used in two window specifications then the temporary table created to calculate window functions contained fields for two identical partitions. This problem was fixed as well.
| * | Window functions: Better class namesSergei Petrunia2016-04-061-1/+1
| | | | | | | | | | | | | | | | | | As discussed on the call: - s/Window_funcs_computation_step/Window_funcs_computation/g - s/Window_func_sort/Window_funcs_sort/g
| * | MDEV-9848: Window functions: reuse sorting and/or scanningSergei Petrunia2016-04-051-1/+1
| | | | | | | | | | | | | | | | | | | | | - Rename Window_funcs_computation to Window_funcs_computation_step - Introduce Window_func_sort which invokes filesort and then invokes computation of all window functions that use this ordering. - Expose Window functions' sort operations in EXPLAIN|ANALYZE FORMAT=JSON
| * | Merge branch 'bb-10.2-mdev9543' of github.com:MariaDB/server into ↵Sergei Petrunia2016-03-281-1/+1
| |\ \ | | | | | | | | | | | | bb-10.2-mdev9543
| | * | Make window functions computation step show up in EXPLAIN FORMAT=JSON outputSergei Petrunia2016-03-281-1/+1
| | | |
| * | | Merge branch '10.2' into bb-10.2-mdev9543Sergei Petrunia2016-03-281-6/+5
| |\ \ \ | | |/ / | |/| |
| * | | Remove JOIN_TAB::used_window_func, it is not used anymoreSergei Petrunia2016-03-281-2/+0
| | | |
| * | | Make window function computation a part of the query planSergei Petrunia2016-03-271-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added class Window_funcs_computation, with setup() method to setup execution, and exec() to run window function computation. setup() is currently trivial. In the future, it is expected to optimize the number of sorting operations and passes that are done over the temp. table.
| * | | Code cleanupSergei Petrunia2016-03-241-1/+1
| | | |
| * | | MDEV-8646: Re-engineer the code for post-join operationsSergei Petrunia2016-03-151-8/+0
| | | | | | | | | | | | | | | | | | | | Make query pushdown work in the post-refactored code. This fixes sequence.group_by test.
| * | | Cleanup: remove JOIN::table_access_tabs, top_table_access_tabs_count.Sergei Petrunia2016-02-151-21/+1
| | | | | | | | | | | | | | | | | | | | | | | | These do not have any meaning after MDEV-8646. Their only valid values are - table_access_tabs= join_tab; - top_table_access_tabs_count= top_join_tab_count;
| * | | Post-merge fixes. win.test passes but further cleanup is needed.Sergei Petrunia2016-02-141-0/+4
| | | |
| * | | Window functions: moving aheadSergei Petrunia2016-02-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Disable the code that attempts to group window functions together by their PARTITION BY / ORDER BY clauses, because 1. It doesn't work: when I issue a query with just one window function, and no indexes on the table, filesort is not invoked at all. 2. It is not possible to check that it works currently. Add my own code that does invoke filesort() for each window function. - Hopefully the sort criteria is right - Debugging shows that filesort operates on {sort_key, rowid} pairs (OK) - We can read the filesort rowid result in order.
| * | | Moved window function computation code from JOIN::exec_inner() intoSergei Petrunia2016-02-141-0/+4
| | | | | | | | | | | | | | | | a separate function, JOIN::process_window_functions().
| * | | This is the consolidated patch for mdev-8646:bb-10.2-mdev8646Igor Babaev2016-02-091-96/+234
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "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-10372: EXPLAIN fixes for recursive CTEs, including FORMAT=JSONSergei Petrunia2016-08-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Tabular EXPLAIN now prints "RECURSIVE UNION". - There is a basic implementation of EXPLAIN FORMAT=JSON. - it produces "recursive_union" JSON struct - No other details or ANALYZE support, yet.
* | | | Fixed the following problem:Igor Babaev2016-07-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Temporary tables created for recursive CTE were instantiated at the prepare phase. As a result these temporary tables missed indexes for look-ups and optimizer could not use them.
* | | | Merge branch '10.2' into 10.2-mdev9864Galina Shalygina2016-05-081-128/+248
| | | |
* | | | Initial commit just to make a branch for mdev-9864Galina Shalygina2016-05-081-0/+1
| |/ / |/| |
* | | Merge branch '10.1' into 10.2Sergei Golubchik2016-03-231-5/+4
|\ \ \ | | |/ | |/|
| * | Merge branch '10.0' into 10.1Sergei Golubchik2016-03-211-1/+1
| |\ \
| | * | Fix spelling: occurred, execute, which etcOtto Kekäläinen2016-03-041-1/+1
| | | |
| * | | MDEV-5542: GROUP_CONCAT truncate output to 65.536 chars when using DISTINCT ↵Oleksandr Byelkin2016-03-011-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | or ORDER BY port of mysql fix WL#6098
* | | | Removed TABLE->sort to make it possible to have multiple active calls toMonty2016-03-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | filesort and init_read_record() for the same table. This will simplify code for WINDOW FUNCTIONS (MDEV-6115) - Filesort_info renamed to SORT_INFO and moved to filesort.h - filesort now returns SORT_INFO - init_read_record() now takes a SORT_INFO parameter. - unique declaration is moved to uniques.h - subselect caching of buffers is now more explicit than before - filesort_buffer is now reusable even if rec_length has changed. - filsort_free_buffers() and free_io_cache() calls are removed - Remove one malloc() when using get_addon_fields() Other things: - Added --debug-assert-on-not-freed-memory option to make it easier to debug some not-freed-memory issues.
* | | | Merge branch '10.1' into 10.2Sergei Golubchik2016-02-251-1/+0
|\ \ \ \ | |/ / / | | | / | |_|/ |/| |
| * | Merge branch '10.0' into 10.1Sergei Golubchik2016-02-231-1/+0
| |\ \ | | |/
| | * Merge branch '5.5' into 10.0Sergei Golubchik2016-02-151-1/+0
| | |\
| | | * MDEV-7122: Assertion `0' failed in subselect_hash_sj_engine::initVicențiu Ciorbaru2016-02-101-0/+13
| | | | | | | | | | | | | | | | | | | | Fix test failure when using maria small-block size. We need to query the max_key_length and max_key_parts based on the the tmp table engine.
* | | | MDEV-9238 Wrap create_virtual_tmp_table() into a class, split into different ↵Alexander Barkov2015-12-041-1/+174
| | | | | | | | | | | | | | | | steps
* | | | A joint patch for:Alexander Barkov2015-11-251-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | - MDEV-8093 sql_yacc.yy: add %type create_field for field_spec and column_def and partially: - MDEV-8095 Split Create_field
* | | bug: move one_storage_engine checking loopSergei Golubchik2015-10-051-3/+0
| | | | | | | | | | | | | | | down to the point where all tables are already known (and subqueries converted to joins, if needed)
* | | cleanups and simplificationsSergei Golubchik2015-10-051-1/+2
| | |
* | | move internal API out from group_by_handlerSergei Golubchik2015-10-051-2/+19
| | | | | | | | | | | | into a Pushdown_query object
* | | typos in comments, minor stylistic editsSergei Golubchik2015-10-051-0/+5
| | |
* | | MDEV-6080: Allowing storage engine to shortcut group by queriesMonty2015-10-051-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This task is to allow storage engines that can execute GROUP BY or summary queries efficiently to intercept a full query or sub query from MariaDB and deliver the result either to the client or to a temporary table for further processing. - Added code in sql_select.cc to intercept GROUP BY queries. Creation of group_by_handler is done after all optimizations to allow storage engine to benefit of an optimized WHERE clause and suggested indexes to use. - Added group by handler to sequence engine and a group_by test suite as a way to test the new interface. - Intercept EXPLAIN with a message "Storage engine handles GROUP BY" libmysqld/CMakeLists.txt: Added new group_by_handler files sql/CMakeLists.txt: Added new group_by_handler files sql/group_by_handler.cc: Implementation of group_by_handler functions sql/group_by_handler.h: Definition of group_by_handler class sql/handler.h: Added handlerton function to create a group_by_handler, if the storage engine can intercept the query. sql/item_cmpfunc.cc: Allow one to evaluate item_equal any time. sql/sql_select.cc: Added code to intercept GROUP BY queries - If all tables are from the same storage engine and the query is using sum functions, call create_group_by() to check if the storage engine can intercept the query. - If yes: - create a temporary table to hold a GROUP_BY row or result - In do_select() intercept normal query execution by instead calling the group_by_handler to get the result - Intercept EXPLAIN sql/sql_select.h: Added handling of group_by_handler Added caching of the original join tab (needed for cleanup after group_by handler) storage/sequence/mysql-test/sequence/group_by.result: Test group_by_handler interface storage/sequence/mysql-test/sequence/group_by.test: Test group_by_handler interface storage/sequence/sequence.cc: Added simple group_by_engine for handling COUNT(*) and SUM(primary_key). This was done as a test of the group_by_handler interface
* | | Merge branch '10.0' into 10.1Sergei Golubchik2015-09-031-2/+5
|\ \ \ | |/ / | | | | | | | | | referenced_by_foreign_key2(), needed for InnoDB to compile, was taken from 10.0-galera
| * | MDEV-8289: Semijoin inflates number of rows in query resultSergei Petrunia2015-08-181-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Make semi-join optimizer not to choose LooseScan when 1) the index is not covered and 2) full index scan will be required. - Make sure that the code in make_join_select() that may change full index scan into a range scan is not invoked when the table uses full scan.
| * | Merge commit '96badb16afcf' into 10.0Jan Lindström2015-08-031-0/+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
| | * Fixed crashing bug when using ONLY_FULL_GROUP_BY in a stored ↵Monty2015-06-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Stage 2 of MDEV-6152:Monty2015-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | - Added mem_root to all calls to new Item - Added private method operator new(size_t size) to Item to ensure that we always use a mem_root when creating an item. This saves use once call to current_thd per Item creation
* | | MDEV-8010 - Avoid sql_alloc() in Items (Patch #1)Sergey Vojtovich2015-08-211-2/+2
| | | | | | | | | | | | | | | | | | | | | 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.
* | | - Renaming variables so that they don't shadow others (After this patch one ↵Monty2015-07-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | can compile with -Wshadow and get much fewer warnings) - Changed ER(ER_...) to ER_THD(thd, ER_...) when thd was known or if there was many calls to current_thd in the same function. - Changed ER(ER_..) to ER_THD_OR_DEFAULT(current_thd, ER...) in some places where current_thd is not necessary defined. - Removing calls to current_thd when we have access to thd Part of this is optimization (not calling current_thd when not needed), but part is bug fixing for error condition when current_thd is not defined (For example on startup and end of mysqld) Notable renames done as otherwise a lot of functions would have to be changed: - In JOIN structure renamed: examined_rows -> join_examined_rows record_count -> join_record_count - In Field, renamed new_field() to make_new_field() Other things: - Added DBUG_ASSERT(thd == tmp_thd) in Item_singlerow_subselect() just to be safe. - Removed old 'tab' prefix in JOIN_TAB::save_explain_data() and use members directly - Added 'thd' as argument to a few functions to avoid calling current_thd.
* | | Fixes done while working on MDEV-4119:Monty2015-07-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)