2006-08-16 14:58:49 +02:00
|
|
|
# t/innodb_mysql.test
|
2006-05-16 11:16:23 +02:00
|
|
|
#
|
2006-08-16 14:58:49 +02:00
|
|
|
# Last update:
|
|
|
|
# 2006-07-26 ML test refactored (MySQL 5.1)
|
|
|
|
# main testing code t/innodb_mysql.test -> include/mix1.inc
|
2006-05-16 11:16:23 +02:00
|
|
|
#
|
2006-05-22 16:10:53 +03:00
|
|
|
|
2006-08-16 14:58:49 +02:00
|
|
|
-- source include/have_innodb.inc
|
|
|
|
let $engine_type= InnoDB;
|
|
|
|
let $other_engine_type= MEMORY;
|
2006-09-18 16:55:56 +02:00
|
|
|
# InnoDB does support FOREIGN KEYFOREIGN KEYs
|
|
|
|
let $test_foreign_keys= 1;
|
2007-10-08 20:57:37 +02:00
|
|
|
set global innodb_support_xa=default;
|
|
|
|
set session innodb_support_xa=default;
|
2006-08-16 14:58:49 +02:00
|
|
|
--source include/mix1.inc
|
2008-05-07 09:58:21 +04:00
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t1, t2, t3;
|
|
|
|
--enable_warnings
|
|
|
|
#
|
|
|
|
# BUG#35850: Performance regression in 5.1.23/5.1.24
|
|
|
|
#
|
|
|
|
create table t1(a int);
|
|
|
|
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
|
|
create table t2 (a int, b int, pk int, key(a,b), primary key(pk)) engine=innodb;
|
|
|
|
insert into t2 select @a:=A.a+10*(B.a + 10*C.a),@a, @a from t1 A, t1 B, t1 C;
|
|
|
|
--echo this must use key 'a', not PRIMARY:
|
|
|
|
--replace_column 9 #
|
|
|
|
explain select a from t2 where a=b;
|
|
|
|
drop table t1, t2;
|
|
|
|
|
2008-11-03 12:14:48 +01:00
|
|
|
#
|
|
|
|
# Bug #40360: Binlog related errors with binlog off
|
|
|
|
#
|
|
|
|
# This bug is triggered when the binlog format is STATEMENT and the
|
|
|
|
# binary log is turned off. In this case, no error should be shown for
|
|
|
|
# the statement since there are no replication issues.
|
|
|
|
|
|
|
|
SET SESSION BINLOG_FORMAT=STATEMENT;
|
|
|
|
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
2008-11-03 18:46:47 +01:00
|
|
|
query_vertical select @@session.sql_log_bin, @@session.binlog_format, @@session.tx_isolation;
|
2008-11-03 12:14:48 +01:00
|
|
|
CREATE TABLE t1 ( a INT ) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1 VALUES(1);
|
2008-11-03 18:46:47 +01:00
|
|
|
DROP TABLE t1;
|
2008-11-03 12:14:48 +01:00
|
|
|
|
2007-04-19 22:38:12 +02:00
|
|
|
#
|
2008-11-27 19:03:13 +04:00
|
|
|
# Bug#37284 Crash in Field_string::type()
|
2007-04-19 22:38:12 +02:00
|
|
|
#
|
A fix and a test case for Bug#24918 drop table and lock / inconsistent
between perm and temp tables. Review fixes.
The original bug report complains that if we locked a temporary table
with LOCK TABLES statement, we would not leave LOCK TABLES mode
when this temporary table is dropped.
Additionally, the bug was escalated when it was discovered than
when a temporary transactional table that was previously
locked with LOCK TABLES statement was dropped, futher actions with
this table, such as UNLOCK TABLES, would lead to a crash.
The problem originates from incomplete support of transactional temporary
tables. When we added calls to handler::store_lock()/handler::external_lock()
to operations that work with such tables, we only covered the normal
server code flow and did not cover LOCK TABLES mode.
In LOCK TABLES mode, ::external_lock(LOCK) would sometimes be called without
matching ::external_lock(UNLOCK), e.g. when a transactional temporary table
was dropped. Additionally, this table would be left in the list of LOCKed
TABLES.
The patch aims to address this inadequacy. Now, whenever an instance
of 'handler' is destroyed, we assert that it was priorly
external_lock(UNLOCK)-ed. All the places that violate this assert
were fixed.
This patch introduces no changes in behavior -- the discrepancy in
behavior will be fixed when we start calling ::store_lock()/::external_lock()
for all tables, regardless whether they are transactional or not,
temporary or not.
2007-07-27 16:37:29 +04:00
|
|
|
--disable_warnings
|
2008-11-27 19:03:13 +04:00
|
|
|
DROP TABLE IF EXISTS t1;
|
A fix and a test case for Bug#24918 drop table and lock / inconsistent
between perm and temp tables. Review fixes.
The original bug report complains that if we locked a temporary table
with LOCK TABLES statement, we would not leave LOCK TABLES mode
when this temporary table is dropped.
Additionally, the bug was escalated when it was discovered than
when a temporary transactional table that was previously
locked with LOCK TABLES statement was dropped, futher actions with
this table, such as UNLOCK TABLES, would lead to a crash.
The problem originates from incomplete support of transactional temporary
tables. When we added calls to handler::store_lock()/handler::external_lock()
to operations that work with such tables, we only covered the normal
server code flow and did not cover LOCK TABLES mode.
In LOCK TABLES mode, ::external_lock(LOCK) would sometimes be called without
matching ::external_lock(UNLOCK), e.g. when a transactional temporary table
was dropped. Additionally, this table would be left in the list of LOCKed
TABLES.
The patch aims to address this inadequacy. Now, whenever an instance
of 'handler' is destroyed, we assert that it was priorly
external_lock(UNLOCK)-ed. All the places that violate this assert
were fixed.
This patch introduces no changes in behavior -- the discrepancy in
behavior will be fixed when we start calling ::store_lock()/::external_lock()
for all tables, regardless whether they are transactional or not,
temporary or not.
2007-07-27 16:37:29 +04:00
|
|
|
--enable_warnings
|
2008-11-27 19:03:13 +04:00
|
|
|
CREATE TABLE t1 (a char(50)) ENGINE=InnoDB;
|
|
|
|
CREATE INDEX i1 on t1 (a(3));
|
|
|
|
SELECT * FROM t1 WHERE a = 'abcde';
|
2007-09-14 17:43:14 +03:00
|
|
|
DROP TABLE t1;
|
2008-12-08 12:23:33 +02:00
|
|
|
|
2008-11-29 15:36:17 +02:00
|
|
|
#
|
|
|
|
# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of
|
|
|
|
# requested column
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE foo (a int, b int, c char(10),
|
|
|
|
PRIMARY KEY (c(3)),
|
|
|
|
KEY b (b)
|
|
|
|
) engine=innodb;
|
|
|
|
|
|
|
|
CREATE TABLE foo2 (a int, b int, c char(10),
|
|
|
|
PRIMARY KEY (c),
|
|
|
|
KEY b (b)
|
|
|
|
) engine=innodb;
|
|
|
|
|
|
|
|
CREATE TABLE bar (a int, b int, c char(10),
|
|
|
|
PRIMARY KEY (c(3)),
|
|
|
|
KEY b (b)
|
|
|
|
) engine=myisam;
|
|
|
|
|
|
|
|
INSERT INTO foo VALUES
|
|
|
|
(1,2,'abcdefghij'), (2,3,''), (3,4,'klmnopqrst'),
|
|
|
|
(4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe');
|
|
|
|
|
|
|
|
INSERT INTO bar SELECT * FROM foo;
|
|
|
|
INSERT INTO foo2 SELECT * FROM foo;
|
|
|
|
|
|
|
|
--query_vertical EXPLAIN SELECT c FROM bar WHERE b>2;
|
|
|
|
--query_vertical EXPLAIN SELECT c FROM foo WHERE b>2;
|
|
|
|
--query_vertical EXPLAIN SELECT c FROM foo2 WHERE b>2;
|
|
|
|
|
|
|
|
--query_vertical EXPLAIN SELECT c FROM bar WHERE c>2;
|
|
|
|
--query_vertical EXPLAIN SELECT c FROM foo WHERE c>2;
|
|
|
|
--query_vertical EXPLAIN SELECT c FROM foo2 WHERE c>2;
|
|
|
|
|
|
|
|
DROP TABLE foo, bar, foo2;
|
2008-12-08 12:23:33 +02:00
|
|
|
|
2009-01-07 10:11:37 -02:00
|
|
|
#
|
|
|
|
# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table
|
|
|
|
#
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
DROP TABLE IF EXISTS t1,t3,t2;
|
|
|
|
DROP FUNCTION IF EXISTS f1;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
DELIMITER |;
|
|
|
|
CREATE FUNCTION f1() RETURNS VARCHAR(250)
|
|
|
|
BEGIN
|
|
|
|
return 'hhhhhhh' ;
|
|
|
|
END|
|
|
|
|
DELIMITER ;|
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a VARCHAR(20), b VARCHAR(20), c VARCHAR(20)) ENGINE=INNODB;
|
|
|
|
|
|
|
|
BEGIN WORK;
|
|
|
|
|
|
|
|
CREATE TEMPORARY TABLE t2 (a VARCHAR(20), b VARCHAR(20), c varchar(20)) ENGINE=INNODB;
|
|
|
|
CREATE TEMPORARY TABLE t3 LIKE t2;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES ('a','b',NULL),('c','d',NULL),('e','f',NULL);
|
|
|
|
|
|
|
|
SET @stmt := CONCAT('INSERT INTO t2 SELECT tbl.a, tbl.b, f1()',' FROM t1 tbl');
|
|
|
|
PREPARE stmt1 FROM @stmt;
|
|
|
|
|
|
|
|
SET @stmt := CONCAT('INSERT INTO t3', ' SELECT * FROM t2');
|
|
|
|
PREPARE stmt3 FROM @stmt;
|
|
|
|
|
|
|
|
EXECUTE stmt1;
|
|
|
|
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
DEALLOCATE PREPARE stmt1;
|
|
|
|
DEALLOCATE PREPARE stmt3;
|
|
|
|
|
|
|
|
DROP TABLE t1,t3,t2;
|
|
|
|
DROP FUNCTION f1;
|
|
|
|
|
2009-01-09 08:20:32 -02:00
|
|
|
#
|
|
|
|
# Bug#37016: TRUNCATE TABLE removes some rows but not all
|
|
|
|
#
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
DROP TABLE IF EXISTS t1,t2;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
|
|
|
|
CREATE TABLE t2 (id INT PRIMARY KEY,
|
|
|
|
t1_id INT, INDEX par_ind (t1_id),
|
|
|
|
FOREIGN KEY (t1_id) REFERENCES t1(id)) ENGINE=INNODB;
|
|
|
|
INSERT INTO t1 VALUES (1),(2);
|
|
|
|
INSERT INTO t2 VALUES (3,2);
|
|
|
|
|
|
|
|
SET AUTOCOMMIT = 0;
|
|
|
|
|
|
|
|
START TRANSACTION;
|
|
|
|
--error ER_ROW_IS_REFERENCED_2
|
|
|
|
TRUNCATE TABLE t1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
|
|
|
START TRANSACTION;
|
|
|
|
--error ER_ROW_IS_REFERENCED_2
|
|
|
|
TRUNCATE TABLE t1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
ROLLBACK;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
|
|
|
SET AUTOCOMMIT = 1;
|
|
|
|
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
--error ER_ROW_IS_REFERENCED_2
|
|
|
|
TRUNCATE TABLE t1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
DELETE FROM t2 WHERE id = 3;
|
|
|
|
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
TRUNCATE TABLE t1;
|
|
|
|
ROLLBACK;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
TRUNCATE TABLE t2;
|
|
|
|
|
|
|
|
DROP TABLE t2;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2008-12-08 12:23:33 +02:00
|
|
|
--echo End of 5.1 tests
|