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 15:10:53 +02: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 07:58:21 +02: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 16:03:13 +01: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.
mysql-test/r/innodb_mysql.result:
Update test results (Bug#24918)
mysql-test/t/innodb_mysql.test:
Add a test case for Bug#24918
sql/handler.h:
Make handler::external_lock() a protected method. Backport from 5.1 its
public wrapper handler::ha_external_lock().
Assert that the handler is not closed if it is still locked.
sql/lock.cc:
In mysql_lock_tables only call lock_external() for the list of tables that
we called store_lock() for.
E.g. get_lock_data() does not add non-transactional temporary tables to the
lock list, so lock_external() should not be called for them.
Use handler::ha_external_lock() instead of handler::external_lock().
Add comments for mysql_lock_remove(), parameterize one strange
side effect that it has. At least in one place where mysql_lock_remove
is used, this side effect is not desired (DROP TABLE). The parameter
will be dropped in 5.1, along with the side effect.
sql/mysql_priv.h:
Update declaration of mysql_lock_remove().
sql/opt_range.cc:
Deploy handler::ha_external_lock() instead of handler::external_lock()
sql/sql_base.cc:
When closing a temporary table, remove the table from the list of LOCKed
TABLES of this thread, in case it's there.
It's there if it is a transactional temporary table.
Use a new declaration of mysql_lock_remove().
sql/sql_class.h:
Extend the comment for THD::temporary_tables.
sql/sql_table.cc:
Deploy handler::ha_external_lock() instead of handler::external_lock()
2007-07-27 14:37:29 +02:00
|
|
|
--disable_warnings
|
2008-11-27 16:03:13 +01: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.
mysql-test/r/innodb_mysql.result:
Update test results (Bug#24918)
mysql-test/t/innodb_mysql.test:
Add a test case for Bug#24918
sql/handler.h:
Make handler::external_lock() a protected method. Backport from 5.1 its
public wrapper handler::ha_external_lock().
Assert that the handler is not closed if it is still locked.
sql/lock.cc:
In mysql_lock_tables only call lock_external() for the list of tables that
we called store_lock() for.
E.g. get_lock_data() does not add non-transactional temporary tables to the
lock list, so lock_external() should not be called for them.
Use handler::ha_external_lock() instead of handler::external_lock().
Add comments for mysql_lock_remove(), parameterize one strange
side effect that it has. At least in one place where mysql_lock_remove
is used, this side effect is not desired (DROP TABLE). The parameter
will be dropped in 5.1, along with the side effect.
sql/mysql_priv.h:
Update declaration of mysql_lock_remove().
sql/opt_range.cc:
Deploy handler::ha_external_lock() instead of handler::external_lock()
sql/sql_base.cc:
When closing a temporary table, remove the table from the list of LOCKed
TABLES of this thread, in case it's there.
It's there if it is a transactional temporary table.
Use a new declaration of mysql_lock_remove().
sql/sql_class.h:
Extend the comment for THD::temporary_tables.
sql/sql_table.cc:
Deploy handler::ha_external_lock() instead of handler::external_lock()
2007-07-27 14:37:29 +02:00
|
|
|
--enable_warnings
|
2008-11-27 16:03:13 +01: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 16:43:14 +02:00
|
|
|
DROP TABLE t1;
|
2008-12-08 11:23:33 +01:00
|
|
|
|
2008-11-29 14:36:17 +01: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 11:23:33 +01:00
|
|
|
|
2007-06-01 19:53:50 +02:00
|
|
|
|
2009-01-07 13:11:37 +01: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 11:20:32 +01: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;
|
|
|
|
|
2009-03-27 17:08:14 +01:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0
|
|
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
|
|
PRIMARY KEY (id)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
|
|
aid INT UNSIGNED NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
FOREIGN KEY (aid) REFERENCES t1 (id)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
CREATE TABLE t3 (
|
|
|
|
bid INT UNSIGNED NOT NULL,
|
|
|
|
FOREIGN KEY (bid) REFERENCES t2 (id)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
CREATE TABLE t4 (
|
|
|
|
a INT
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
CREATE TABLE t5 (
|
|
|
|
a INT
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
INSERT INTO t1 (id) VALUES (1);
|
|
|
|
INSERT INTO t2 (id, aid) VALUES (1, 1),(2,1),(3,1),(4,1);
|
|
|
|
INSERT INTO t3 (bid) VALUES (1);
|
|
|
|
|
|
|
|
INSERT INTO t4 VALUES (1),(2),(3),(4),(5);
|
|
|
|
INSERT INTO t5 VALUES (1);
|
|
|
|
|
|
|
|
DELETE t5 FROM t4 LEFT JOIN t5 ON t4.a= t5.a;
|
|
|
|
|
|
|
|
--error ER_ROW_IS_REFERENCED_2
|
|
|
|
DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1;
|
|
|
|
--error ER_ROW_IS_REFERENCED_2
|
|
|
|
DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1;
|
|
|
|
|
|
|
|
DELETE IGNORE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1;
|
|
|
|
|
|
|
|
DROP TABLE t3;
|
|
|
|
DROP TABLE t2;
|
|
|
|
DROP TABLE t1;
|
|
|
|
DROP TABLES t4,t5;
|
|
|
|
|
|
|
|
--echo # Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0
|
|
|
|
--echo # Testing for any side effects of IGNORE on AFTER DELETE triggers used with
|
|
|
|
--echo # transactional tables.
|
|
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE t2 (a VARCHAR(100)) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE t3 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE t4 (i INT NOT NULL PRIMARY KEY, t1i INT,
|
|
|
|
FOREIGN KEY (t1i) REFERENCES t1(i))
|
|
|
|
ENGINE=InnoDB;
|
|
|
|
delimiter ||;
|
|
|
|
CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
SET @b:='EXECUTED TRIGGER';
|
|
|
|
INSERT INTO t2 VALUES (@b);
|
|
|
|
SET @a:= error_happens_here;
|
|
|
|
END||
|
|
|
|
delimiter ;||
|
|
|
|
|
|
|
|
SET @b:="";
|
|
|
|
SET @a:="";
|
|
|
|
INSERT INTO t1 VALUES (1),(2),(3),(4);
|
|
|
|
INSERT INTO t3 SELECT * FROM t1;
|
|
|
|
--echo ** An error in a trigger causes rollback of the statement.
|
|
|
|
--error ER_BAD_FIELD_ERROR
|
|
|
|
DELETE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
|
|
|
|
SELECT @a,@b;
|
|
|
|
SELECT * FROM t2;
|
|
|
|
SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
|
|
|
|
|
|
|
|
--echo ** Same happens with the IGNORE option
|
|
|
|
--error ER_BAD_FIELD_ERROR
|
|
|
|
DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
|
|
|
|
SELECT * FROM t2;
|
|
|
|
SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
|
|
|
|
|
|
|
|
--echo **
|
|
|
|
--echo ** The following is an attempt to demonstrate
|
|
|
|
--echo ** error handling inside a row iteration.
|
|
|
|
--echo **
|
|
|
|
DROP TRIGGER trg;
|
|
|
|
TRUNCATE TABLE t1;
|
|
|
|
TRUNCATE TABLE t2;
|
|
|
|
TRUNCATE TABLE t3;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES (1),(2),(3),(4);
|
|
|
|
INSERT INTO t3 VALUES (1),(2),(3),(4);
|
|
|
|
INSERT INTO t4 VALUES (3,3),(4,4);
|
|
|
|
|
|
|
|
delimiter ||;
|
|
|
|
CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
SET @b:= CONCAT('EXECUTED TRIGGER FOR ROW ',CAST(OLD.i AS CHAR));
|
|
|
|
INSERT INTO t2 VALUES (@b);
|
|
|
|
END||
|
|
|
|
delimiter ;||
|
|
|
|
|
|
|
|
--echo ** DELETE is prevented by foreign key constrains but errors are silenced.
|
|
|
|
--echo ** The AFTER trigger isn't fired.
|
|
|
|
DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
|
|
|
|
--echo ** Tables are modified by best effort:
|
|
|
|
SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
|
|
|
|
--echo ** The AFTER trigger was only executed on successful rows:
|
|
|
|
SELECT * FROM t2;
|
|
|
|
|
|
|
|
DROP TRIGGER trg;
|
|
|
|
|
|
|
|
--echo **
|
|
|
|
--echo ** Induce an error midway through an AFTER-trigger
|
|
|
|
--echo **
|
|
|
|
TRUNCATE TABLE t4;
|
|
|
|
TRUNCATE TABLE t1;
|
|
|
|
TRUNCATE TABLE t3;
|
|
|
|
INSERT INTO t1 VALUES (1),(2),(3),(4);
|
|
|
|
INSERT INTO t3 VALUES (1),(2),(3),(4);
|
|
|
|
delimiter ||;
|
|
|
|
CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
SET @a:= @a+1;
|
|
|
|
IF @a > 2 THEN
|
|
|
|
INSERT INTO t4 VALUES (5,5);
|
|
|
|
END IF;
|
|
|
|
END||
|
|
|
|
delimiter ;||
|
|
|
|
|
|
|
|
SET @a:=0;
|
|
|
|
--echo ** Errors in the trigger causes the statement to abort.
|
|
|
|
--error ER_NO_REFERENCED_ROW_2
|
|
|
|
DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
|
|
|
|
SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
|
|
|
|
SELECT * FROM t4;
|
|
|
|
|
|
|
|
DROP TRIGGER trg;
|
|
|
|
DROP TABLE t4;
|
|
|
|
DROP TABLE t1;
|
|
|
|
DROP TABLE t2;
|
|
|
|
DROP TABLE t3;
|
|
|
|
|
2009-05-05 11:38:19 +02:00
|
|
|
#
|
|
|
|
# Bug#43580: Issue with Innodb on multi-table update
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB;
|
|
|
|
CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB;
|
|
|
|
|
|
|
|
CREATE TABLE t3 (a INT, b INT KEY, KEY (a)) ENGINE = INNODB;
|
|
|
|
CREATE TABLE t4 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6);
|
|
|
|
INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
|
|
|
|
|
|
|
|
INSERT INTO t3 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106);
|
|
|
|
INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
|
|
|
|
|
|
|
|
UPDATE t1, t2 SET t1.a = t1.a + 100, t2.b = t1.a + 10
|
|
|
|
WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b;
|
|
|
|
--sorted_result
|
|
|
|
SELECT * FROM t2;
|
|
|
|
|
|
|
|
UPDATE t3, t4 SET t3.a = t3.a + 100, t4.b = t3.a + 10
|
|
|
|
WHERE t3.a BETWEEN 2 AND 4 AND t4.a = t3.b - 100;
|
|
|
|
--sorted_result
|
|
|
|
SELECT * FROM t4;
|
|
|
|
|
|
|
|
DROP TABLE t1, t2, t3, t4;
|
|
|
|
|
2009-06-07 22:40:53 +02:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#44886: SIGSEGV in test_if_skip_sort_order() -
|
|
|
|
--echo # uninitialized variable used as subscript
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a INT, b INT, c INT, d INT, PRIMARY KEY (b), KEY (a,c))
|
|
|
|
ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1 VALUES (1,1,1,0);
|
|
|
|
|
|
|
|
CREATE TABLE t2 (a INT, b INT, e INT, KEY (e)) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t2 VALUES (1,1,2);
|
|
|
|
|
|
|
|
CREATE TABLE t3 (a INT, b INT) ENGINE=MyISAM;
|
|
|
|
INSERT INTO t3 VALUES (1, 1);
|
|
|
|
|
|
|
|
SELECT * FROM t1, t2, t3
|
|
|
|
WHERE t1.a = t3.a AND (t1.b = t3.b OR t1.d) AND t2.b = t1.b AND t2.e = 2
|
|
|
|
GROUP BY t1.b;
|
|
|
|
|
|
|
|
DROP TABLE t1, t2, t3;
|
|
|
|
|
2009-07-07 14:52:34 +02:00
|
|
|
--echo #
|
|
|
|
--echo # Bug #45828: Optimizer won't use partial primary key if another
|
|
|
|
--echo # index can prevent filesort
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
# Create the table
|
|
|
|
CREATE TABLE `t1` (
|
|
|
|
c1 int NOT NULL,
|
|
|
|
c2 int NOT NULL,
|
|
|
|
c3 int NOT NULL,
|
|
|
|
PRIMARY KEY (c1,c2),
|
|
|
|
KEY (c3)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
# populate with data
|
|
|
|
INSERT INTO t1 VALUES (5,2,1246276747);
|
|
|
|
INSERT INTO t1 VALUES (2,1,1246281721);
|
|
|
|
INSERT INTO t1 VALUES (7,3,1246281756);
|
|
|
|
INSERT INTO t1 VALUES (4,2,1246282139);
|
|
|
|
INSERT INTO t1 VALUES (3,1,1246282230);
|
|
|
|
INSERT INTO t1 VALUES (1,0,1246282712);
|
|
|
|
INSERT INTO t1 VALUES (8,3,1246282765);
|
|
|
|
INSERT INTO t1 SELECT c1+10,c2+10,c3+10 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT c1+100,c2+100,c3+100 from t1;
|
|
|
|
INSERT INTO t1 SELECT c1+1000,c2+1000,c3+1000 from t1;
|
|
|
|
INSERT INTO t1 SELECT c1+10000,c2+10000,c3+10000 from t1;
|
|
|
|
INSERT INTO t1 SELECT c1+100000,c2+100000,c3+100000 from t1;
|
|
|
|
INSERT INTO t1 SELECT c1+1000000,c2+1000000,c3+1000000 from t1;
|
|
|
|
|
|
|
|
# query and no rows will match the c1 condition, whereas all will match c3
|
|
|
|
SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3;
|
|
|
|
|
|
|
|
# SHOULD use the pk.
|
|
|
|
# index on c3 will be used instead of primary key
|
|
|
|
EXPLAIN SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3;
|
|
|
|
|
|
|
|
# if we force the primary key, we can see the estimate is 1
|
|
|
|
EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3;
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
c1 int NOT NULL,
|
|
|
|
c2 int NOT NULL,
|
|
|
|
c3 int NOT NULL,
|
|
|
|
KEY (c1,c2),
|
|
|
|
KEY (c3)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
# SHOULD use the pk.
|
|
|
|
# if we switch it from a primary key to a regular index, it works correctly as well
|
|
|
|
explain SELECT * FROM t2 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3;
|
|
|
|
|
|
|
|
DROP TABLE t1,t2;
|
|
|
|
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # 36259: Optimizing with ORDER BY
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
a INT NOT NULL AUTO_INCREMENT,
|
|
|
|
b INT NOT NULL,
|
|
|
|
c INT NOT NULL,
|
|
|
|
d VARCHAR(5),
|
|
|
|
e INT NOT NULL,
|
|
|
|
PRIMARY KEY (a), KEY i2 (b,c,d)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
INSERT INTO t1 (b,c,d,e) VALUES (1,1,'a',1), (2,2,'b',2);
|
|
|
|
INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1;
|
|
|
|
INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1;
|
|
|
|
INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1;
|
|
|
|
INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1;
|
|
|
|
INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1;
|
|
|
|
INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1;
|
|
|
|
EXPLAIN SELECT * FROM t1 WHERE b=1 AND c=1 ORDER BY a;
|
|
|
|
EXPLAIN SELECT * FROM t1 FORCE INDEX(i2) WHERE b=1 and c=1 ORDER BY a;
|
|
|
|
EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a;
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2009-10-13 06:43:27 +02:00
|
|
|
--echo #
|
|
|
|
--echo # Bug #47963: Wrong results when index is used
|
|
|
|
--echo #
|
|
|
|
CREATE TABLE t1(
|
|
|
|
a VARCHAR(5) NOT NULL,
|
|
|
|
b VARCHAR(5) NOT NULL,
|
|
|
|
c DATETIME NOT NULL,
|
|
|
|
KEY (c)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1 VALUES('TEST', 'TEST', '2009-10-09 00:00:00');
|
|
|
|
SELECT * FROM t1 WHERE a = 'TEST' AND
|
|
|
|
c >= '2009-10-09 00:00:00' AND c <= '2009-10-09 00:00:00';
|
|
|
|
SELECT * FROM t1 WHERE a = 'TEST' AND
|
|
|
|
c >= '2009-10-09 00:00:00.0' AND c <= '2009-10-09 00:00:00.0';
|
|
|
|
SELECT * FROM t1 WHERE a = 'TEST' AND
|
|
|
|
c >= '2009-10-09 00:00:00.0' AND c <= '2009-10-09 00:00:00';
|
|
|
|
SELECT * FROM t1 WHERE a = 'TEST' AND
|
|
|
|
c >= '2009-10-09 00:00:00' AND c <= '2009-10-09 00:00:00.0';
|
|
|
|
SELECT * FROM t1 WHERE a = 'TEST' AND
|
|
|
|
c >= '2009-10-09 00:00:00.000' AND c <= '2009-10-09 00:00:00.000';
|
|
|
|
SELECT * FROM t1 WHERE a = 'TEST' AND
|
|
|
|
c >= '2009-10-09 00:00:00.00' AND c <= '2009-10-09 00:00:00.001';
|
|
|
|
SELECT * FROM t1 WHERE a = 'TEST' AND
|
|
|
|
c >= '2009-10-09 00:00:00.001' AND c <= '2009-10-09 00:00:00.00';
|
|
|
|
EXPLAIN SELECT * FROM t1 WHERE a = 'TEST' AND
|
|
|
|
c >= '2009-10-09 00:00:00.001' AND c <= '2009-10-09 00:00:00.00';
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2009-11-04 12:54:28 +01:00
|
|
|
--echo #
|
|
|
|
--echo # Bug #46175: NULL read_view and consistent read assertion
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
CREATE TABLE t1(a CHAR(13),KEY(a)) ENGINE=innodb;
|
|
|
|
CREATE TABLE t2(b DATETIME,KEY(b)) ENGINE=innodb;
|
|
|
|
INSERT INTO t1 VALUES (),();
|
|
|
|
INSERT INTO t2 VALUES (),();
|
|
|
|
CREATE OR REPLACE VIEW v1 AS SELECT 1 FROM t2
|
|
|
|
WHERE b =(SELECT a FROM t1 LIMIT 1);
|
|
|
|
|
|
|
|
--disable_query_log
|
|
|
|
--disable_result_log
|
|
|
|
CONNECT (con1, localhost, root,,);
|
|
|
|
--enable_query_log
|
|
|
|
--enable_result_log
|
|
|
|
CONNECTION default;
|
|
|
|
|
|
|
|
DELIMITER |;
|
|
|
|
CREATE PROCEDURE p1(num INT)
|
|
|
|
BEGIN
|
|
|
|
DECLARE i INT DEFAULT 0;
|
|
|
|
REPEAT
|
|
|
|
SHOW CREATE VIEW v1;
|
|
|
|
SET i:=i+1;
|
|
|
|
UNTIL i>num END REPEAT;
|
|
|
|
END|
|
|
|
|
DELIMITER ;|
|
|
|
|
|
|
|
|
--echo # Should not crash
|
|
|
|
--disable_query_log
|
|
|
|
--disable_result_log
|
|
|
|
--send CALL p1(1000)
|
|
|
|
CONNECTION con1;
|
|
|
|
--echo # Should not crash
|
|
|
|
CALL p1(1000);
|
|
|
|
|
|
|
|
CONNECTION default;
|
|
|
|
--reap
|
|
|
|
--enable_query_log
|
|
|
|
--enable_result_log
|
|
|
|
|
|
|
|
DISCONNECT con1;
|
|
|
|
DROP PROCEDURE p1;
|
|
|
|
DROP VIEW v1;
|
|
|
|
DROP TABLE t1,t2;
|
2009-10-13 06:43:27 +02:00
|
|
|
|
2010-01-29 16:04:37 +01:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # Bug #49324: more valgrind errors in test_if_skip_sort_order
|
|
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ;
|
|
|
|
--echo #should not cause valgrind warnings
|
|
|
|
SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2010-02-26 12:17:00 +01:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#50843: Filesort used instead of clustered index led to
|
|
|
|
--echo # performance degradation.
|
|
|
|
--echo #
|
|
|
|
create table t1(f1 int not null primary key, f2 int) engine=innodb;
|
|
|
|
create table t2(f1 int not null, key (f1)) engine=innodb;
|
|
|
|
insert into t1 values (1,1),(2,2),(3,3);
|
|
|
|
insert into t2 values (1),(2),(3);
|
|
|
|
explain select t1.* from t1 left join t2 using(f1) group by t1.f1;
|
|
|
|
drop table t1,t2;
|
|
|
|
--echo #
|
|
|
|
|
2010-01-29 16:04:37 +01:00
|
|
|
|
2008-12-08 11:23:33 +01:00
|
|
|
--echo End of 5.1 tests
|