Commit 3772df8b authored by Zardosht Kasheff's avatar Zardosht Kasheff

[t:2893], add some savepoint tests

git-svn-id: file:///svn/mysql/tests/mysql-test@23633 c7de825b-a66e-492c-adef-691d508d4ae1
parent c6146429
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;
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;
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;
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`;
......
# 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;
# 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;
# 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;
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment