summaryrefslogtreecommitdiff
path: root/sql
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-25672 table alias from previous statement interferes later commandsSergei Golubchik2021-06-021-1/+1
| | | | | only perform the "correct table name" check for *new* generated columns, but not for already existing ones - they're guaranteed to be valid
* MDEV-25635 Assertion failure when pushing from HAVING into WHERE of viewIgor Babaev2021-06-021-1/+4
| | | | | | | | | | | | | | | | This bug could manifest itself after pushing a where condition over a mergeable derived table / view / CTE DT into a grouping view / derived table / CTE V whose item list contained set functions with constant arguments such as MIN(2), SUM(1) etc. In such cases the field references used in the condition pushed into the view V that correspond set functions are wrapped into Item_direct_view_ref wrappers. Due to a wrong implementation of the virtual method const_item() for the class Item_direct_view_ref the wrapped set functions with constant arguments could be erroneously taken for constant items. This could lead to a wrong result set returned by the main select query in 10.2. In 10.4 where a possibility of pushing condition from HAVING into WHERE had been added this could cause a crash. Approved by Sergey Petrunya <sergey.petrunya@mariadb.com>
* MDEV-25730 fixup: GCC -Og -Wmaybe-uninitializedMarko Mäkelä2021-06-021-0/+1
| | | | | Silence a warning about an uninitialized variable that was introduced by commit d8fa71a089aa5cbe569e7f8b6fa67326a9ecab2b.
* MDEV-25576: The statement EXPLAIN running as regular statement and as ↵Dmitry Shulga2021-05-304-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | prepared statement produces different results for UPDATE with subquery Both EXPLAIN and EXPLAIN EXTENDED statements produce different results set in case it is run in normal way and in PS mode for the statements UPDATE/DELETE with subquery. The use case below reproduces the issue: MariaDB [test]> CREATE TABLE t1 (c1 INT KEY) ENGINE=MyISAM; Query OK, 0 rows affected (0,128 sec) MariaDB [test]> CREATE TABLE t2 (c2 INT) ENGINE=MyISAM; Query OK, 0 rows affected (0,023 sec) MariaDB [test]> CREATE TABLE t3 (c3 INT) ENGINE=MyISAM; Query OK, 0 rows affected (0,021 sec) MariaDB [test]> EXPLAIN EXTENDED UPDATE t3 SET c3 = -> ( SELECT COUNT(d1.c1) FROM ( SELECT a11.c1 FROM t1 AS a11 -> STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 JOIN t1 AS a12 -> ON a12.c1 = a11.c1 ) d1 ); +------+-------------+-------+------+---------------+------+---------+------+------+----------+--------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +------+-------------+-------+------+---------------+------+---------+------+------+----------+--------------------------------+ | 1 | PRIMARY | t3 | ALL | NULL | NULL | NULL | NULL | 0 | 100.00 | | | 2 | SUBQUERY | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Impossible WHERE noticed after reading const tables +------+-------------+-------+------+---------------+------+---------+------+------+----------+--------------------------------+ 2 rows in set (0,002 sec) MariaDB [test]> PREPARE stmt FROM -> EXPLAIN EXTENDED UPDATE t3 SET c3 = -> ( SELECT COUNT(d1.c1) FROM ( SELECT a11.c1 FROM t1 AS a11 -> STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 JOIN t1 AS a12 -> ON a12.c1 = a11.c1 ) d1 ); Query OK, 0 rows affected (0,000 sec) Statement prepared MariaDB [test]> EXECUTE stmt; +------+-------------+-------+------+---------------+------+---------+------+------+----------+--------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +------+-------------+-------+------+---------------+------+---------+------+------+----------+--------------------------------+ | 1 | PRIMARY | t3 | ALL | NULL | NULL | NULL | NULL | 0 | 100.00 | | | 2 | SUBQUERY | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | no matching row in const table | +------+-------------+-------+------+---------------+------+---------+------+------+----------+--------------------------------+ 2 rows in set (0,000 sec) The reason by that different result sets are produced is that on execution of the statement 'EXECUTE stmt' the flag SELECT_DESCRIBE not set in the data member SELECT_LEX::options for instances of SELECT_LEX that correspond to subqueries used in the UPDTAE/DELETE statements. Initially, these flags were set on parsing the statement PREPARE stmt FROM "EXPLAIN EXTENDED UPDATE t3 SET ..." but latter they were reset before starting real execution of the parsed query during handling the statement 'EXECUTE stmt'; So, to fix the issue the functions mysql_update()/mysql_delete() have been modified to set the flag SELECT_DESCRIBE forcibly in the data member SELECT_LEX::options for the primary SELECT_LEX of the UPDATE/DELETE statement.
* Cleanup: Remove handler::update_table_comment()Marko Mäkelä2021-05-273-29/+3
| | | | | | | | | | | The only call of the virtual member function handler::update_table_comment() was removed in commit 82d28fada7dc928564aefac802400c6684c11917 (MySQL 5.5.53) but the implementation was not removed. The only non-trivial implementation was for InnoDB. The information is now returned via handler::get_foreign_key_create_info() and ha_statistics::delete_length.
* MDEV-25730: maria.repair test fails with valgrindSergei Golubchik2021-05-251-2/+7
| | | | | | | | | cherry-pick commit: 1fff2398ef3dda1a7e8404f18e4e165823bd4e0a MDEV-22530 post push fixes from 10.6. Followup. If the KILL happens - report it as a failure, don't eat it up silently. Note that this has to be done after `table_name` is populated, so that the error message could show it.
* CONNECT: move jar files to /usr/share and include them in DEBsSergei Golubchik2021-05-221-1/+1
|
* MDEV-23886 Reusing CTE inside a function fails with table doesn't existIgor Babaev2021-05-2114-208/+574
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the code existed just before this patch binding of a table reference to the specification of the corresponding CTE happens in the function open_and_process_table(). If the table reference is not the first in the query the specification is cloned in the same way as the specification of a view is cloned for any reference of the view. This works fine for standalone queries, but does not work for stored procedures / functions for the following reason. When the first call of a stored procedure/ function SP is processed the body of SP is parsed. When a query of SP is parsed the info on each encountered table reference is put into a TABLE_LIST object linked into a global chain associated with the query. When parsing of the query is finished the basic info on the table references from this chain except table references to derived tables and information schema tables is put in one hash table associated with SP. When parsing of the body of SP is finished this hash table is used to construct TABLE_LIST objects for all table references mentioned in SP and link them into the list of such objects passed to a pre-locking process that calls open_and_process_table() for each table from the list. When a TABLE_LIST for a view is encountered the view is opened and its specification is parsed. For any table reference occurred in the specification a new TABLE_LIST object is created to be included into the list for pre-locking. After all objects in the pre-locking have been looked through the tables mentioned in the list are locked. Note that the objects referenced CTEs are just skipped here as it is impossible to resolve these references without any info on the context where they occur. Now the statements from the body of SP are executed one by one that. At the very beginning of the execution of a query the tables used in the query are opened and open_and_process_table() now is called for each table reference mentioned in the list of TABLE_LIST objects associated with the query that was built when the query was parsed. For each table reference first the reference is checked against CTEs definitions in whose scope it occurred. If such definition is found the reference is considered resolved and if this is not the first reference to the found CTE the the specification of the CTE is re-parsed and the result of the parsing is added to the parsing tree of the query as a sub-tree. If this sub-tree contains table references to other tables they are added to the list of TABLE_LIST objects associated with the query in order the referenced tables to be opened. When the procedure that opens the tables comes to the TABLE_LIST object created for a non-first reference to a CTE it discovers that the referenced table instance is not locked and reports an error. Thus processing non-first table references to a CTE similar to how references to view are processed does not work for queries used in stored procedures / functions. And the main problem is that the current pre-locking mechanism employed for stored procedures / functions does not allow to save the context in which a CTE reference occur. It's not trivial to save the info about the context where a CTE reference occurs while the resolution of the table reference cannot be done without this context and consequentially the specification for the table reference cannot be determined. This patch solves the above problem by moving resolution of all CTE references at the parsing stage. More exactly references to CTEs occurred in a query are resolved right after parsing of the query has finished. After resolution any CTE reference it is marked as a reference to to derived table. So it is excluded from the hash table created for pre-locking used base tables and view when the first call of a stored procedure / function is processed. This solution required recursive calls of the parser. The function THD::sql_parser() has been added specifically for recursive invocations of the parser.
* MDEV-22462: Item_in_subselect::create_single_in_to_exists_cond(JOIN *, Item ↵Sergei Petrunia2021-05-211-23/+21
| | | | | | | | | | | | | **, Item **): Assertion `false' failed. Item_in_subselect::create_single_in_to_exists_cond() should handle the case where the subquery is a table-less select but it is not a result of a UNION. (Table-less subqueries like "(SELECT 1)" are "substituted" with their select list, but table-less subqueries with WHERE or HAVING clause, like "(SELECT 1 WHERE ...)" are not substituted. They are handled with regular execution path)
* MDEV-25462: Assertion `m_status == DA_ERROR || m_status == DA_OK ||Rucha Deodhar2021-05-202-1/+8
| | | | | | | | | | | | | m_status == DA_OK_BULK' failed in Diagnostics_area::message from get_schema_tables_record Analysis: SET NAMES changes character set for character_set_client, character_set_connection, character_set_results to 'filename'. The .frm file of view has @xx sequences in the SELECT query, which give parsing error because 'filename' character set is not parser friendly. When we get parsing error (ER_PARSE_ERROR), we directly return true without setting error status. This is caught later in assertion. Fix: Disallow 'filename' character set in SET NAMES because it is not parser friendly.
* MDEV-25728: mysqld --help --verbose creates a log-bin-index fileDaniel Black2021-05-201-2/+2
| | | | | | | | | | | | | before change test: strace -fe trace=file -o /tmp/f.strace sql/mysqld --datadir=/tmp/d --log-bin=foo-bin --help --verbose && ls -la /tmp/ ... 'mysqladmin variables' instead of 'mysqld --verbose --help'. total 0 drwxrwxr-x. 2 dan dan 60 May 19 18:05 . drwxrwxrwt. 27 root root 640 May 19 18:03 .. -rw-rw----. 1 dan dan 0 May 19 18:05 foo-bin.index
* MDEV-25629: Crash in get_sort_by_table() in subquery with order by having ↵Sergei Petrunia2021-05-191-0/+1
| | | | | | | | | | | outer ref In Item_field::fix_fields(): when the item was resolved to an Item_field in the SELECT's select_list, copy the Item_field's "depended_from" field. Failure to do so caused the item to have incorrect attributes: it pointed to a Field in an upper select but used_tables() didn't return OUTER_REF_TABLE_BIT.
* MDEV-22530: Aborting OPTIMIZE TABLE still logs in binary log and replicates ↵Sujatha2021-05-171-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to the Slave server. Problem: ======== Aborting OPTIMIZE TABLE still logs in binary logs and replicates to the Slave server. "Optimize table" command under execution, is killed by using "Ctrl-C" as shown below. MariaDB [test]> optimize table t2; ^CCtrl-C -- query killed. Continuing normally. In spite of query execution being interrupted the query gets written to binary log. Analysis: ======== Admin command execution logic is not handling KILL command, hence it ignores the KILL command and completes its execution. Fix: === Check for thread killed notification, during admin command execution and handle it. If thread kill occurs prior to any table modification the query will not be written to binary log. If kill happens after at least one table is modified then the query will be written to binary log. Ex: command in execution is 'OPTIMIZE TABLE t1,t2' and the thread kill happens after t1 table is modified then 'OPTIMIZE TABLE t1,t2' will be written to binary log as admin commands will not make the slave to diverge from master.
* MDEV-17515: GTID Replication in optimistic mode deadlockSujatha2021-05-174-36/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: ======= In slave_parallel_mode=optimistic configuration, when admin commands and DML operation on the same table are scheduled simultaneously for execution, it results in lock conflict and slave server either hangs due to deadlock or goes down with an assert. Analysis: ======== Admin commands OPTIMIZE, REPAIR and ANALYZE are written to binary log as ordinary transactions. When 'slave_parallel_mode' is 'optimistic' DMLs are allowed to run in parallel. But these locks are not detected by parallel replication deadlock detection-and-handling mechanism. At times they result in deadlock or assertion. Fix: === Flag admin commands as DDL in Gtid_log_event at the time of writing to binary log. Add a new bit EXECUTED_TABLE_ADMIN_CMD to 'm_unsafe_rollback_flags'. During 'mysql_admin_table' command execution it accepts a list of tables to be processed and executes them in a loop. Upon successful execution enable 'EXECUTED_TABLE_ADMIN_CMD' bit in thd->transaction.stmt_unsafe_rollback_flags. Gtid_log_event constructor will notice this flag and mark the current transaction with 'FL_DDL' flag. Gtid_log_events marked as FL_DDL will not be scheduled parallel execution, on the slave. They will execute in isolation to prevent deadlocks. Note: Removed the call to 'trans_commit_implicit' from 'mysql_admin_table' function as 'mysql_execute_command' will take care of invoking 'trans_commit_implicit'.
* MDEV-25681: --relay-log{,-index} missing warningDaniel Black2021-05-171-2/+2
| | | | | | | | | No longer a MySQL server, "his" is the wrong pronoun for a server. Thanks Michael Newton for highlighting these problems Also changed slave -> replica.
* MDEV-25669: SST scripts should check all server groups in config filesJulius Goryavsky2021-05-151-125/+80
| | | | | | | | | | | | | | | | | | | | | | | 1) This commit implements reading all sections from configuration files while looking for the current value of any server variable, which were previously only read from the [mysqld.suffix] group and from [mysqld], but not from other groups such as [mariadb.suffix], [mariadb] or, for example, [server]. 2) This commit also fixes misrecognition of some parameters when parsing a command line containing a special marker for the end of the list of options ("--") or when short option names (such as "-s", "-a" and "-h arg") chained together (like a "-sah arg"). Such parameters can be passed to the SST script in the list of arguments after "--mysqld-args" if the server is started with a complex set of options - this was revealed during manual testing of changes to read configuration files. 3) The server-side preparation code for the "--mysqld-args" option list has also been simplified to make it easier to change in the future (if needed), and has been improved to properly handle the special backquote ("`") character in the argument values.
* MDEV-25682 Explain shows an execution plan different from actually executedIgor Babaev2021-05-141-1/+1
| | | | | | | | If a select query contained an ORDER BY clause that followed a LIMIT clause or an ORDER BY clause or ORDER BY with LIMIT the EXPLAIN output for the query showed an execution plan different from that was actually executed. Approved by Roman Nozdrin <roman.nozdrin@mariadb.com>
* MDEV-22370 safe_mutex: Trying to lock uninitialized mutex at ↵Sachin Kumar2021-05-143-1/+18
| | | | | | | | | | | | | /data/src/10.4-bug/sql/rpl_parallel.cc, line 470 upon shutdown during FTWRL Problem:- When we issue FTWRL with shutdown in parallel, there is race between FTWRL and shutdown. Shutdown might destroy the mutex (pool->LOCK_rpl_thread_pool) before FTWRL can lock it. So we can get crash on FTWRL thread Solution:- mysql_mutex_destroy(pool->LOCK_rpl_thread_pool) should wait for FTWRL thread to complete its work , and then destroy. So slave_prepare_for_shutdown will just deactivate the pool, and mutex is destroyed later in end_slave()
* MDEV-20821 parallel slave server shutdown hangAndrei Elkin2021-05-141-0/+3
| | | | | | | | | | | Parallel slave server shutdown found to be hanging in close_connections() triggered by shutdown due to a slave worker thread would not be notified to exit in case the worker was sitting idle. Fixed with destroying the worker pool earlier that is in slave_prepare_for_shutdown() when all their driver threads have already left. A test file is added to simulate the bug condition as well as check multi-sourced and not-idle worker cases.
* XA PREPARE and SHOW STATUSSergei Golubchik2021-05-081-7/+13
| | | | | | | XA transaction only allows to access data in specific states, in ACTIVE, but not in IDLE or PREPARE. But even then one should be able to run SHOW STATUS.
* MDEV-25418: Improve mariabackup SST script compliance with native MariaDB ↵Alexey Yurchenko2021-05-061-44/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSL practices and configuration. 1. Pass joiner's authentication information to donor together with address in State Transfer Request. This allows joiner to authenticate donor on connection. Previously joiner would accept data from anywhere. 2. Deprecate custom SSL configuration variables tca, tcert and tkey in favor of more familiar ssl-ca, ssl-cert and ssl-key. For backward compatibility tca, tcert and tkey are still supported. 3. Allow falling back to server-wide SSL configuration in [mysqld] if no SSL configuration is found in [sst] section of the config file. 4. Introduce ssl-mode variable in [sst] section that takes standard values and has following effects: - old-style SSL configuration present in [sst]: no effect otherwise: - ssl-mode=DISABLED or absent: retains old, backward compatible behavior and ignores any other SSL configuration - ssl-mode=VERIFY*: verify joiner's certificate and CN on donor, verify donor's secret on joiner (passed to donor via State Transfer Request) BACKWARD INCOMPATIBLE BEHAVIOR - anything else enables new SSL configuration convetions but does not require verification ssl-mode should be set to VERIFY only in a fully upgraded cluster. Examples: [mysqld] ssl-cert=/path/to/cert ssl-key=/path/to/key ssl-ca=/path/to/ca [sst] -- server-wide SSL configuration is ignored, SST does not use SSL [mysqld] ssl-cert=/path/to/cert ssl-key=/path/to/key ssl-ca=/path/to/ca [sst] ssl-mode=REQUIRED -- use server-wide SSL configuration for SST but don't attempt to verify the peer identity [sst] ssl-cert=/path/to/cert ssl-key=/path/to/key ssl-ca=/path/to/ca ssl-mode=VERIFY_CA -- use SST-specific SSL configuration for SST and require verification on both sides Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
* MDEV-21603 Crashing SHOW TABLES with derived table in WHERE conditionSergei Golubchik2021-05-045-18/+6
| | | | | | | | | | When you only need view structure, don't call handle_derived with DT_CREATE and rely on its internal hackish check to skip DT_CREATE. Because handle_derived is called from many different places, and this internal hackish check is indiscriminative. Instead, just don't ask handle_derived to do DT_CREATE if you don't want it to do DT_CREATE.
* MDEV-16146: MariaDB slave stops with following errors.Sujatha2021-04-303-10/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: ======== 180511 11:07:58 [ERROR] Slave I/O: Unexpected master's heartbeat data: heartbeat is not compatible with local info;the event's data: log_file_name mysql-bin.000009 log_pos 1054262041, Error_code: 1623 Analysis: ========= In replication setup when master server doesn't have any events to send to slave server it sends an 'Heartbeat_log_event'. This event carries the current binary log filename and offset details. The offset values is stored within 4 bytes of event header. When the size of binary log is higher than UINT32_MAX the log_pos values will not fit in 4 bytes memory. It overflows and hence slave stops with an error. Fix: === Since we cannot extend the common_header of Log_event class, a greater than 4GB value of Log_event::log_pos is made to be transported with a HeartBeat event's sub-header. Log_event::log_pos in such case is set to zero to indicate that the 8 byte sub-header is allocated in the event. In case of cross version replication following behaviour is expected OLD - Server without fix NEW - Server with fix OLD<->NEW : works bidirectionally as long as the binlog offset is (normally) within 4GB. When log_pos > UINT32_MAX OLD->NEW : The 'log_pos' is bound to overflow and NEW slave may report an invalid event/incompatible heart beat event error. NEW->OLD : Since patched server sets log_pos=0 on overflow, OLD slave will report invalid event error.
* Another correction of the patch for MDEV-24823.Igor Babaev2021-04-281-2/+3
| | | | | | | | | This commits replaces the call of the function setup_tables() with a call of the function setup_tables_and_check_access() in the method Multiupdate_prelocking_strategy::handle_end(). There is no known bug that would require this change. However the change aligns this piece of code with the code existed before the patch for MDEV-24823.
* Bug#29363867: LOST CONNECTION TO MYSQL SERVER DURING QUERYbb-10.2-BUG29363867Oleksandr Byelkin2021-04-281-4/+24
| | | | | | | | | | | | The problem is that sharing default expression among set instruction leads to attempt access result field of function created in other instruction runtime MEM_ROOT and already freed (a bit different then MySQL problem). Fix is the same as in MySQL (but no optimisation for constant), turn DECLARE a, b, c type DEFAULT expr; to DECLARE a type DEFAULT expr, b type DEFAULT a, c type DEFAULT a;
* MDEV-25258 : SET PASSWORD command fail with wsrep apiJan Lindström2021-04-281-1/+5
| | | | | Problem was that we should skip strict password validation on applier nodes similarly as is done for slave nodes.
* MDEV-19198 - DBUG assert in CREATE IF NOT EXIST under LOCK TABLES WRITEVladislav Vaintroub2021-04-281-1/+8
| | | | | Relax the assert condition. A locked table that did existed prior to CREATE IF NOT EXIST, retains the MDL_NO_SHARED_READ_WRITE MDL lock prio.
* Bug#29363867: LOST CONNECTION TO MYSQL SERVER DURING QUERYSergei Golubchik2021-04-273-27/+19
| | | | | | | | | plugin variables in SET only locked the plugin till the end of the statement. If SET with a plugin variable was prepared, it was possible to uninstall the plugin before EXECUTE. Then EXECUTE would crash, trying to resolve a now-invalid pointer to a disappeared variable. Fix: keep plugins locked until the prepared statement is closed.
* Bug #31674599: THE UDF_INIT() FUNCTION CAUSE SERVER CRASHSergei Golubchik2021-04-271-3/+3
|
* MDEV-22928 InnoDB fails to fetch index type when index mismatch happensThirunarayanan Balathandayuthapani2021-04-271-0/+1
| | | | | | InnoDB fails to fetch the index type when innodb dictionary doesn't match with frm. InnoDB should return corrupted if it can't find the index in ha_innobase::index_type().
* MDEV-24583 SELECT aborts after failed REPLACE into table with vcolNikita Malyavin2021-04-272-4/+6
| | | | | | | table->move_fields wasn't undone in case of error. 1. move_fields is unconditionally undone even when error is occurred 2. cherry-pick an assertion in `ptr_in_record`, which is already in 10.5
* MDEV-16962 Assertion failed in open_purge_table upon concurrent ALTER/FLUSHNikita Malyavin2021-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | So we are having a race condition of three of threads, resulting in a deadlock backoff in purge, which is unexpected. More precisely, the following happens: T1: NOCOPY ALTER TABLE begins, and eventually it holds MDL_SHARED_NO_WRITE lock; T2: FLUSH TABLES begins. it sets share->tdc->flushed = true T3: purge on a record with virtual column begins. it is going to open a table. MDL_SHARED_READ lock is acquired therefore. Since share->tdc->flushed is set, it waits for a TDC purge end. T1: is going to elevate MDL LOCK to exclusive and therefore has to set other waiters to back off. T3: receives VICTIM status, reports a DEADLOCK, sets OT_BACKOFF_AND_RETRY to Open_table_context::m_action My fix is to allow opening table in purge while flushing. It is already done the same way in other maintainance facilities like REPAIR TABLE. Another way would be making an actual backoff, but Open_table_context does not allow to distinguish it from other failure types, which still seem to be unexpected. Making this would require hacking into Open_table_context interface for no benefit, in comparison to passing MYSQL_OPEN_IGNORE_FLUSH during table open.
* MDEV-24925: Server crashes in Item_subselect::init_expr_cache_trackerSergei Petrunia2021-04-251-1/+10
| | | | | | | | | | | | | (trivial backport to 10.2) The optimizer removes redundant GROUP BY operations. If GROUP BY element is a subselect, it is "eliminated". However one must not eliminate the item if it is used both in the select list and in the GROUP BY, like so: select (select ... ) as SUBQ from ... group by SUBQ Do not eliminate such items.
* This patch complements the patch for MDEV-24823.Igor Babaev2021-04-231-1/+1
|
* MDEV-25091 CREATE TABLE: field references qualified by a wrong table name ↵Aleksey Midenkov2021-04-233-5/+106
| | | | | | | | | | | succeed Before FRM is written walk vcol expressions through check_table_name_processor() and check if field items match (db, table_name) qualifier. We cannot do this in check_vcol_func_processor() as there is already no table name qualifiers in expressions of written and loaded FRM.
* MDEV-24823 Crash with invalid multi-table update of view in 2nd execution of SPIgor Babaev2021-04-227-26/+65
| | | | | | | | | | | | | | | | | | | | | | Before this patch mergeable derived tables / view used in a multi-table update / delete were merged before the preparation stage. When the merge of a derived table / view is performed the on expression attached to it is fixed and ANDed with the where condition of the select S containing this derived table / view. It happens after the specification of the derived table / view has been merged into S. If the ON expression refers to a non existing field an error is reported and some other mergeable derived tables / views remain unmerged. It's not a problem if the multi-table update / delete statement is standalone. Yet if it is used in a stored procedure the select with incompletely merged derived tables / views may cause a problem for the second call of the procedure. This does not happen for select queries using derived tables / views, because in this case their specifications are merged after the preparation stage at which all ON expressions are fixed. This patch makes sure that merging of the derived tables / views used in a multi-table update / delete statement is performed after the preparation stage. Approved by Oleksandr Byelkin <sanja@mariadb.com>
* Update timezone data on WindowsVladislav Vaintroub2021-04-222-0/+2
| | | | | | | | There is new Yukon Standard time Windows timezone. Also fix the powershell script that generates the Windows locale mapping, tell powershell to use TLSv1.2 to access the github (on some reason it is TLS1.1 that powershell is using by default, and it does no work)
* MDEV-24526 binlog rotate via FLUSH LOGS may obsolate binlog file for ↵Andrei Elkin2021-04-211-0/+19
| | | | | | | | | | | | | | | | | | | | | recovery too eary There was race between a committing transaction and the following in binlog order FLUSH LOGS that could create a 2nd Binlog checkpoint (BCP) event in the new file *before* the first logged-in-old-binlog transaction gets committed in Innodb. That would cause the transaction loss at recovery, should the server stop right after the BCP. The race is tackled by enforcing the necessary set of mutexes to be acquired by FLUSH-LOGS handler in the correct order (of the group commit leader pattern). Note, there remain two cases where a similar race is still possible: - the above race as it is when the server is run with ("unlikely") non-default `--binlog-optimize-thread-scheduling=0` (MDEV-24530), and - at unlikely event of bin-logging of Incident event (MDEV-24531) that also triggers binlog rotation, in both cases though with lesser chances after the current fixes.
* Fixup: Event_queue_element_for_exec initializer list not supported on gcc-4.1Vicențiu Ciorbaru2021-04-211-1/+5
|
* fixed some korean error messagesbb-10.2-danielblack-pr1811-korean-translationLee Keun Won2021-04-211-14/+17
| | | | Closes #1811
* MDEV-24807:A possibility for double free in dtor of ↵Vicențiu Ciorbaru2021-04-203-1/+3
| | | | | | | Event_queue_element_for_exec in the case of OOM Eliminate a memory leak when init can fail by forgetting to delete the Event_queue_element_for_exec object.
* MDEV-25362 Incorrect name resolution for subqueries in ON expressionsprot-10.2Igor Babaev2021-04-172-1/+34
| | | | | | | | | | | | | | | | | | This patch sets the proper name resolution context for outer references used in a subquery from an ON clause. Usually this context is more narrow than the name resolution context of the parent select that were used before this fix. This fix revealed another problem that concerned ON expressions used in from clauses of specifications of derived tables / views / CTEs. The name resolution outer context for such ON expression must be set to NULL to prevent name resolution beyond the derived table where it is used. The solution to resolve this problem applied in sql_derived.cc was provided by Sergei Petrunia <sergey@mariadb.com>. The change in sql_parse.cc is not good for 10.4+. A corresponding diff for 10.4+ will be provided in JIRA entry for this bug. Approved by Oleksandr Byelkin <sanja@mariadb.com>
* MDEV-15064: IO_CACHE mysys read_pos, not libmaria rc_posbb-10.2-danielblack-MDEV-15064-IO_CACHE-read_posRainer Orth2021-04-171-1/+1
| | | | | | | | | It seems some overly tolerant compilers (gcc) allow the structure of IO_CACHE that is defined differently in libmaria to have members equalivance to the iocache in mysys. More strict Solaris compilers recognise that rc_pos really isn't a structure member and won't compile.
* MDEV-25407: EXISTS subquery with correlation in ON expression crashesbb-10.2-mdev25407Sergei Petrunia2021-04-161-1/+29
| | | | Make Item_subselect::walk() walk the ON expressions, too.
* MDEV-25403 ALTER TABLE wrongly checks for field's default value if AFTER is usedSergei Golubchik2021-04-151-1/+1
| | | | | | | | When a column is added to an non-empty table, existing rows will have a column's default value for existing rows. Or a "zero value" if the column has no default. But this check should be skipped when an existing column is altered.
* signal handler, display coredump file pattern similarly to MDEV-25294 but ↵David Carlier2021-04-151-3/+3
| | | | for FreeBSD, thankfully the sysctl OID is the same.
* MDEV-25182 Complex query in Store procedure corrupts resultsbb-10.2-MDEV-25182Oleksandr Byelkin2021-04-124-7/+17
| | | | | | | | | | | | | | | | | | | | | At the second execution of the PS 1. mark_as_dependent() is called with the same parameters as at the first execution (select#4 and select#3) 2. as outer_select (select#3) has been already merged at the first execution of PS it cannot be reached using the outer_select() function anymore (and so can not stop iteration). 3. as a result all selects towards the top level select including the select for 'ca' are marked as uncacheable. 4. Marked uncacheable it executed incorrectly triggering filling its temporary table several times and using freed memory at the end. To avoid the problem we use name resolution context to go "up". NOTE: problem also exists in 10.2 but has no visible effect on execution. That is why the problem is fixed in 10.2. The patch also add debug logging of important procedures and better specify parameters types of st_select_lex::mark_as_dependent.
* MDEV-25108: Running of the EXPLAIN EXTENDED statement produces extra warning ↵bb-10.2-MDEV-25108-2Dmitry Shulga2021-04-124-15/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in case it is executed in PS (prepared statement) mode The EXPLAIN EXTENDED statement run as a prepared statement can produce extra warning comparing with a case when EXPLAIN EXTENDED statement is run as a regular statement. For example, the following test case CREATE TABLE t1 (c int); CREATE TABLE t2 (d int); EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1; produces the extra warning "Field or reference 'c' of SELECT #2 was resolved in SELECT #1" in case the above mentioned "EXPLAIN EXTENDED" statement is executed in PS mode, that is by submitting the following statements: PREPARE stmt FROM "EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1"; EXECUTE stmt; The reason of the extra warning emittion is in a way items are handled (being fixed) during execution of the JOIN::prepare() method. The method Item_field::fix_fields() calls the find_field_in_tables() function in case a field hasn't been associated yet with the item. Implementation of the find_field_in_tables() function first checks whether a table containing the required field was already opened and cached. It is done by checking the data member item->cached_table. This data member is set on handling the PRERARE FROM statement and checked on executing the EXECUTE statement. If the data member item->cached_table is set the find_field_in_tables() function invoked and the mark_select_range_as_dependent() function called if the field is an outer referencee. The mark_select_range_as_dependent() function calls the mark_as_dependent() function that finally invokes the push_warning_printf() function that produces extra warning. To fix the issue, calling of push_warning_printf() is elimited in case it was run indirectly in result of hanlding already opened table from the Item_field::fix_fields() method.
* MDEV-13467 fixup: Improve error handlingMarko Mäkelä2021-04-081-7/+15
|
* MDEV-25294 signal handler display coredump on macDavid CARLIER2021-03-301-1/+13
|