summaryrefslogtreecommitdiff
path: root/mysql-test/main
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '10.6' into 10.7mariadb-10.7.810.7Oleksandr Byelkin2023-02-014-0/+39
|\
| * Fix results in real ps-protocol:Oleksandr Byelkin2023-02-014-0/+39
| | | | | | | | | | Starting wth 10.6 it goes via ps protocol so the subselect removed only once on prepare.
* | Merge branch '10.6' into 10.7Oleksandr Byelkin2023-01-3120-117/+1461
|\ \ | |/
| * Merge branch '10.5' into 10.6Oleksandr Byelkin2023-01-3120-117/+1461
| |\
| | * Merge branch '10.4' into 10.5Oleksandr Byelkin2023-01-2720-119/+1465
| | |\
| | | * MDEV-30218: Incorrect optimization for rowid_filtering, correctionSergei Petrunia2023-01-262-9/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable use of Rowid Filter optimization with eq_ref access. Use the following assumptions: - Assume index-only access cost is 50% of non-index-only access cost. - Take into account that "Eq_ref access cache" reduces the number of lookups eq_ref access will make. = This means the number of Rowid Filter checks is reduced also = Eq_ref access cost is computed using that assumption (see prev_record_reads() call), so we should use it in all cost ' computations.
| | | * Merge branch '10.3' into 10.4Oleksandr Byelkin2023-01-268-2/+609
| | | |\
| | | | * MDEV-30081 Crash with splitting from constant mergeable derived tableIgor Babaev2023-01-242-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug manifested itself in very rare situations when splitting optimization was applied to a materialized derived table with group clause by key over a constant meargeable derived table that was in inner part of an outer join. In this case the used tables for the key to access the split table incorrectly was evaluated to a not empty table map. Approved by Oleksandr Byelkin <sanja@mariadb.com>
| | | | * MDEV-30248 Infinite sequence of recursive calls when processing embedded CTEIgor Babaev2023-01-232-0/+295
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the patch for bug MDEV-30248 that unsatisfactorily resolved the problem of resolution of references to CTE. In some cases when such a reference has the same table name as the name of one of CTEs containing this reference the reference could be resolved incorrectly that led to an invalid select tree where units could be mutually dependent. This in its turn could lead to an infinite sequence of recursive calls or to falls into infinite loops. The patch also removes LEX::resolve_references_to_cte_in_hanging_cte() as with the new code for resolution of CTE references the call of this function is not needed anymore. Approved by Oleksandr Byelkin <sanja@mariadb.com>
| | | | * MDEV-15178: Filesort::make_sortorder: Assertion `pos->field != __null |Sergei Petrunia2023-01-232-2/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Initial patch by Varun Gupta. Amended and added comments). When the query has both 1. Aggregate functions that require sorting data by group, and 2. Window functions we need to use two temporary tables. The first temp.table will hold the join output. Then it is passed to filesort(). Reading it in sorted order allows to compute the aggregate functions. Then, we need to write their values into the second temp. table. Then, Window Function computation step can pass that to filesort() and read them in the order it needs. Failure to create the second temp. table would cause an assertion failure: window function could would not find where to get the values of the aggregate functions.
| | | | * MDEV-30052 Crash with a query containing nested WINDOW clausesIgor Babaev2023-01-202-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use SELECT_LEX to save lists for ORDER BY and GROUP BY before parsing WINDOW clauses / specifications. This is needed for proper parsing of a nested WINDOW clause when a WINDOW clause is used in a subquery contained in another WINDOW clause. Fix assignment of empty SQL_I_List to another one (in case of empty list next shoud point on first).
| | | * | MDEV-29199 Unique hash key is ignored upon INSERT ... SELECT into non-empty ↵Sergei Golubchik2023-01-202-96/+209
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MyISAM table disable bulk insert optimization if long uniques are used, because they need to read the table (index_read) after every inserted now. And bulk insert optimization might disable indexes. bulk insert is already disabled in other cases when there are chances that the table will be read duing the bulk insert.
| | | * | MDEV-29294 Assertion `functype() == ((Item_cond *) new_item)->functype()' ↵Oleg Smirnov2023-01-204-0/+208
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | failed in Item_cond::remove_eq_conds on SELECT Item_singlerow_subselect may be converted to Item_cond during optimization. So there is a possibility of constructing nested Item_cond_and or Item_cond_or which is not allowed (such conditions must be flattened). This commit checks if such kind of optimization has been applied and flattens the condition if needed
| | | * | MDEV-27653 long uniques don't work with unicode collationsAlexander Barkov2023-01-194-0/+376
| | | | |
* | | | | Merge branch '10.6' into 10.7Oleksandr Byelkin2023-01-186-0/+107
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.5' into 10.6Oleksandr Byelkin2023-01-182-0/+24
| |\ \ \ \ | | |/ / /
| | * | | MDEV-26392: Crash with json_get_path_next and 10.5.12Rucha Deodhar2023-01-182-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis: When we skip level when path is found, it changes the state of the json engine. This breaks the sequence for json_get_path_next() which is called at the end to ensure json document is valid and leads to crash. Fix: Use json_scan_next() at the end to check if json document has correct syntax (is valid).
| * | | | Merge 10.5 into 10.6Marko Mäkelä2023-01-174-0/+83
| |\ \ \ \ | | |/ / /
| | * | | ADD CONSTRAINT IF NOT EXISTS didn't work in SPSergei Golubchik2023-01-172-0/+51
| | | | | | | | | | | | | | | | | | | | "if not exists" must be stored in a separate read-only property
| | * | | MDEV-30080 Wrong result with LEFT JOINs involving constant tablesMonty2023-01-132-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reason things fails in 10.5 and above is that test_quick_select() returns -1 (impossible range) for empty tables if there are any conditions attached. This didn't happen in 10.4 as the cost for a range was more than for a table scan with 0 rows and get_key_scan_params() did not create any range plans and thus did not mark the range as impossible. The code that checked the 'impossible range' conditions did not take into account all cases of LEFT JOIN usage. Adding an extra check if the table is used with an ON condition in case of 'impossible range' fixes the issue.
* | | | | Merge 10.6 into 10.7Marko Mäkelä2023-01-1335-334/+1053
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2023-01-1335-334/+1053
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Marko Mäkelä2023-01-1330-310/+997
| | |\ \ \ | | | |/ /
| | | * | Merge 10.3 into 10.4Marko Mäkelä2023-01-133-0/+255
| | | |\ \ | | | | |/
| | | | * MDEV-28602 Wrong result with outer join, merged derived table and viewSergei Petrunia2023-01-113-0/+255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Variant 3, initial variant was by Rex Jonston) A LEFT JOIN with a constant as a column of the inner table produced wrong query result if the optimizer had to write the inner table column into a temp table. Query pattern: SELECT ... FROM (SELECT /*non-mergeable select*/ FROM t1 LEFT JOIN (SELECT 'Y' as Val) t2 ON ...) as tbl Fixed this by adding Item_direct_view_ref::save_in_field() which follows the pattern of Item_direct_view_ref's save_org_in_field(), save_in_result_field() and val_XXX() functions: * call check_null_ref() and handle NULL value * if we didn't get a NULL-complemented row, call Item_direct_ref's function.
| | | * | MDEV-19160 json_pretty() alias for json_detailed()Weijun-H2023-01-122-0/+32
| | | | |
| | | * | fixup for MDEV-19160Rucha Deodhar2023-01-122-8/+7
| | | | |
| | | * | Fixed failing test main.func_jsonMonty2023-01-122-0/+2
| | | | |
| | | * | MDEV-30345 DML does not find rows it is supposed toMonty2023-01-112-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This only happens with 'timestamp_column IN (select ...) The reason was a missing assignment in Item_cache_timestamp::cache_value()
| | | * | Merge branch '10.3' into 10.4Sergei Golubchik2023-01-1011-5/+271
| | | |\ \ | | | | |/
| | | | * MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/errorDaniel Black2023-01-094-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | regression from MDEV-29540 / 8c389393695. INSERT SELECT errors needed to be unconditionally ignored. As this touches the CREATE .. SELECT functionality, show the equalivent test there.
| | | | * MDEV-27624 Wrong result for nested left join using not_exists optimizationIgor Babaev2023-01-063-0/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug affected queries with nested left joins having the same last inner table such that not_exists optimization could be applied to the most inner outer join when optimizer chose to use join buffers. The bug could lead to producing wrong a result set. If the WHERE condition a query contains a conjunctive IS NULL predicate over a non-nullable column of an inner table of a not nested outer join then not_exists optimization can be applied to tho the outer join. With this optimization when looking for matches for a certain record from the outer table of the join the records of the inner table can be ignored right after the first match satisfying the ON condition is found. In the case of nested outer joins having the same last inner table this optimization still can be applied but only if all ON conditions of the embedding outer joins are satisfied. Such check was missing in the code that tried to apply not_exists optimization when join buffers were used for outer join operations. This problem has been already fixed in the patch for bug MDEV-7992. Yet there it was resolved only for the cases when join buffers were not used for outer joins. Approved by Oleksandr Byelkin <sanja@mariadb.com>
| | | | * MDEV-29988 group by fixSergei Golubchik2023-01-022-5/+18
| | | | |
| | | | * MDEV-29988: Major performance regression with 10.6.11Dmitry Shulga2023-01-022-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea is to put Item_direct_ref_to_item as a transparent and permanent wrapper before a string which require conversion. So that Item_direct_ref_to_item would be the only place where the pointer to the string item is stored, this pointer can be changed and restored during PS execution as needed. And if any permanent (subquery) optimization would need a pointer to the item, it'll use a pointer to the Item_direct_ref_to_item - which is a permanent item and won't go away.
| | | * | MDEV-17869 AddressSanitizer: use-after-poison in ↵Sergei Golubchik2023-01-092-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Item_change_list::rollback_item_tree_changes it's incorrect to use change_item_tree() to replace arguments of top-level AND/OR, because they (arguments) are stored in a List, so a pointer to an argument is in the list_node, and individual list_node's of top-level AND/OR can be deleted in Item_cond::build_equal_items(). In that case rollback_item_tree_changes() will modify the deleted object. Luckily, it's not needed to use change_item_tree() for top-level AND/OR, because the whole top-level item is copied and preserved in prep_where and prep_on, and restored from there. So, just don't. Additionally to the test case in the commit it fixes * ASAN failure of main.opt_tvc --ps * ASAN failure of main.having_cond_pushdown --ps
| | | * | don't set default value in temp table if NO_DEFAULT_VALUE_FLAGSergei Golubchik2023-01-093-5/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when an internal temporary table field is created from a real field, a new temp field should only copy a default from the source field when the latter has it
| | | * | MDEV-29890 Update with inner join false row count resultSergei Golubchik2023-01-092-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when creating a temp table field from an actual table field, these two fields are supposed to be mostly identical (except for BIT field storage), in particular, temp field should have the same default as the orig field, even if the sql_mode has been changed meanwhile (e.g. to include NO_ZERO_DATE)
| | | * | cleanupSergei Golubchik2023-01-094-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Helper class to swicth to relaxed checks during field copy. Temporarily.
| | | * | MDEV-19160 JSON_DETAILED output unnecessarily verboseWeijun-H2023-01-056-267/+289
| | | | |
| | * | | MDEV-30373 Wrong result with range accessMonty2023-01-115-3/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This issue was caused by the bug fix for MDEV-30325 Wrong result upon range query using index condition The bug could happen in the case of several overlapping key ranges with OR
* | | | | Merge 10.6 into 10.7Marko Mäkelä2023-01-104-0/+74
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2023-01-104-0/+74
| |\ \ \ \ | | |/ / /
| | * | | MDEV-30325 Wrong result upon range query using index condition wrong result ↵Monty2023-01-052-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | upon range query using index condition This was caused by a bug in key_or() when SEL_ARG* key1 has been cloned and is overlapping with SEL_ARG *key2 Cloning of SEL_ARG's happens only in very special cases, which is why this bug has remained undetected for years. It happend in the following query: SELECT COUNT(*) FROM lineitem force index (i_l_orderkey_quantity,i_l_shipdate) WHERE l_shipdate < '1994-01-01' AND l_orderkey < 800 OR l_quantity > 3 AND l_orderkey NOT IN ( 157, 1444 ); Because there are two different indexes that can be used and the code for IN causes a 'tree_or', which causes all SEL_ARG's to be cloned. Other things: - While checking the code, I found a bug in SEL_ARG::SEL_ARG(SEL_ARG &arg) - This was incrementing next_key_part->use_count as part of creating a copy of an existing SEL_ARG. This is however not enough as the 'reverse operation' when the copy is not needed is 'key2_cpy.increment_use_count(-1)', which does something completely different. Fixed by calling increment_use_count(1) in SEL_ARG::SEL_ARG.
| | * | | MDEV-30240 Wrong result upon aggregate function with SQL_BUFFER_RESULTMonty2023-01-032-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem was that when storing rows into a temporary table, MIN/MAX items that where marked as constants (as theire value had been computed at start of query) would be reset. Fixed by not reseting MIN/MAX items that are marked as const in Item_sum_min_max::clear().
* | | | | Merge 10.6 into 10.7Marko Mäkelä2023-01-0430-209/+196
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2023-01-0328-202/+160
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Marko Mäkelä2023-01-0328-202/+160
| | |\ \ \ | | | |/ /
| | | * | Merge 10.3 into 10.4Marko Mäkelä2023-01-0313-12/+68
| | | |\ \ | | | | |/
| | | | * MDEV-30151 parse error 1=2 not between/inSergei Golubchik2023-01-022-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the parser couldn't parse `1=2 not between 3 and 5` after `2` it expected only NOT2_SYM, but not NOT_SYM (visible from the sql_yacc.output file), which resulted in Syntax error ... near 'not between 3 and 4' The parser was confused by a rather low NOT_SYM precedence and %prec BETWEEN_SYM didn't resolve this confusion. As a fix, let's remove any %precedence from NOT_SYM and specify %prec explicitly in the only place where it matters for NOT_SYM. In other places, such as for NOT BETWEEN, NOT_SYM won't have a precedence, so bison won't be confused about it.
| | | | * MDEV-19071 Wrong results when using STDDEV_SAMP() and viewSergei Golubchik2023-01-022-0/+25
| | | | |