1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fixed two bugs with CREATE OR REPLACE and LOCK TABLES:

MDEV-6560 Assertion `! is_set() ' failed in Diagnostics_area::set_ok_status on killing CREATE OR REPLACE
MDEV-6525 Assertion `table->pos_in_locked _tables == __null || table->pos_in_locked_tables->table = table' failed in mark_used_tables_as_free_for_reuse, locking problems and binlogging problems on CREATE OR REPLACE under lock.
 

mysql-test/r/create_or_replace.result:
  Added test for MDEV-6560
mysql-test/t/create_or_replace.test:
  Added test for MDEV-6560
mysql-test/valgrind.supp:
  Added suppression for OpenSuse 12.3
sql/sql_base.cc:
  More DBUG
sql/sql_class.cc:
  Changed that thd_sqlcom_can_generate_row_events() does not report that CREATE OR REPLACE is generating row events.
  This is safe as this function is only used by InnoDB/XtraDB to check if a query is generating row events as part of another transaction. As CREATE is always run as it's own transaction, this isn't a problem.
  This fixed MDEV-6525.
sql/sql_table.cc:
  Remember if reopen_tables() generates an error (which can only happen in case of KILL).
  This fixed MDEV-6560
This commit is contained in:
Michael Widenius
2014-09-08 20:56:56 +03:00
parent 0835f57489
commit 9c79227c96
8 changed files with 151 additions and 4 deletions

View File

@ -427,4 +427,16 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_SHARED_READ MDL_EXPLICIT Table metadata lock test t2
drop table t1;
unlock tables;
#
# MDEV-6560
# Assertion `! is_set() ' failed in Diagnostics_area::set_ok_status
#
CREATE TABLE t1 (col_int_nokey INT) ENGINE=InnoDB;
CREATE OR REPLACE TEMPORARY TABLE tmp LIKE t1;
LOCK TABLE t1 WRITE;
CREATE OR REPLACE TABLE t1 LIKE tmp;;
KILL QUERY 3;
CREATE OR REPLACE TABLE t1 (a int);;
KILL QUERY 3;
drop table t1;
DROP TABLE t2;

View File

@ -0,0 +1,31 @@
include/master-slave.inc
[connection master]
#
# MDEV-6525 ; Problems with CREATE OR REPLACE under lock
#
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
CREATE FUNCTION f1() RETURNS INT RETURN ( SELECT MAX(a) FROM t1 );
connect con1,localhost,root,,test;
CREATE TEMPORARY TABLE tmp (b INT) ENGINE=InnoDB;
LOCK TABLE t1 WRITE;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
CREATE OR REPLACE TABLE t1 LIKE tmp;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`b` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
connection default;
set session lock_wait_timeout=1;
SELECT f1();
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
set session lock_wait_timeout=@@global.lock_wait_timeout;
SELECT f1();
connection con1;
unlock tables;
connection default;
ERROR 42S22: Unknown column 'a' in 'field list'
disconnect con1;
drop function f1;
drop table t1;
include/rpl_end.inc

View File

@ -0,0 +1,44 @@
--source include/have_innodb.inc
--source include/have_binlog_format_row_or_statement.inc
--source include/have_metadata_lock_info.inc
--source include/master-slave.inc
--enable_connect_log
--echo #
--echo # MDEV-6525 ; Problems with CREATE OR REPLACE under lock
--echo #
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
CREATE FUNCTION f1() RETURNS INT RETURN ( SELECT MAX(a) FROM t1 );
--connect (con1,localhost,root,,test)
CREATE TEMPORARY TABLE tmp (b INT) ENGINE=InnoDB;
LOCK TABLE t1 WRITE;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
CREATE OR REPLACE TABLE t1 LIKE tmp;
SHOW CREATE TABLE t1;
--connection default
set session lock_wait_timeout=1;
--error 1205
SELECT f1();
set session lock_wait_timeout=@@global.lock_wait_timeout;
--send SELECT f1()
--connection con1
# This is here just in case, any timeout should be ok
--sleep 1
unlock tables;
--connection default
--error 1054
--reap
--disconnect con1
# Cleanup
drop function f1;
drop table t1;
--disable_connect_log
--source include/rpl_end.inc

View File

@ -332,6 +332,38 @@ select * from information_schema.metadata_lock_info;
drop table t1;
unlock tables;
--echo #
--echo # MDEV-6560
--echo # Assertion `! is_set() ' failed in Diagnostics_area::set_ok_status
--echo #
CREATE TABLE t1 (col_int_nokey INT) ENGINE=InnoDB;
--let $con_id = `SELECT CONNECTION_ID()`
CREATE OR REPLACE TEMPORARY TABLE tmp LIKE t1;
LOCK TABLE t1 WRITE;
--connect (con1,localhost,root,,test)
--connection default
--send CREATE OR REPLACE TABLE t1 LIKE tmp;
--connection con1
eval KILL QUERY $con_id;
--connection default
--error 0,ER_QUERY_INTERRUPTED
--reap
--send CREATE OR REPLACE TABLE t1 (a int);
--connection con1
eval KILL QUERY $con_id;
--connection default
--error 0,ER_QUERY_INTERRUPTED
--reap
--disconnect con1
drop table t1;
#
# Cleanup
#

View File

@ -412,6 +412,17 @@
fun:__libc_start_main
}
#
# dl_init reports leaked memory in memalign on OpenSuse 12.3
{
memory "loss" from _dl_init
Memcheck:Leak
fun:memalign
...
fun:call_init
fun:_dl_init
}
#
# dlclose can allocate memory for error message, the memory will be