summaryrefslogtreecommitdiff
path: root/mysql-test/r
diff options
context:
space:
mode:
authordlenev@mockturtle.local <>2007-05-19 10:49:56 +0400
committerdlenev@mockturtle.local <>2007-05-19 10:49:56 +0400
commitb0dfdc2b83a114b6f7b5e6404963da9ae1fb633c (patch)
tree0fdbeaf9dbc2599825b08e2a54dcf4fe861c91c6 /mysql-test/r
parente4a3189c4f20fdf18424bcbc9b7721cf149bf148 (diff)
downloadmariadb-git-b0dfdc2b83a114b6f7b5e6404963da9ae1fb633c.tar.gz
Patch changing how ALTER TABLE implementation handles table locking
and invalidation in the most general case (non-temporary table and not simple RENAME or ENABLE/DISABLE KEYS or partitioning command). See comment for sql/sql_table.cc for more information. These changes are prerequisite for 5.1 version of fix for bug #23667 "CREATE TABLE LIKE is not isolated from alteration by other connections"
Diffstat (limited to 'mysql-test/r')
-rw-r--r--mysql-test/r/alter_table-big.result41
-rw-r--r--mysql-test/r/alter_table.result53
-rw-r--r--mysql-test/r/innodb_mysql.result24
3 files changed, 117 insertions, 1 deletions
diff --git a/mysql-test/r/alter_table-big.result b/mysql-test/r/alter_table-big.result
index a9d0515d6bb..9761754a02f 100644
--- a/mysql-test/r/alter_table-big.result
+++ b/mysql-test/r/alter_table-big.result
@@ -5,14 +5,53 @@ key (n2, n3, n1),
key (n3, n1, n2));
create table t2 (i int);
alter table t1 disable keys;
+insert into t1 values (RAND()*1000, RAND()*1000, RAND()*1000);
reset master;
+set session debug="+d,sleep_alter_enable_indexes";
alter table t1 enable keys;;
insert into t2 values (1);
insert into t1 values (1, 1, 1);
-show binlog events in 'master-bin.000001' from 102;
+set session debug="-d,sleep_alter_enable_indexes";
+show binlog events in 'master-bin.000001' from 106;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; insert into t2 values (1)
master-bin.000001 # Query 1 # use `test`; alter table t1 enable keys
master-bin.000001 # Query 1 # use `test`; insert into t1 values (1, 1, 1)
drop tables t1, t2;
End of 5.0 tests
+drop table if exists t1, t2, t3;
+create table t1 (i int);
+reset master;
+set session debug="+d,sleep_alter_before_main_binlog";
+alter table t1 change i c char(10) default 'Test1';;
+insert into t1 values ();
+select * from t1;
+c
+Test1
+alter table t1 change c vc varchar(100) default 'Test2';;
+rename table t1 to t2;
+drop table t2;
+create table t1 (i int);
+alter table t1 change i c char(10) default 'Test3', rename to t2;;
+insert into t2 values ();
+select * from t2;
+c
+Test3
+alter table t2 change c vc varchar(100) default 'Test2', rename to t1;;
+rename table t1 to t3;
+drop table t3;
+set session debug="-d,sleep_alter_before_main_binlog";
+show binlog events in 'master-bin.000001' from 106;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query 1 # use `test`; alter table t1 change i c char(10) default 'Test1'
+master-bin.000001 # Query 1 # use `test`; insert into t1 values ()
+master-bin.000001 # Query 1 # use `test`; alter table t1 change c vc varchar(100) default 'Test2'
+master-bin.000001 # Query 1 # use `test`; rename table t1 to t2
+master-bin.000001 # Query 1 # use `test`; drop table t2
+master-bin.000001 # Query 1 # use `test`; create table t1 (i int)
+master-bin.000001 # Query 1 # use `test`; alter table t1 change i c char(10) default 'Test3', rename to t2
+master-bin.000001 # Query 1 # use `test`; insert into t2 values ()
+master-bin.000001 # Query 1 # use `test`; alter table t2 change c vc varchar(100) default 'Test2', rename to t1
+master-bin.000001 # Query 1 # use `test`; rename table t1 to t3
+master-bin.000001 # Query 1 # use `test`; drop table t3
+End of 5.1 tests
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index 4481b56791f..63dc13a4b6d 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -977,6 +977,59 @@ SELECT * FROM t1;
v b
abc 5
DROP TABLE t1;
+End of 5.0 tests
+drop table if exists t1, t2, t3;
+create table t1 (i int);
+create table t3 (j int);
+insert into t1 values ();
+insert into t3 values ();
+lock table t1 write, t3 read;
+alter table t1 modify i int default 1;
+insert into t1 values ();
+select * from t1;
+i
+NULL
+1
+alter table t1 change i c char(10) default "Two";
+insert into t1 values ();
+select * from t1;
+c
+NULL
+1
+Two
+alter table t1 modify c char(10) default "Three", rename to t2;
+select * from t1;
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+select * from t2;
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
+select * from t3;
+j
+NULL
+unlock tables;
+insert into t2 values ();
+select * from t2;
+c
+NULL
+1
+Three
+lock table t2 write, t3 read;
+alter table t2 change c vc varchar(100) default "Four", rename to t1;
+select * from t1;
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+select * from t2;
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
+select * from t3;
+j
+NULL
+unlock tables;
+insert into t1 values ();
+select * from t1;
+vc
+NULL
+1
+Three
+Four
+drop tables t1, t3;
DROP TABLE IF EXISTS `t+1`, `t+2`;
CREATE TABLE `t+1` (c1 INT);
ALTER TABLE `t+1` RENAME `t+2`;
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index dc9564b21a2..c8aea5ebb61 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -796,4 +796,28 @@ lock table t2 write;
alter table t2 modify i int default 4, rename t1;
unlock tables;
drop table t1;
+drop table if exists t1;
+create table t1 (i int);
+insert into t1 values ();
+lock table t1 write;
+alter table t1 modify i int default 1;
+insert into t1 values ();
+select * from t1;
+i
+NULL
+1
+alter table t1 change i c char(10) default "Two";
+insert into t1 values ();
+select * from t1;
+c
+NULL
+1
+Two
+unlock tables;
+select * from t1;
+c
+NULL
+1
+Two
+drop tables t1;
End of 5.1 tests