diff --git a/mysql-test/suite/tokudb.savepoint/r/1078-2.result b/mysql-test/suite/tokudb.savepoint/r/1078-2.result new file mode 100755 index 00000000000..b90124ee267 --- /dev/null +++ b/mysql-test/suite/tokudb.savepoint/r/1078-2.result @@ -0,0 +1,279 @@ +SET STORAGE_ENGINE = 'TokuDB'; +DROP TABLE IF EXISTS t1; +set autocommit=0; +set session transaction isolation level read committed; +create table t1 (n int); +begin; +savepoint `my_savepoint`; +insert into t1 values (7); +savepoint `savept2`; +insert into t1 values (3); +select n from t1; +n +7 +3 +savepoint savept3; +rollback to savepoint savept2; +rollback to savepoint savept3; +ERROR 42000: SAVEPOINT savept3 does not exist +rollback to savepoint savept2; +release savepoint `my_savepoint`; +select n from t1; +n +7 +rollback to savepoint `my_savepoint`; +ERROR 42000: SAVEPOINT my_savepoint does not exist +rollback to savepoint savept2; +ERROR 42000: SAVEPOINT savept2 does not exist +insert into t1 values (8); +savepoint sv; +commit; +savepoint sv; +set autocommit=1; +rollback; +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +insert into t1 values (2,20); +select * from t1; +a b +1 10 +2 20 +savepoint b; +insert into t1 values (3,30); +rollback to savepoint a; +select * From t1; +a b +1 10 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +insert into t1 values (2,20); +select * from t1; +a b +1 10 +2 20 +savepoint b; +insert into t1 values (3,30); +release savepoint a; +select * From t1; +a b +1 10 +2 20 +3 30 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +a b +rollback to savepoint c; +select * From t1; +a b +rollback to savepoint b; +select * from t1; +a b +1 100 +rollback to savepoint a; +select * from t1; +a b +1 10 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +insert into t1 values (1,1); +select * from t1; +a b +1 1 +begin; +replace into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +a b +rollback to savepoint c; +select * From t1; +a b +rollback to savepoint b; +select * from t1; +a b +1 100 +rollback to savepoint a; +select * from t1; +a b +1 10 +rollback; +select * from t1; +a b +1 1 +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +insert into t1 values (2,20); +select * from t1; +a b +2 20 +release savepoint c; +select * From t1; +a b +2 20 +release savepoint b; +select * from t1; +a b +2 20 +release savepoint a; +select * from t1; +a b +2 20 +commit; +select * from t1; +a b +2 20 +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +insert into t1 values (2,20); +select * from t1; +a b +2 20 +release savepoint c; +select * From t1; +a b +2 20 +rollback to savepoint b; +select * from t1; +a b +1 100 +release savepoint a; +select * from t1; +a b +1 100 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +insert into t1 values (2,20); +savepoint a; +insert into t1 values (3,30),(4,40); +insert into t1 values (5,50),(6,60), (3,333), (7,70); +ERROR 23000: Duplicate entry '3' for key 'PRIMARY' +select * from t1; +a b +1 10 +2 20 +3 30 +4 40 +savepoint b; +insert ignore into t1 values (8,80),(1,100),(9,90); +select * from t1; +a b +1 10 +2 20 +3 30 +4 40 +8 80 +9 90 +rollback to savepoint b; +select * from t1; +a b +1 10 +2 20 +3 30 +4 40 +rollback to savepoint a; +select * from t1; +a b +1 10 +2 20 +insert into t1 value (10,100); +savepoint c; +select * from t1; +a b +1 10 +2 20 +10 100 +release savepoint a; +rollback to savepoint c; +ERROR 42000: SAVEPOINT c does not exist +commit; +select * from t1; +a b +1 10 +2 20 +10 100 +drop table t1; diff --git a/mysql-test/suite/tokudb.savepoint/r/1078-3.result b/mysql-test/suite/tokudb.savepoint/r/1078-3.result new file mode 100755 index 00000000000..48666e6a941 --- /dev/null +++ b/mysql-test/suite/tokudb.savepoint/r/1078-3.result @@ -0,0 +1,279 @@ +SET STORAGE_ENGINE = 'TokuDB'; +DROP TABLE IF EXISTS t1; +set autocommit=0; +set session transaction isolation level read uncommitted; +create table t1 (n int); +begin; +savepoint `my_savepoint`; +insert into t1 values (7); +savepoint `savept2`; +insert into t1 values (3); +select n from t1; +n +7 +3 +savepoint savept3; +rollback to savepoint savept2; +rollback to savepoint savept3; +ERROR 42000: SAVEPOINT savept3 does not exist +rollback to savepoint savept2; +release savepoint `my_savepoint`; +select n from t1; +n +7 +rollback to savepoint `my_savepoint`; +ERROR 42000: SAVEPOINT my_savepoint does not exist +rollback to savepoint savept2; +ERROR 42000: SAVEPOINT savept2 does not exist +insert into t1 values (8); +savepoint sv; +commit; +savepoint sv; +set autocommit=1; +rollback; +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +insert into t1 values (2,20); +select * from t1; +a b +1 10 +2 20 +savepoint b; +insert into t1 values (3,30); +rollback to savepoint a; +select * From t1; +a b +1 10 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +insert into t1 values (2,20); +select * from t1; +a b +1 10 +2 20 +savepoint b; +insert into t1 values (3,30); +release savepoint a; +select * From t1; +a b +1 10 +2 20 +3 30 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +a b +rollback to savepoint c; +select * From t1; +a b +rollback to savepoint b; +select * from t1; +a b +1 100 +rollback to savepoint a; +select * from t1; +a b +1 10 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +insert into t1 values (1,1); +select * from t1; +a b +1 1 +begin; +replace into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +a b +rollback to savepoint c; +select * From t1; +a b +rollback to savepoint b; +select * from t1; +a b +1 100 +rollback to savepoint a; +select * from t1; +a b +1 10 +rollback; +select * from t1; +a b +1 1 +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +insert into t1 values (2,20); +select * from t1; +a b +2 20 +release savepoint c; +select * From t1; +a b +2 20 +release savepoint b; +select * from t1; +a b +2 20 +release savepoint a; +select * from t1; +a b +2 20 +commit; +select * from t1; +a b +2 20 +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +insert into t1 values (2,20); +select * from t1; +a b +2 20 +release savepoint c; +select * From t1; +a b +2 20 +rollback to savepoint b; +select * from t1; +a b +1 100 +release savepoint a; +select * from t1; +a b +1 100 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +insert into t1 values (2,20); +savepoint a; +insert into t1 values (3,30),(4,40); +insert into t1 values (5,50),(6,60), (3,333), (7,70); +ERROR 23000: Duplicate entry '3' for key 'PRIMARY' +select * from t1; +a b +1 10 +2 20 +3 30 +4 40 +savepoint b; +insert ignore into t1 values (8,80),(1,100),(9,90); +select * from t1; +a b +1 10 +2 20 +3 30 +4 40 +8 80 +9 90 +rollback to savepoint b; +select * from t1; +a b +1 10 +2 20 +3 30 +4 40 +rollback to savepoint a; +select * from t1; +a b +1 10 +2 20 +insert into t1 value (10,100); +savepoint c; +select * from t1; +a b +1 10 +2 20 +10 100 +release savepoint a; +rollback to savepoint c; +ERROR 42000: SAVEPOINT c does not exist +commit; +select * from t1; +a b +1 10 +2 20 +10 100 +drop table t1; diff --git a/mysql-test/suite/tokudb.savepoint/r/1078-4.result b/mysql-test/suite/tokudb.savepoint/r/1078-4.result new file mode 100755 index 00000000000..2a5f781f1fc --- /dev/null +++ b/mysql-test/suite/tokudb.savepoint/r/1078-4.result @@ -0,0 +1,279 @@ +SET STORAGE_ENGINE = 'TokuDB'; +DROP TABLE IF EXISTS t1; +set autocommit=0; +set session transaction isolation level serializable; +create table t1 (n int); +begin; +savepoint `my_savepoint`; +insert into t1 values (7); +savepoint `savept2`; +insert into t1 values (3); +select n from t1; +n +7 +3 +savepoint savept3; +rollback to savepoint savept2; +rollback to savepoint savept3; +ERROR 42000: SAVEPOINT savept3 does not exist +rollback to savepoint savept2; +release savepoint `my_savepoint`; +select n from t1; +n +7 +rollback to savepoint `my_savepoint`; +ERROR 42000: SAVEPOINT my_savepoint does not exist +rollback to savepoint savept2; +ERROR 42000: SAVEPOINT savept2 does not exist +insert into t1 values (8); +savepoint sv; +commit; +savepoint sv; +set autocommit=1; +rollback; +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +insert into t1 values (2,20); +select * from t1; +a b +1 10 +2 20 +savepoint b; +insert into t1 values (3,30); +rollback to savepoint a; +select * From t1; +a b +1 10 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +insert into t1 values (2,20); +select * from t1; +a b +1 10 +2 20 +savepoint b; +insert into t1 values (3,30); +release savepoint a; +select * From t1; +a b +1 10 +2 20 +3 30 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +a b +rollback to savepoint c; +select * From t1; +a b +rollback to savepoint b; +select * from t1; +a b +1 100 +rollback to savepoint a; +select * from t1; +a b +1 10 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +insert into t1 values (1,1); +select * from t1; +a b +1 1 +begin; +replace into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +a b +rollback to savepoint c; +select * From t1; +a b +rollback to savepoint b; +select * from t1; +a b +1 100 +rollback to savepoint a; +select * from t1; +a b +1 10 +rollback; +select * from t1; +a b +1 1 +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +insert into t1 values (2,20); +select * from t1; +a b +2 20 +release savepoint c; +select * From t1; +a b +2 20 +release savepoint b; +select * from t1; +a b +2 20 +release savepoint a; +select * from t1; +a b +2 20 +commit; +select * from t1; +a b +2 20 +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +a b +1 10 +savepoint a; +replace into t1 values (1,100); +select * from t1; +a b +1 100 +savepoint b; +delete from t1 where a=1; +select * from t1; +a b +savepoint c; +insert into t1 values (2,20); +select * from t1; +a b +2 20 +release savepoint c; +select * From t1; +a b +2 20 +rollback to savepoint b; +select * from t1; +a b +1 100 +release savepoint a; +select * from t1; +a b +1 100 +rollback; +select * from t1; +a b +drop table t1; +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +insert into t1 values (2,20); +savepoint a; +insert into t1 values (3,30),(4,40); +insert into t1 values (5,50),(6,60), (3,333), (7,70); +ERROR 23000: Duplicate entry '3' for key 'PRIMARY' +select * from t1; +a b +1 10 +2 20 +3 30 +4 40 +savepoint b; +insert ignore into t1 values (8,80),(1,100),(9,90); +select * from t1; +a b +1 10 +2 20 +3 30 +4 40 +8 80 +9 90 +rollback to savepoint b; +select * from t1; +a b +1 10 +2 20 +3 30 +4 40 +rollback to savepoint a; +select * from t1; +a b +1 10 +2 20 +insert into t1 value (10,100); +savepoint c; +select * from t1; +a b +1 10 +2 20 +10 100 +release savepoint a; +rollback to savepoint c; +ERROR 42000: SAVEPOINT c does not exist +commit; +select * from t1; +a b +1 10 +2 20 +10 100 +drop table t1; diff --git a/mysql-test/suite/tokudb.savepoint/r/1078.result b/mysql-test/suite/tokudb.savepoint/r/1078.result index b13a6684c23..23b1f5be1e3 100755 --- a/mysql-test/suite/tokudb.savepoint/r/1078.result +++ b/mysql-test/suite/tokudb.savepoint/r/1078.result @@ -1,6 +1,7 @@ SET STORAGE_ENGINE = 'TokuDB'; DROP TABLE IF EXISTS t1; set autocommit=0; +set session transaction isolation level repeatable read; create table t1 (n int); begin; savepoint `my_savepoint`; diff --git a/mysql-test/suite/tokudb.savepoint/t/1078-2.test b/mysql-test/suite/tokudb.savepoint/t/1078-2.test new file mode 100755 index 00000000000..399f872f7e3 --- /dev/null +++ b/mysql-test/suite/tokudb.savepoint/t/1078-2.test @@ -0,0 +1,216 @@ +# ticket 895 is a query optimization problem with the primary key + +--source include/have_tokudb.inc +SET STORAGE_ENGINE = 'TokuDB'; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +set autocommit=0; + +set session transaction isolation level read committed; + +create table t1 (n int); +# +# savepoints +# +begin; +savepoint `my_savepoint`; +insert into t1 values (7); +savepoint `savept2`; +insert into t1 values (3); +select n from t1; +savepoint savept3; +rollback to savepoint savept2; +--error 1305 +rollback to savepoint savept3; +rollback to savepoint savept2; +release savepoint `my_savepoint`; +select n from t1; +-- error 1305 +rollback to savepoint `my_savepoint`; +--error 1305 +rollback to savepoint savept2; +insert into t1 values (8); +savepoint sv; +commit; +savepoint sv; +set autocommit=1; +# nop +rollback; +drop table t1; + +# +# test rollback to savepoint (that is not last savepoint) +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +insert into t1 values (2,20); +select * from t1; +savepoint b; +insert into t1 values (3,30); +rollback to savepoint a; +select * From t1; +rollback; +select * from t1; +drop table t1; + +# +# test release of savepoint (that is not last savepoint) +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +insert into t1 values (2,20); +select * from t1; +savepoint b; +insert into t1 values (3,30); +release savepoint a; +select * From t1; +rollback; +select * from t1; +drop table t1; + +# +# test rollback to savepoints when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +rollback to savepoint c; +select * From t1; +rollback to savepoint b; +select * from t1; +rollback to savepoint a; +select * from t1; +rollback; +select * from t1; +drop table t1; + +# +# test rollback to savepoints when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +insert into t1 values (1,1); +select * from t1; +begin; +replace into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +rollback to savepoint c; +select * From t1; +rollback to savepoint b; +select * from t1; +rollback to savepoint a; +select * from t1; +rollback; +select * from t1; +drop table t1; + + + +# +# test release of savepoints when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +insert into t1 values (2,20); +select * from t1; +release savepoint c; +select * From t1; +release savepoint b; +select * from t1; +release savepoint a; +select * from t1; +commit; +select * from t1; +drop table t1; + +# +# test release of savepoints and then rollback of savepoint when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +insert into t1 values (2,20); +select * from t1; +release savepoint c; +select * From t1; +rollback to savepoint b; +select * from t1; +release savepoint a; +select * from t1; +rollback; +select * from t1; +drop table t1; + + + +# +# get statement transactions to abort +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +insert into t1 values (2,20); +savepoint a; +insert into t1 values (3,30),(4,40); +--error ER_DUP_ENTRY +insert into t1 values (5,50),(6,60), (3,333), (7,70); +select * from t1; +savepoint b; +insert ignore into t1 values (8,80),(1,100),(9,90); +select * from t1; +rollback to savepoint b; +select * from t1; +rollback to savepoint a; +select * from t1; +insert into t1 value (10,100); +savepoint c; +select * from t1; +release savepoint a; +--error 1305 +rollback to savepoint c; +commit; +select * from t1; +drop table t1; diff --git a/mysql-test/suite/tokudb.savepoint/t/1078-3.test b/mysql-test/suite/tokudb.savepoint/t/1078-3.test new file mode 100755 index 00000000000..5b1230cafde --- /dev/null +++ b/mysql-test/suite/tokudb.savepoint/t/1078-3.test @@ -0,0 +1,216 @@ +# ticket 895 is a query optimization problem with the primary key + +--source include/have_tokudb.inc +SET STORAGE_ENGINE = 'TokuDB'; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +set autocommit=0; + +set session transaction isolation level read uncommitted; + +create table t1 (n int); +# +# savepoints +# +begin; +savepoint `my_savepoint`; +insert into t1 values (7); +savepoint `savept2`; +insert into t1 values (3); +select n from t1; +savepoint savept3; +rollback to savepoint savept2; +--error 1305 +rollback to savepoint savept3; +rollback to savepoint savept2; +release savepoint `my_savepoint`; +select n from t1; +-- error 1305 +rollback to savepoint `my_savepoint`; +--error 1305 +rollback to savepoint savept2; +insert into t1 values (8); +savepoint sv; +commit; +savepoint sv; +set autocommit=1; +# nop +rollback; +drop table t1; + +# +# test rollback to savepoint (that is not last savepoint) +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +insert into t1 values (2,20); +select * from t1; +savepoint b; +insert into t1 values (3,30); +rollback to savepoint a; +select * From t1; +rollback; +select * from t1; +drop table t1; + +# +# test release of savepoint (that is not last savepoint) +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +insert into t1 values (2,20); +select * from t1; +savepoint b; +insert into t1 values (3,30); +release savepoint a; +select * From t1; +rollback; +select * from t1; +drop table t1; + +# +# test rollback to savepoints when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +rollback to savepoint c; +select * From t1; +rollback to savepoint b; +select * from t1; +rollback to savepoint a; +select * from t1; +rollback; +select * from t1; +drop table t1; + +# +# test rollback to savepoints when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +insert into t1 values (1,1); +select * from t1; +begin; +replace into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +rollback to savepoint c; +select * From t1; +rollback to savepoint b; +select * from t1; +rollback to savepoint a; +select * from t1; +rollback; +select * from t1; +drop table t1; + + + +# +# test release of savepoints when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +insert into t1 values (2,20); +select * from t1; +release savepoint c; +select * From t1; +release savepoint b; +select * from t1; +release savepoint a; +select * from t1; +commit; +select * from t1; +drop table t1; + +# +# test release of savepoints and then rollback of savepoint when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +insert into t1 values (2,20); +select * from t1; +release savepoint c; +select * From t1; +rollback to savepoint b; +select * from t1; +release savepoint a; +select * from t1; +rollback; +select * from t1; +drop table t1; + + + +# +# get statement transactions to abort +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +insert into t1 values (2,20); +savepoint a; +insert into t1 values (3,30),(4,40); +--error ER_DUP_ENTRY +insert into t1 values (5,50),(6,60), (3,333), (7,70); +select * from t1; +savepoint b; +insert ignore into t1 values (8,80),(1,100),(9,90); +select * from t1; +rollback to savepoint b; +select * from t1; +rollback to savepoint a; +select * from t1; +insert into t1 value (10,100); +savepoint c; +select * from t1; +release savepoint a; +--error 1305 +rollback to savepoint c; +commit; +select * from t1; +drop table t1; diff --git a/mysql-test/suite/tokudb.savepoint/t/1078-4.test b/mysql-test/suite/tokudb.savepoint/t/1078-4.test new file mode 100755 index 00000000000..4119629e737 --- /dev/null +++ b/mysql-test/suite/tokudb.savepoint/t/1078-4.test @@ -0,0 +1,216 @@ +# ticket 895 is a query optimization problem with the primary key + +--source include/have_tokudb.inc +SET STORAGE_ENGINE = 'TokuDB'; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +set autocommit=0; + +set session transaction isolation level serializable; + +create table t1 (n int); +# +# savepoints +# +begin; +savepoint `my_savepoint`; +insert into t1 values (7); +savepoint `savept2`; +insert into t1 values (3); +select n from t1; +savepoint savept3; +rollback to savepoint savept2; +--error 1305 +rollback to savepoint savept3; +rollback to savepoint savept2; +release savepoint `my_savepoint`; +select n from t1; +-- error 1305 +rollback to savepoint `my_savepoint`; +--error 1305 +rollback to savepoint savept2; +insert into t1 values (8); +savepoint sv; +commit; +savepoint sv; +set autocommit=1; +# nop +rollback; +drop table t1; + +# +# test rollback to savepoint (that is not last savepoint) +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +insert into t1 values (2,20); +select * from t1; +savepoint b; +insert into t1 values (3,30); +rollback to savepoint a; +select * From t1; +rollback; +select * from t1; +drop table t1; + +# +# test release of savepoint (that is not last savepoint) +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +insert into t1 values (2,20); +select * from t1; +savepoint b; +insert into t1 values (3,30); +release savepoint a; +select * From t1; +rollback; +select * from t1; +drop table t1; + +# +# test rollback to savepoints when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +rollback to savepoint c; +select * From t1; +rollback to savepoint b; +select * from t1; +rollback to savepoint a; +select * from t1; +rollback; +select * from t1; +drop table t1; + +# +# test rollback to savepoints when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +insert into t1 values (1,1); +select * from t1; +begin; +replace into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +update t1 set b=1000 where a=1; +select * from t1; +rollback to savepoint c; +select * From t1; +rollback to savepoint b; +select * from t1; +rollback to savepoint a; +select * from t1; +rollback; +select * from t1; +drop table t1; + + + +# +# test release of savepoints when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +insert into t1 values (2,20); +select * from t1; +release savepoint c; +select * From t1; +release savepoint b; +select * from t1; +release savepoint a; +select * from t1; +commit; +select * from t1; +drop table t1; + +# +# test release of savepoints and then rollback of savepoint when doing work on same key +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +select * from t1; +savepoint a; +replace into t1 values (1,100); +select * from t1; +savepoint b; +delete from t1 where a=1; +select * from t1; +savepoint c; +insert into t1 values (2,20); +select * from t1; +release savepoint c; +select * From t1; +rollback to savepoint b; +select * from t1; +release savepoint a; +select * from t1; +rollback; +select * from t1; +drop table t1; + + + +# +# get statement transactions to abort +# +create table t1 (a int, b int, primary key (a)); +begin; +insert into t1 values (1,10); +insert into t1 values (2,20); +savepoint a; +insert into t1 values (3,30),(4,40); +--error ER_DUP_ENTRY +insert into t1 values (5,50),(6,60), (3,333), (7,70); +select * from t1; +savepoint b; +insert ignore into t1 values (8,80),(1,100),(9,90); +select * from t1; +rollback to savepoint b; +select * from t1; +rollback to savepoint a; +select * from t1; +insert into t1 value (10,100); +savepoint c; +select * from t1; +release savepoint a; +--error 1305 +rollback to savepoint c; +commit; +select * from t1; +drop table t1; diff --git a/mysql-test/suite/tokudb.savepoint/t/1078.test b/mysql-test/suite/tokudb.savepoint/t/1078.test index aeab4c32aab..13a4a068c96 100755 --- a/mysql-test/suite/tokudb.savepoint/t/1078.test +++ b/mysql-test/suite/tokudb.savepoint/t/1078.test @@ -8,6 +8,8 @@ DROP TABLE IF EXISTS t1; --enable_warnings set autocommit=0; +set session transaction isolation level repeatable read; + create table t1 (n int); # # savepoints