summaryrefslogtreecommitdiff
path: root/mysql-test/r/group_by.result
Commit message (Collapse)AuthorAgeFilesLines
* Create 'main' test directory and move 't' and 'r' thereMichael Widenius2018-03-291-2834/+0
|
* Merge remote-tracking branch 'origin/10.2' into bb-10.2-extMonty2018-01-011-0/+25
|\ | | | | | | | | | | | | | | | | | | Conflicts: cmake/make_dist.cmake.in mysql-test/r/func_json.result mysql-test/r/ps.result mysql-test/t/func_json.test mysql-test/t/ps.test sql/item_cmpfunc.h
| * Merge remote-tracking branch 'origin/10.1' into 10.2Vicențiu Ciorbaru2017-12-221-0/+25
| |\
| | * Merge branch '10.0' into 10.1Vicențiu Ciorbaru2017-12-201-0/+25
| | |\
| | | * Merge remote-tracking branch '5.5' into 10.0Vicențiu Ciorbaru2017-12-201-0/+25
| | | |\
| | | | * MDEV-12350: Heap corruption, overrun buffer, ASAN errors, server crash in ↵Varun Gupta2017-12-201-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | my_fill_8bit / filesort In the function make_sortkey a tmp buffer was defined and in the absence of param->tmp_buffer, tmp buffer used the sort_keys buffer. sort_keys buffer has a length defined in sort_field->length, while param->tmp_buffer is stored in param->rec_length. Make sure to use the appropriate length based on which buffer we are using otherwise we'll overflow. Also added a type cast to size_t during the calculation of the sort keys buffer size to avoid an oveflow if the buffer size exceeds 32 bits.
* | | | | Merge branch '10.2' into bb-10.2-extSergei Golubchik2017-08-251-0/+27
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.1' into 10.2Sergei Golubchik2017-08-171-0/+27
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.0' into 10.1Sergei Golubchik2017-08-081-0/+27
| | |\ \ \ | | | |/ /
| | | * | Merge remote-tracking branch 'origin/5.5' into 10.0Vicențiu Ciorbaru2017-07-251-0/+27
| | | |\ \ | | | | |/
| | | | * MDEV-13180 Unused left join causes server crashSergei Golubchik2017-07-121-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | already fixed by be55bbc2b20 just add a test case
| | | | * MDEV-12489 The select stmt may fail due to "having clause is ambiguous" ↵Sergei Golubchik2017-07-121-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unexpected only compare field references with an alias (from the SELECT clause) when this reference doesn't specify an explicit table name part.
| | | | * MDEV-7826 Server crashes in Item_subselect::enumerate_field_refs_processorSergei Golubchik2017-07-121-0/+14
| | | | | | | | | | | | | | | | | | | | upper->item can be NULL if we're referring to an aggregate function
* | | | | MDEV-10141: Add support for INTERSECT (and common parts for EXCEPT)Oleksandr Byelkin2017-03-141-2/+2
|/ / / / | | | | | | | | | | | | MDEV-10140: Add support for EXCEPT
* | | | MDEV-10694 - SIGFPE and/or huge memory allocation in maria_create ...Sergei Petrunia2017-02-151-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The issue was that JOIN::rollup_write_data() used JOIN::tmp_table_param::[start_]recinfo, which had uninitialized data. These fields have uninitialized data, because JOIN::tmp_table_param currently only stores some grouping-related data fields. The data about the work (temporary) tables themselves is stored in join->join_tab[...].tmp_table_param. The fix is to make JOIN::rollup_write_data follow this convention and look at the right TMP_TABLE_PARAM object
* | | | Merge branch '10.1' into 10.2Sergei Golubchik2016-12-291-0/+14
|\ \ \ \ | |/ / /
| * | | Merge branch '10.0' into 10.1Sergei Golubchik2016-12-111-0/+14
| |\ \ \ | | |/ /
| | * | Merge branch '5.5' into 10.0Sergei Golubchik2016-12-091-0/+14
| | |\ \ | | | |/
| | | * MDEV-10663: Use of Inline table columns in HAVING clause throws 1463 ErrorOleksandr Byelkin2016-12-061-0/+14
| | | | | | | | | | | | | | | | check for VIEW/DERIVED fields
* | | | Item::print(): remove redundant parenthesesSergei Golubchik2016-12-121-2/+2
| | | | | | | | | | | | | | | | | | | | by introducing new Item::precedence() method and using it to decide whether parentheses are required
* | | | Merge branch '10.1' into 10.2Sergei Golubchik2016-09-091-0/+34
|\ \ \ \ | |/ / /
| * | | MDEV-10324: Server crash in get_sel_arg_for_keypart or AssertionSergei Petrunia2016-07-051-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The crash was caused by this problem: get_best_group_min_max() tries to construct query plans for keys that are not processed by the range optimizer. This wasn't a problem as long as SEL_TREE::keys was an array of MAX_KEY elements. However, now it is a Mem_root_array and only has elements for the used keys, and get_best_group_min_max attempts to address beyond the end of the array. The obvious way to fix the crash was to port (and improve) a part of 96fcfcbd7b5120e8f64fd45985001eca8d36fbfb from mysql-5.7. This makes get_best_group_min_max not to consider indexes that Mem_root_arrays have no element for. After that, I got non-sensical query plans (see MDEV-10325 for details). Fixed that by making get_best_group_min_max to check if the index is in table->keys_in_use_for_group_by bitmap.
| * | | MDEV-9602 crash in st_key::actual_rec_per_key when group by constantMonty2016-04-281-0/+14
| | | | | | | | | | | | | | | | Problem was that cost_group_min_max() could not handle if group by was optimized away.
* | | | Merge branch '10.2' into 10.2-mdev9864Galina Shalygina2016-05-081-2/+47
|/ / /
* | | MDEV-8988: Apparently valid SQL query gives wrong result (nested WHERE)mariadb-10.1.12Sergei Petrunia2016-02-241-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | - "Early NULLs filtering" optimization used to "peel off" Item_ref and Item_direct_ref wrappers from an outside column reference before adding "outer_table_col IS NOT NULL" into JOIN::outer_ref_cond. - When this happened in a subquery that was evaluated in a post-GROUP-BY context, attempt to evaluate JOIN::outer_ref_cond would fetch an incorrect value of outer_table_col.
* | | MDEV-8747 Wrong result for SELECT..WHERE derived_table_column='a' AND ↵Alexander Barkov2015-09-061-4/+0
| | | | | | | | | | | | | | | | | | 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
* | | Fixes done while working on MDEV-4119:Monty2015-07-051-3/+85
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | Merge branch '5.5' into 10.0Sergei Golubchik2015-06-111-1/+1
|\ \ | |/
| * MDEV-8085 main.group_by failed in buildbotSergei Golubchik2015-06-031-1/+1
| | | | | | | | | | change the test case to be deterministic (while still sufficient to test a bug)
* | Merge branch '5.5' into 10.0Sergei Golubchik2015-05-041-0/+10
|\ \ | |/
| * post-merge changes, fixes, and testsSergei Golubchik2015-04-281-0/+10
| |
* | 5.5 mergeSergei Golubchik2015-01-211-0/+14
|\ \ | |/
| * MDEV-6855 Assertion `cond_type == Item::FUNC_ITEM' failed in ↵Michael Widenius2014-12-151-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | check_group_min_max_predicates with GROUP BY, aggregate in WHERE SQ, multi-part key mysql-test/r/group_by.result: Test for MDEV-6855 mysql-test/t/group_by.test: Test for MDEV-6855 sql/item.h: Fixed spelling error sql/opt_range.cc: Added handling of cond_type == Item::CACHE_ITEM in WHERE clauses for MIN/MAX optimization. Fixed indentation
* | 5.5 mergeSergei Golubchik2014-11-031-0/+11
|\ \ | |/
| * MDEV-6484: Assertion `tab->ref.use_count' failed on query with joins, ↵Sergey Petrunya2014-10-141-0/+11
| | | | | | | | | | | | | | | | | | | | constant table, multi-part key - test_if_skip_sort_order()/create_ref_for_key() may change table access from EQ_REF(index1) to REF(index2). - Doing so doesn't make much sense from optimization POV, but since they are doing it, they should update tab->read_record.unlock_row accordingly.
* | 5.5 mergeSergei Golubchik2014-05-091-0/+9
|\ \ | |/
| * MDEV-6129: Server crashes during UNION with ORDER BY field IS NULLMichael Widenius2014-04-241-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed crashing bug for union queries where there was no real tables. mysql-test/r/group_by.result: Added test case mysql-test/t/group_by.test: Added test case sql/db.opt: Removed genrated file sql/item.cc: Handled case when table_list->pos_in_tables is not set. Can only happens when there is no real tables in query
* | Fixed the problem of mdev-5947.Igor Babaev2014-04-221-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back-ported from the mysql 5.6 code line the patch with the following comment: Fix for Bug#11757108 CHANGE IN EXECUTION PLAN FOR COUNT_DISTINCT_GROUP_ON_KEY CAUSES PEFORMANCE REGRESSION The cause for the performance regression is that the access strategy for the GROUP BY query is changed form using "index scan" in mysql-5.1 to use "loose index scan" in mysql-5.5. The index used for group by is unique and thus each "loose scan" group will only contain one record. Since loose scan needs to re-position on each "loose scan" group this query will do a re-position for each index entry. Compared to just reading the next index entry as a normal index scan does, the use of loose scan for this query becomes more expensive. The cause for selecting to use loose scan for this query is that in the current code when the size of the "loose scan" group is one, the formula for calculating the cost estimates becomes almost identical to the cost of using normal index scan. Differences in use of integer versus floating point arithmetic can cause one or the other access strategy to be selected. The main issue with the formula for estimating the cost of using loose scan is that it does not take into account that it is more costly to do a re-position for each "loose scan" group compared to just reading the next index entry. Both index scan and loose scan estimates the cpu cost as: "number of entries needed too read/scan" * ROW_EVALUATE_COST The results from testing with the query in this bug indicates that the real cost for doing re-position four to eight times higher than just reading the next index entry. Thus, the cpu cost estimate for loose scan should be increased. To account for the extra work to re-position in the index we increase the cost for loose index scan to include the cost of navigating the index. This is modelled as a function of the height of the b-tree: navigation cost= ceil(log(records in table)/log(indexes per block)) * ROWID_COMPARE_COST; This will avoid loose index scan being used for indexes where the "loose scan" group contains very few index entries.
* | 10.0-base mergeSergei Golubchik2014-02-031-35/+13
|\ \
| * \ 5.5 mergeSergei Golubchik2014-02-011-35/+13
| |\ \ | | |/
| | * move innodb specific test from group_by.test to group_by_innodb.testSergei Golubchik2014-01-261-26/+0
| | |
| | * Fixed MDEV-5424: SELECT using ORDER BY DESC and LIMIT produces unexpected ↵Michael Widenius2014-01-021-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | results (InnoDB/XtraDB) This only happend when using an ORDER BY on a primary key part, where all other key parts where constant. Remove of duplicated expressions in ORDER BY (as the old code did this in some strange cases) mysql-test/r/group_by.result: Fixed results to take into account that duplicate order by parts are now deleted mysql-test/r/group_by_innodb.result: Ensure extended keys are on mysql-test/r/innodb_ext_key.result: More tests mysql-test/r/order_by.result: More tests mysql-test/t/group_by.test: Fixed results to take into account that duplicate order by parts are now deleted mysql-test/t/group_by_innodb.test: Ensure extended keys are on mysql-test/t/innodb_ext_key.test: More tests mysql-test/t/order_by.test: More tests sql/sql_select.cc: Fixed bug where we looked at extended key parts when we shouldn't Remove of duplicated expressions in ORDER BY sql/table.cc: Indentation fixes
* | | merge 10.0-base -> 10.0unknown2013-10-291-0/+5
|\ \ \ | |/ /
| * | merge 5.5->10.0-baseunknown2013-10-291-0/+5
| |\ \ | | |/
| | * Merge 5.3->5.5unknown2013-10-291-0/+5
| | |\
| | | * MDEV-5104 crash in Item_field::used_tables with broken order bytimour@askmonty.org2013-10-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis: st_select_lex_unit::prepare() computes can_skip_order_by as TRUE. As a result join->prepare() gets called with order == NULL, and doesn't do name resolution for the inner ORDER clause. Due to this the prepare phase doesn't detect that the query references non-exiting function and field. Later join->optimize() calls update_used_tables() for a non-resolved Item_field, which understandably has no Field object. This call results in a crash. Solution: Resolve unnecessary ORDER BY clauses to detect if they reference non-exising objects. Then remove such clauses from the JOIN object.
* | | | 10.0-base merge.Sergei Golubchik2013-09-211-1/+1
|\ \ \ \ | |/ / / | | | | | | | | | | | | Partitioning/InnoDB changes are *not* merged (they'll come from 5.6) TokuDB does not compile (not updated to 10.0 SE API)
| * | | MDEV-4120: UNIQUE indexes should not be considered for loose index scanunknown2013-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the loose scan code in opt_range.cc considers all indexes as possible for the access method. Due to inexact statistics it may happen that a loose scan is selected over a unique index. This is clearly wrong since a "loose scan" over a unique index will read the same keys as a direct index scan, but the loose scan has more overhead. This task adds a rule to skip unique indexes for loose scan.
* | | | 10.0-base mergeSergei Golubchik2013-04-151-0/+244
|\ \ \ \ | |/ / /
| * | | 5.5 mergeSergei Golubchik2013-03-271-0/+244
| |\ \ \ | | |/ /