summaryrefslogtreecommitdiff
path: root/sql
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-30812 fixup: GCC 12.2.0 -Wmaybe-uninitializedMarko Mäkelä2023-05-111-17/+18
| | | | | best_access_path(): Simplify the logic for computing fanout. This fixes up commit 4329ec5d3b109cb0bcbee151b5800dc7b19d1945
* MDEV-31199: Assertion `field->table->stats_is_read' fails with ↵mariadb-10.6.13bb-10.6-releaseSergei Petrunia2023-05-051-0/+1
| | | | | | | | | | | | | hash_join_cardinality=on Derived table creation code would call Field::make_new_field() which would memcpy the Field object from the source table, including Field::read_stats. But the temp. table as a whole had table->stats_is_read=false. Which was correct but not consistent with Field::read_stats and caused an assertion. Fixed by making sure that Field::read_stats=NULL for fields in the new temporary (i.e. work) tables.
* Merge branch '10.5' into 10.6Oleksandr Byelkin2023-05-051-1/+1
|\
| * Merge branch '10.4' into 10.5mariadb-10.5.20bb-10.5-releaseOleksandr Byelkin2023-05-051-1/+1
| |\
| | * MDEV-31194: Server crash or assertion failure with join_cache_level=4mariadb-10.4.29Sergei Petrunia2023-05-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem, introduced in patch for MDEV-26301: When check_join_cache_usage() decides not to use join buffer, it must adjust the access method accordingly. For BNL-H joins this means switching from pseudo-"ref access"(with index=MAX_KEY) to some other access method. Failing to do this will cause assertions down the line when code that is not aware of BNL-H will try to initialize index use for ref access with index=MAX_KEY. The fix is to follow the regular code path to disable the join buffer for the join_tab ("goto no_join_cache") instead of just returning from check_join_cache_usage().
* | | Merge branch '10.5' into 10.6Oleksandr Byelkin2023-05-042-4/+9
|\ \ \ | |/ /
| * | Merge branch '10.4' into 10.5Oleksandr Byelkin2023-05-042-4/+9
| |\ \ | | |/
| | * MDEV-31189 Server crash or assertion failure in upon 2nd execution of PS ↵Oleksandr Byelkin2023-05-041-4/+8
| | | | | | | | | | | | | | | | | | | | | with views and HAVING Do not try to decide merge/materialize for derived if it was already decided (even if it is a view).
| | * MDEV-31164 default current_timestamp() not working when used INSERT ON ↵Sergei Golubchik2023-05-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | DUPLICATE KEY in some cases select_insert::store_values() must reset has_value_set bitmap before every row, just like mysql_insert() does. because ON DUPLICATE KEY UPDATE and triggers modify it
* | | Merge branch '10.5' into 10.6Oleksandr Byelkin2023-05-041-0/+6
|\ \ \ | |/ /
| * | Merge branch '10.4' into 10.5Oleksandr Byelkin2023-05-041-0/+6
| |\ \ | | |/
| | * MDEV-31181 Server crash in subselect_uniquesubquery_engine::print upon ↵Oleksandr Byelkin2023-05-041-0/+6
| | | | | | | | | | | | | | | | | | EXPLAIN EXTENDED DELETE Temporary fix to avoid the server crash.
* | | Merge branch '10.5' into 10.6Oleksandr Byelkin2023-05-043-61/+249
|\ \ \ | |/ /
| * | Merge branch '10.4' into 10.5Oleksandr Byelkin2023-05-033-45/+247
| |\ \ | | |/
| | * MDEV-26301: Split optimization refills: Optimizer Trace coverageSergei Petrunia2023-05-032-13/+61
| | | | | | | | | | | | Add Optimizer Trace printouts.
| | * MDEV-26301 Split optimization refills temporary table too many timesIgor Babaev2023-05-033-32/+186
| | | | | | | | | | | | | | | | | | | | | | | | This patch optimizes the number of refills for the lateral derived table to which a materialized derived table subject to split optimization is is converted. This optimized number of refills is now considered as the expected number of refills of the materialized derived table when searching for the best possible splitting of the table.
* | | Merge branch '10.5' into 10.6Oleksandr Byelkin2023-05-0323-172/+286
|\ \ \ | |/ /
| * | Merge branch '10.4' into 10.5Oleksandr Byelkin2023-05-031-2/+6
| |\ \ | | |/
| | * MDEV-29621 part 2 of post-merge fixes in galeraAndrei2023-05-031-1/+1
| | | | | | | | | | | | | | | (part 1 is in the previous commit) to [ pass ] galera.MDEV-18832, galera.MDEV-27862
| | * Protect a new condition (by Andrei)Oleksandr Byelkin2023-05-031-1/+5
| | |
| * | Merge branch 'bb-10.4-release' into bb-10.5-releaseOleksandr Byelkin2023-05-022-4/+10
| |\ \ | | |/
| | * Merge branch '10.4' into bb-10.4-releaseOleksandr Byelkin2023-05-022-4/+10
| | |\
| | | * MDEV-30838 Assertion `m_thd == _current_thd()'Daniele Sciascia2023-05-022-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Update wsrep-lib which contains fix for the assertion - Fix error handling for appending fragment to streaming log, make sure tables are closed after rollback. Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
| * | | MDEV-29621 manual merge from 10.4 -> 10.5Andrei2023-05-021-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | 1. log_event.cc stuff should go into log_event_server.cc 2. the test's wait condition is textually different in 10.5, fixed. 3. pre-exec 'optimistic' global var value is correct for 10.5 indeed.
| * | | Merge branch 'bb-10.4-release' into bb-10.5-releaseOleksandr Byelkin2023-05-0220-165/+248
| |\ \ \ | | |/ /
| | * | Merge branch '10.3' into 10.4Oleksandr Byelkin2023-05-026-16/+75
| | |\ \ | | | |/ | | |/|
| | | * MDEV-29621: Replica stopped by locks on sequenceAndrei2023-04-275-13/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using binlog_row_image=FULL with sequence table inserts, a replica can deadlock because it treats full inserts in a sequence as DDL statements by getting an exclusive lock on the sequence table. It has been observed that with parallel replication, this exclusive lock on the sequence table can lead to a deadlock where one transaction has the exclusive lock and is waiting on a prior transaction to commit, whereas this prior transaction is waiting on the MDL lock. This fix for this is on the master side, to raise FL_DDL flag on the GTID of a full binlog_row_image write of a sequence table. This forces the slave to execute the statement serially so a deadlock cannot happen. A test verifies the deadlock also to prove it happen on the OLD (pre-fixes) slave. OLD (buggy master) -replication-> NEW (fixed slave) is provided. As the pre-fixes master's full row-image may represent both SELECT NEXT VALUE and INSERT, the parallel slave pessimistically waits for the prior transaction to have committed before to take on the critical part of the second (like INSERT in the test) event execution. The waiting exploits a parallel slave's retry mechanism which is controlled by `@@global.slave_transaction_retries`. Note that in order to avoid any persistent 'Deadlock found' 2013 error in OLD -> NEW, `slave_transaction_retries` may need to be set to a higher than the default value. START-SLAVE is an effective work-around if this still happens.
| | * | MDEV-31153 New methods Schema::make_item_func_* for REPLACE, SUBSTRING, TRIMAlexander Barkov2023-04-297-74/+170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding virtual methods to class Schema: make_item_func_replace() make_item_func_substr() make_item_func_trim() This is a non-functional preparatory change for MDEV-27744.
| | * | Adding "const" qualifiers to a few trivial Lex_input_string methodsAlexander Barkov2023-04-292-23/+23
| | | |
| | * | MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogrambb-10.4-mdev31067-variant2Sergei Petrunia2023-04-281-39/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Variant #2. When Histogram::point_selectivity() sees that the point value of interest falls into one bucket, it tries to guess whether the bucket has many different (unpopular) values or a few popular values. (The number of rows is fixed, as it's a Height-balanced histogram). The basis for this guess is the "width" of the value range the bucket covers. Buckets covering wider value ranges are assumed to contain values with proportionally lower frequencies. This is just a [brave] guesswork. For a very narrow bucket, it may produce an estimate that's larger than total #rows in the bucket or even in the whole table. Remove the guesswork and replace it with basic logic: return either the per-table average selectivity of col=const, or selectivity of one bucket, whichever is lower.
| | * | MDEV-22756 SQL Error (1364): Field 'DB_ROW_HASH_1' doesn't have a default valueSergei Golubchik2023-04-281-1/+1
| | | | | | | | | | | | | | | | exclude generated columns from the "has default value" check
| | * | MDEV-31113 Server crashes in store_length / ↵bb-10.4-mdev-31113Oleg Smirnov2023-04-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Type_handler_string_result::make_sort_key with DISTINCT and group function Fix-up for commit 476b24d084e7e717310155bb986eb086d3c1e1a6 Author: Monty Date: Thu Feb 16 14:19:33 2023 +0200 MDEV-20057 Distinct SUM on CROSS JOIN and grouped returns wrong result which misses initializing of sorder->suffix_length. In this commit the initialization is implemented by passing MY_ZEROFILL flag to the allocation of SORT_FIELD elements
| | * | return accidentally removed in 45d4f6b97b4811b1b7783dcd19526be1dbb196dc commentbb-10.4-MDEV-30889Oleksandr Byelkin2023-04-271-0/+6
| | | |
| | * | MDEV-30889: 3 - Item_in_optimizer leakOleksandr Byelkin2023-04-265-24/+33
| | | | | | | | | | | | | | | | Keep Item_in_optimizer cache always (but only once) in statement memory.
| | * | MDEV-30889: 2 - Allocation in TABLE_SHARE::init_from_sql_statement_stringOleksandr Byelkin2023-04-261-15/+0
| | | | | | | | | | | | | | | | | | | | Fix leack in TABLE_SHARE::init_from_sql_statement_string by removing uneeded switching arenas.
| | * | MDEV-30889: 1 - Allocation in Item_subselect::mark_as_dependentOleksandr Byelkin2023-04-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Fix leack in Item_subselect::mark_as_dependent (allocation of temporary list in statement memory inctroduced in f4d552104364fe195237f39862d91f657c7a34cb )
* | | | MDEV-31162 Crash for query using ROWNUM over multi-table view with ORDER BYbb-10.6-igorIgor Babaev2023-05-024-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug could cause a crash of the server when processing a query with ROWNUM() if it used in its FROM list a reference to a mergeable view defined as SELECT over more than one table that contained ORDER BY clause. When a mergeable view with ORDER BY clause and without LIMIT clause is used in the FROM list of a query that does not have ORDER BY clause the ORDER BY clause of the view is moved to the query. The code that performed this transformation forgot to delete the moved ORDER BY list from the view. If a query contains ROWNUM() and uses a mergeable multi-table view with ORDER BY then according to the current code of TABLE_LIST::init_derived() the view has to be forcibly materialized. As the query and the view shared the same items in its ORDER BY lists they could not be properly resolved either in the query or in the view. This led to a crash of the server. This patch has returned back the original signature of LEX::can_not_use_merged() to comply with 10.4 code of the condition that checks whether a megeable view has to be forcibly materialized. Approved by Oleksandr Byelkin <sanja@mariadb.com>
* | | | MDEV-31143 Crash for query using ROWNUM() over view with ORDER BYIgor Babaev2023-04-302-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When processing a query over a mergeable view at some conditions checked at prepare stage it may be decided to materialize the view rather than to merge it. Before this patch in such case the field 'derived' of the TABLE_LIST structure created for the view remained set to 0. As a result the guard condition preventing range analysis for materialized views did not work properly. This led to a call of some handler method for the temporary table created to contain the view's records that was supposed to be used only for opened tables. However temporary tables created for materialization of derived tables or views are not opened yet when range analysis is performed. Approved by Oleksandr Byelkin <sanja@mariadb.com>
* | | | MDEV-30812: Improve output cardinality estimates for hash joinbb-10.6-mdev30812Sergei Petrunia2023-04-283-33/+196
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce @@optimizer_switch flag: hash_join_cardinality When it is on, use EITS statistics to produce tighter bounds for hash join output cardinality. Amended by Monty. Reviewed by: Monty <monty@mariadb.org>
* | | | MDEV-31073 Server crash, assertion `table != 0 && view->field_translation != ↵Oleksandr Byelkin2023-04-274-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 0' failure with ROWNUM and view Now the same rule applied to vews and derived tables. So we should allow merge of views (and derived) in queries with rownum, because it do not change results, only makes query plans better.
* | | | Merge 10.5 into 10.6Marko Mäkelä2023-04-276-20/+41
|\ \ \ \ | |/ / /
| * | | Merge 10.4 into 10.5Marko Mäkelä2023-04-276-20/+41
| |\ \ \ | | |/ /
| | * | MDEV-11356 Option skip-core-file does not workSergei Golubchik2023-04-262-9/+3
| | | | | | | | | | | | | | | | | | | | remove ancient hard-coded treatment of --core-file. This enables normal my_getopt behavior for the already existing sysvar
| | * | MDEV-30620 Trying to lock uninitialized LOCK_parallel_entryAndrei2023-04-251-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The error was seen by a number of mtr tests being caused by overdue initialization of rpl_parallel::LOCK_parallel_entry. Specifically, SHOW-SLAVE-STATUS might find in rpl_parallel::workers_idle() a gtid domain hash entry already inserted whose mutex had not done mysql_mutex_init(). Fixed with swapping the mutex init and the its entry's stack insertion. Tested with a generous number of `mtr --repeat` of a few of the reported to fail tests, incl rpl.parallel_backup.
| | * | MDEV-30430: Enabling system versioning on tables without primary key breaks ↵Brandon Nesterenko2023-04-241-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | replication When replicating MDL events for a table that uses system versioning without primary keys, ensure that for data sets with duplicate records, the updates to these records with duplicates are enacted on the correct row. That is, there was a bug (reported in MDEV-30430) such that the function to find the row to update would stop after finding the first matching record. However, in the absence of primary keys, the version of the record is needed to compare the row to ensure we are updating the correct one. The fix, therefore, updates the record comparison functionality to use system version columns when there are no primary keys on the table. Reviewed By: ============ Andrei Elkin <andrei.elkin@mariadb.com>
| | * | MDEV-28798: Previously Binlog Encrypted Master Segfaults on Binlog Dump with ↵Brandon Nesterenko2023-04-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using_Gtid=Slave_Pos Problem: ======== A master can segfault if it can't set up decryption for its binary log during a binlog dump with Using_Gtid=Slave_Pos. If slave connects using GTID mode, the master will call into log.cc::get_gtid_list_event(), which iterate through binlog events looking for a Gtid_list_log_event. On an encrypted binlog that the master cannot decrypt, the first event will be a START_ENCRYPTION_EVENT which will call into the following decryption branch if (fdle->start_decryption((Start_encryption_log_event*) ev)) errormsg= ‘Could not set up decryption for binlog.’; The event iteration however, does not stop in spite of this error. The master will try to read the next event, but segfault while trying to decrypt it because decryption failed to initialize. Solution: ======== Break the event iteration if decryption cannot be set up. Reviewed By: ============ Andrei Elkin <andrei.elkin@mariadb.com>
| | * | MDEV-31102 Crash when pushing condition into view defined as unionIgor Babaev2023-04-241-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug could manifest itself at the first execution of prepared statement created for queries using a materialized view defined as union. A crash could happen for sure if the query contained a condition pushable into the view and this condition was over the column defined via a complex string expression requiring implicit conversion from one charset to another for some of its sub-expressions. The bug could cause crashes when executing PS for some other queries whose optimization needed building clones for such expressions. This bug was introduced in the patch for MDEV-29988 where the class Item_direct_ref_to_item was added. The implementations of the virtual methods get_copy() and build_clone() were invalid for the class and this could cause crashes after the method build_clone() was called for expressions containing objects of the Item_direct_ref_to_item type. Approved by Sergei Golubchik <serg@mariadb.com>
* | | | Merge 10.5 into 10.6Marko Mäkelä2023-04-2513-49/+126
|\ \ \ \ | |/ / /
| * | | MDEV-31038: Parallel Replication Breaks if XA PREPARE Fails Updating Slave ↵Brandon Nesterenko2023-04-243-22/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GTID State If a replica failed to update the GTID slave state when committing an XA PREPARE, the replica would retry the transaction and get an out-of-order GTID error. This is because the commit phase of an XA PREPARE is bifurcated. That is, first, the prepare is handled by the relevant storage engines. Then second, the GTID slave state is updated as a separate autocommit transaction. If the second phase fails, and the transaction is retried, then the same transaction is attempted to be committed again, resulting in a GTID out-of-order error. This patch fixes this error by immediately stopping the slave and reporting the appropriate error. That is, there was logic to bypass the error when updating the GTID slave state table if the underlying error is allowed for retry on a parallel slave. This patch adds a parameter to disallow the error bypass, thereby forcing the error state to still happen. Reviewed By ============ Andrei Elkin <andrei.elkin@mariadb.com>
| * | | Merge branch '10.4' into 10.5Oleksandr Byelkin2023-04-2412-27/+75
| |\ \ \ | | |/ /