summaryrefslogtreecommitdiff
path: root/mysql-test
Commit message (Collapse)AuthorAgeFilesLines
* Update explain_json result10.8-selectivitySergei Krivonos2021-12-141-14/+12
|
* Another fixup, to be combined with the previous commitsMonty2021-12-137-39/+217
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed a lot of inconsistencies in optimizer cost calculation. The main objective was get cost calculation as similar (and accurate) as possible to make different plans more comparable. - Replaced constant 2.0 with new define TABLE_SCAN_SETUP_COST. - Added RECORD_COPY_COST, the cost of finding the next row and copying it to record for table scans. - Added INDEX_COPY_COST, the cost of finding the next key and copying it to record for index scans. - Added INDEX_NEXT_FIND_COST, the cost of finding the next index entry and checking it against filter. - Some scan cost estimates did not take into account TIME_FOR_COMPARE. Now all scan costs takes this into account. (main.show_explain) - Fixed that we don't calculate TIME_FOR_COMPARE twice for some plans, like in optimize_straight_join() and greedy_search() - JOIN_TAB::scan_time() did not take into account index only scans, which produced a wrong cost when index scan was used. Fixed by adding support for covering keys. Cached also the calculated values to avoid future calls during optimization phase. - Fixed that most index cost calculation are done the same way and more close to 'range' calculations. The effects of this change are: - Cost of index scan is now lower than before, which causes some tests result to change. (innodb.innodb, main.show_explain) - Fixed the EQ_REF takes into account clustered and covered keys. - Ensured that index_scan_cost() == range(scan_of_all_rows_in_table_using_one_range) + MULTI_RANGE_READ_INFO_CONST. One effect of this is that if there is choice of doing a full index scan and a range-index scan over almost the whole table then index scan will be preferred (no range-read setup cost). - Rowid filter setup cost and filter compare cost now takes into account fetching and checking the rowid (INDEX_NEXT_FIND_COST). (main.partition_pruning heap.heap_btree main.log_state) - Introduced ha_scan_time() that takes into account the CPU cost of finding the next row and copying the row from the engine to 'record'. This causes costs of table scan to slightly increase and some test to changed their plan from ALL to RANGE or ALL to ref. (innodb.innodb_mysql, main.select_pkeycache) - Introduced ha_scan_and_compare_time() to is like ha_scan_time() but also adds the cost of checking the where clause (TIME_FOR_COMPARE). - Cost of index scan was too low before compared to anything else. - Introduced ha_keyread_time(rows) that takes into account finding the next row and copying the key value to 'record' (INDEX_COPY_COST). - Introduced ha_key_scan_time() for calculating an index scan over all rows. - Added IDX_LOOKUP_COST to keyread_time() as a startup cost. - Added index_only_fetch_cost() as a convenience function to OPT_RANGE. - keyread_time() cost is slightly reduced to prefer shorter keys. - All of the above caused some index_merge combinations to be rejected because of cost (main.index_intersect) - Added checking of the WHERE clause of the accepted rows to ROR costs in get_best_ror_intersect() - Fixed bug in get_best_ror_intersect() where 'min_cost' was not updated, and the cost we compared with was not the one that was used. - Removed '- 0.001' from 'join->best_read' and optimize_straight_join() to ensure that the 'Last_query_cost' status variable contains the same value as the one that was calculated by the optimizer. - Extend get_range_limit_read_cost() to take into considering cost_for_index_read() if there where no quick keys. This will reduce the computed cost for ORDER BY with LIMIT in some cases. (main.innodb_ext_key) - Added INDEX_NEXT_FIND_COST to Range_rowid_filter_cost_info::lookup_cost to account of the time to find and check the next key value against the container - Changed 'JOIN_TAB:::scan_time() to take into consideration clustered and covered keys. The values are now cached and we only have to call this function once. Other calls are changed to use the cached values. Function renamed to JOIN_TAB::estimate_scan_time(). Other things: - Added some 'if (thd->trace_started())' to speed up code - Removed not used function Cost_estimate::is_zero() - Simplified testing of HA_POS_ERROR in get_best_ror_intersect(). (No cost changes)
* Calculate index_only_cost correctly for all ref accessesMonty2021-12-1318-115/+4098
| | | | | | | | | | | | | | | | | | fetch_cost and index_only_cost now takes into account clustered keys and index only accesses. Before the index_only_cost was not correctly taken into account when considering a filter. When using filter, not matching rows will only do a index only access. In the result files, many of the changes are going back to close to what they where before the "Update cost for hash and cached joins" commit, as that commit didn't fix the filter cost (too complex to do everything in one commit). Other things: - cost_for_index_read now returns both full cost and index_only_cost - Ensure that access_cost_factor, used by best_range_rowid_filter_for_partial_join() is between 0 and 1 (as documented).
* Update cost for hash and cached joinsMonty2021-12-1363-929/+990
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The old code didn't correctly add TIME_FOR_COMPARE to rows that are part of the scan that will be compared with the attached where clause. Now the cost calculation for hash join and full join cache join are identical except for HASH_FANOUT (10%) The cost for a join with keys is now also uniform. The total cost for a using a key for lookup is calculated in one place as: (cost_of_finding_rows_through_key(records) + records/TIME_FOR_COMPARE)* record_count_of_previous_row_combinations + startup_cost startup_cost is the cost of a creating a temporary table (if needed) Best_cost now includes the cost of comparing all WHERE clauses and also cost of joining with previous row combinations. Other things: - Optimizer trace is now printing the total costs, including testing the WHERE clause (TIME_FOR_COMPARE) and comparing with all previous rows. - In optimizer trace, include also total cost of query together with the final join order. This makes it easier to find out where the cost was calculated. - Old code used filter even if the cost for it was higher than not using a filter. This is not corrected.
* Adjust costs for doing index scan in cost_group_min_max()Monty2021-12-1317-94/+175
| | | | | | | | | | | | | | | | | | | | | The idea is that when doing a tree dive (once per group), we need to compare key values, which is fast. For each new group, we have to compare the full where clause for the row. Compared to original code, the cost of group_min_max() has slightly increased which affects some test with only a few rows. main.group_min_max and main.distinct have been modified to show the effect of the change. The patch also adjust the number of groups in case of quick selects: - For simple WHERE clauses, ensure that we have at least as many groups as we have conditions on the used group-by key parts. The assumption is that each condition will create at least one group. - Ensure that there are no more groups than rows found by quick_select Test changes: - For some small tables there has been a change of Using index for group-by -> Using index for group-by (scanning) Range -> Index and Using index for group-by -> Using index
* Return >= 1 from matching_candidates_in_table if records > 0.0Monty2021-12-1312-34/+35
| | | | | | | | | | Having rows >= 1.0 helps ensure that when we calculate total rows of joins the number of resulting rows will not be less after the join. Changes in test cases: - Join order change for some tables with few records - 'Filtered' is much higher for tables with few rows, as 1 row is a high procent of a table with few rows.
* Update matching_candidates_in_table() to treat all conditions similarMonty2021-12-1336-207/+205
| | | | | | | | | | | | | | | Fixed also that the 'with_found_constraint parameter' to matching_candidates_in_table() is as documented: It is now true only if there is a reference to a previous table in the WHERE condition for the current examined table (as it was originally documented) Changes in test results: - Filtered was 25% smaller for some queries (expected). - Some join order changed (probably because the tables had very few rows). - Some more table scans, probably because there would be fewer returned rows. - Some tests exposes a bug that if there is more filtered rows, then the cost for table scan will be higher. This will be fixed in a later commit.
* Fix calculation of selectivityMonty2021-12-136-12/+436
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | calculate_cond_selectivity_for_table() is largely rewritten: - Process keys in the order of rows found, smaller ranges first. If two ranges has equal number of rows, use the one with more key parts. This helps us to mark more used fields to not be used for further selectivity calculations. See cmp_quick_ranges(). - Ignore keys with fields that where used by previous keys - Don't use rec_per_key[] to calculate selectivity for smaller secondary key parts. This does not work as rec_per_key[] value is calculated in the context of the previous key parts, not for the key part itself. The one exception is if the previous key parts is a constant. Other things: - Ensure that select->cond_selectivity is always between 0 and 1. - Ensure that select->opt_range_condition_rows is never updated to a higher value. It is initially set to the number of rows in table. - We know store in table->opt_range_condition_rows the lowest number of rows that any row-read-method has found so far. Before it was only done for UICK_SELECT_I::QS_TYPE_ROR_UNION and QUICK_SELECT_I::QS_TYPE_INDEX_MERGE. Now it is done for a lot more methods. See calculate_cond_selectivity_for_table() for details. - Calculate and use selectivity for the first key part of a multiple key part if the first key part is a constant. WHERE key1_part1=5 and key2_part1=5. IF key1 is used, then we can still use selectivity for key2 Changes in test results: - 'filtered' is slighly changed, usually to something slightly smaller - A few cases where for group by queries the table order changed. This was because the number of resulting rows from a group by query with MIN/MAX is now set to be smaller. - A few index was changed as we know prefer index with more key parts if the number of resulting rows is the same.
* Fixed bug in SQL_SELECT_LIMITMonty2021-12-134-9/+7
| | | | | We where comparing costs when we should be comparing number of rows that will be examined
* Limit calculated rows to the number of rows in the tableMonty2021-12-1311-35/+35
| | | | | The result file changes are mainly that number of rows is one smaller for some queries with DISTINCT or GROUP BY
* Ensure that test_quick_select doesn't return more rows than in the tableMonty2021-12-1310-21/+21
| | | | | | | | | | | Other changes: - In test_quick_select(), assume that if table->used_stats_records is 0 then the table has 0 rows. - Fixed prepare_simple_select() to populate table->used_stat_records - Enusre that set_statistics_for_tables() doesn't cause used_stats_records to be 0 when using stat_tables. - To get blackhole to work with replication, set stats.records to 2 so that test_quick_select() doesn't assume the table is empty.
* MDEV-27206: [ERROR] Duplicated key: cause, Assertion `is_uniq_key' failed ↵Sergei Krivonos2021-12-102-0/+27
| | | | with optimizer trace
* Merge 10.7 into 10.8Marko Mäkelä2021-12-101-1/+1
|\
| * Add forgotten changes to the parent commitMarko Mäkelä2021-12-101-1/+1
| |
* | Merge 10.7 into 10.8Marko Mäkelä2021-12-109-4/+293
|\ \ | |/
| * Cleanup: Remove some ib::logger in recovery messagesMarko Mäkelä2021-12-103-3/+0
| |
| * Merge branch '10.6' into 10.7Sergei Golubchik2021-12-086-1/+293
| |\
| | * Merge branch '10.5' into 10.6Sergei Golubchik2021-12-076-1/+293
| | |\
| | | * BUG#31761802 STATISTICS ANY QUERIES USING VIEWS ARE SUMMARIZED TOGETHER WITH ↵Sergei Golubchik2021-12-072-0/+220
| | | | | | | | | | | | | | | | | | | | | | | | THE VIEW DEFINITION SELECT test case only
| | | * Merge branch '10.4' into 10.5Sergei Golubchik2021-12-074-1/+73
| | | |\
| | | | * Merge branch '10.3' into 10.4Sergei Golubchik2021-12-074-1/+73
| | | | |\
| | | | | * Merge branch '10.2' into 10.3Sergei Golubchik2021-12-064-1/+73
| | | | | |\
| | | | | | * fix ./mtr --manual warning after f5441ef4dac9Sergei Golubchik2021-12-061-1/+1
| | | | | | |
| | | | | | * MDEV-26553 NOT IN subquery construct crashing 10.1 and upIgor Babaev2021-11-263-1/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug was introduced by commit be00e279c6061134a33a8099fd69d4304735d02e The commit was applied for the task MDEV-6480 that allowed to remove top level disjuncts from WHERE conditions if the range optimizer evaluated them as always equal to FALSE/NULL. If such disjuncts are removed the WHERE condition may become an AND formula and if this formula contains multiple equalities the field JOIN::item_equal must be updated to refer to these equalities. The above mentioned commit forgot to do this and it could cause crashes for some queries. Approved by Oleksandr Byelkin <sanja@mariadb.com>
* | | | | | | MDEV-27204: [ERROR] Json_writer: a member name was expected, Assertion `got_namebb-10.8-MDEV-27204-v2Sergei Petrunia2021-12-092-13/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [Adjusting Sergei Krivonos's patch] "duplicates_removal" may contain multiple elements inside it and so should have a JSON array as a value (and not object).
* | | | | | | Merge 10.7 into 10.8Marko Mäkelä2021-12-0422-186/+171
|\ \ \ \ \ \ \ | |/ / / / / /
| * | | | | | Merge 10.6 into 10.7Marko Mäkelä2021-12-0422-186/+171
| |\ \ \ \ \ \ | | |/ / / / /
| | * | | | | Merge 10.5 into 10.6Marko Mäkelä2021-12-0422-186/+171
| | |\ \ \ \ \ | | | |/ / / /
| | | * | | | Merge 10.4 into 10.5Marko Mäkelä2021-12-0322-185/+171
| | | |\ \ \ \ | | | | |/ / /
| | | | * | | MDEV-27160 Out of memory in main.long_uniquest-10.4-markoMarko Mäkelä2021-12-034-70/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A part of the test main.long_unique attempts to insert records with two 60,000,001-byte columns. Let us move that test into a separate file main.long_unique_big, declared as big test, so that it can be skipped in environments with limited memory.
| | | | * | | Fix bad galera testsJan Lindström2021-12-0118-112/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * galera_kill_applier : we should make sure that node has correct number of wsrep appliers * galera_bad_wsrep_new_cluster: This test restarts both nodes, so it is bad on mtr. Make sure it is run alone * galera_update_limit : Make sure we have PK when needed galera_as_slave_replay : bf abort was not consistent * galera_unicode_pk : Add wait_conditions so that all nodes are part of cluster and DDL and INSERT has replicated before any further operations are done. * galera_bf_abort_at_after_statement : Add wait_conditions to make sure all nodes are part of cluster and that DDL and INSERT has replicated. Make sure we reset DEBUG_SYNC.
* | | | | | | Merge 10.7 into 10.8Marko Mäkelä2021-12-022-93/+0
|\ \ \ \ \ \ \ | |/ / / / / /
| * | | | | | Merge 10.6 into 10.7Marko Mäkelä2021-12-022-93/+0
| |\ \ \ \ \ \ | | |/ / / / /
| | * | | | | Make the Optimizer Trace of reqular query and PS EXECUTE be identicalbb-10.6-spetruniaSergei Petrunia2021-11-292-93/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Print this piece when we've just made the choice to convert to semi-join. Also, print it when we've already made that choice before: transformation": { "select_id": 2, "from": "IN (SELECT)", "to": "semijoin", "chosen": true }
* | | | | | | MDEV-27154 allkeys.txt based tests for Unicode-4.0.0 and 5.2.0bb-10.8-barAlexander Barkov2021-12-027-0/+38031
| | | | | | |
* | | | | | | Merge 10.7 into 10.8Marko Mäkelä2021-11-2913-5/+524
|\ \ \ \ \ \ \ | |/ / / / / /
| * | | | | | Merge 10.6 into 10.7Marko Mäkelä2021-11-2913-5/+524
| |\ \ \ \ \ \ | | |/ / / / /
| | * | | | | Merge 10.5 into 10.6Marko Mäkelä2021-11-2913-5/+524
| | |\ \ \ \ \ | | | |/ / / /
| | | * | | | Merge 10.4 into 10.5Marko Mäkelä2021-11-2913-6/+423
| | | |\ \ \ \ | | | | |/ / /
| | | | * | | Merge 10.3 into 10.4Marko Mäkelä2021-11-2911-6/+234
| | | | |\ \ \ | | | | | |/ /
| | | | | * | MDEV-27134: Sporadic failure of DROP DATABASE testMarko Mäkelä2021-11-292-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let us create and drop a separate database for getting rid of the default database in the MDEV-22781 test.
| | | | | * | Merge 10.2 into 10.3Marko Mäkelä2021-11-2919-2/+756
| | | | | |\ \ | | | | | | |/
| | | | | | * MDEV-26972 MTR worker aborts after server restart failureSergei Golubchik2021-11-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | restore the old behavior where without a debugger mtr does not wait for mysqld to start. It was broken in feacc0aaf2
| | | | | | * add a test casest-10.2-markoSergei Golubchik2021-11-262-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-20330 Combination of "," (comma), cross join and left join fails to parse
| | | | | | * MDEV-27066: Fixed scientific notation parsing bugMarc Olivier Bergeron2021-11-242-0/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug occurs where the float token containing a dot with an 'e' notation was dropped from the request completely. This causes a manner of invalid SQL statements like: select id 1.e, char 10.e(id 2.e), concat 3.e('a'12356.e,'b'1.e,'c'1.1234e)1.e, 12 1.e*2 1.e, 12 1.e/2 1.e, 12 1.e|2 1.e, 12 1.e^2 1.e, 12 1.e%2 1.e, 12 1.e&2 from test; To be parsed correctly as if it was: select id, char(id), concat('a','b','c'), 12*2, 12/2, 12|2, 12^2, 12%2, 12&2 from test.test; This correct parsing occurs when e is followed by any of: ( ) . , | & % * ^ /
| | | | | | * MDEV-26915: SST scripts do not take log_bin_index setting into accountbb-10.2-MDEV-26915-galeraJulius Goryavsky2021-11-233-0/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, SST scripts assume that the filename specified in the --log-bin-index argument either does not contain an extension or uses the standard ".index" extension. Similar assumptions are used for the log_bin_index parameter read from the configuration file. This commit adds support for arbitrary extensions for the index file paths.
| | | | | | * MDEV-26064: mariabackup SST fails when starting with --innodb-force-recoveryJulius Goryavsky2021-11-235-0/+443
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the server is started with the --innodb-force-recovery argument on the command line, then during SST this argument can be passed to mariabackup only at the --prepare stage, and accordingly it must be removed from the --mysqld-args list (and it is not should be passed to mariabackup otherwise). This commit fixes a flaw in the SST scripts and add a test that checks the ability to run the joiner node in a configuration that uses --innodb-force-recovery=1.
| | | | | | * MDEV-26470 "No database" selected when using CTE in a subquery of DELETE ↵Igor Babaev2021-11-202-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | statement This bug led to reporting bogus messages "No database selected" for DELETE statements if they used subqueries in their WHERE conditions and these subqueries contained references to CTEs. The bug happened because the grammar rule for DELETE statement did not call the function LEX::check_cte_dependencies_and_resolve_references() and as a result of it references to CTEs were not identified as such. Approved by Oleksandr Byelkin <sanja@mariadb.com>
| | | | | | * MDEV-27086 "No database selected" when using UNION of CTEs to define tableIgor Babaev2021-11-202-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug concerned only CREATE TABLE statements of the form CREATE TABLE <table name> AS <with clause> <union>. For such a statement not all references to CTE used in <union> were resolved. As a result a bogus message was reported for the first unresolved reference. This happened because for such statements the function resolving references to CTEs LEX::check_cte_dependencies_and_resolve_references() was called prematurely in the parser. Approved by Oleksandr Byelkin <sanja@mariadb.com>
| | | | | | * MDEV-27098 Subquery using the ALL keyword on TIME columns produces a wrong ↵bb-10.2-barAlexander Barkov2021-11-202-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | result