📄 xasimplenegative.sql
字号:
-- -- some negative test for error checking--xa_datasource 'wombat';xa_connect user 'negativeTest' password 'xxx';-- start new transactionxa_start xa_noflags 0;-- ERROR: cannot start without endxa_start xa_noflags 1;xa_getconnection;-- ERROR: cannot get connection againxa_getconnection;-- ERROR: connot commit/rollback an xa connectioncommit;-- ERROR: connot commit/rollback an xa connectionrollback;drop table APP.negative;create table APP.negative (a char(10), b int);create unique index negativei on APP.negative(b);run resource '/org/apache/derbyTesting/functionTests/tests/store/global_xactTable.view';insert into APP.negative values ('xyz', 1);select * from APP.negative;-- ERROR: cannot commit/prepare/rollback without endxa_commit xa_1phase 0;-- ERROR: cannot commit/prepare/rollback without endxa_rollback 0;-- ERROR: cannot commit/prepare/rollback without endxa_prepare 0;-- OK suspend itxa_end xa_suspend 0;-- ERROR: duplicate xidxa_start xa_noflags 0;-- ERROR: cannot commit/prepare/rollback with suspendedxa_commit xa_1phase 0;-- ERROR: cannot commit/prepare/rollback with suspendedxa_rollback 0;-- ERROR: cannot commit/prepare/rollback with suspendedxa_prepare 0;-- ERROR: cannot commit/prepare/rollback with suspendedxa_commit xa_2phase 0;xa_end xa_success 0;xa_prepare 0;xa_commit xa_2phase 0;-- should be able to use this xid againxa_start xa_noflags 0;-- ERROR: cannot start without endxa_start xa_noflags 0;-- ERROR: duplicate key exception, statement level rollbackinsert into APP.negative values ('rollback', 1);select * from APP.negative;insert into APP.negative values ('ok', 2);select * from global_xactTable order by gxid, status, username, type;disconnect;xa_end xa_fail 0;xa_start xa_noflags 2;xa_getconnection;insert into APP.negative values ('ok', 3);-- ERROR: cannot suspend some other xidxa_end xa_suspend 3;-- ERROR: cannot end some other xid while I am still attachedxa_end xa_success 0;xa_end xa_suspend 2;-- ERROR: cannot join an xid I just suspended have to resumexa_start xa_join 2;xa_start xa_resume 2;xa_end xa_suspend 2;xa_rollback 0;-- ERROR: should not find this xid any morexa_prepare 0;select * from global_xactTable order by gxid, status, username, type;xa_end xa_success 2;disconnect;-- ERROR: can only join a successful branch, not resume xa_start xa_resume 2;-- this is OKxa_start xa_join 2;xa_getconnection;-- ERROR: another dup insert into APP.negative values ('rollback', 3);xa_end xa_suspend 2;xa_end xa_success 2;-- ERROR: cannot call fail nowxa_end xa_fail 2;-- rollback is OKxa_rollback 2;-- ERROR: cannot join something that is not therexa_start xa_join 2;-- ERROR: cannot join something that is not therexa_start xa_resume 2;-- start onexa_start xa_noflags 1;-- ERROR: can only forget heuristically completed transactionxa_forget 1;delete from APP.negative;xa_end xa_success 1;-- ERROR: now try some bad flag xa_start xa_suspend 1;-- ERROR: now try some bad flag xa_start xa_fail 1;xa_prepare 1;-- can only forget heuristically completed transactionxa_forget 1;xa_start xa_noflags 2;-- ERROR: deadlock, transaction trashedselect * from APP.negative;-- ERROR: should have no connection underneathselect * from APP.negative;-- ERROR: should have no connection underneath and xid 2 is gonexa_end xa_suspend 2;-- ERROR: should have no connection underneath and xid 2 is gonexa_end xa_fail 2;xa_rollback 2;disconnect;xa_start xa_noflags 3;xa_getconnection;select * from global_xactTable order by gxid, status, username, type;drop table foo;create table foo (a int);xa_end xa_suspend 3;-- ERROR: cannot join a prepared transactionxa_start xa_join 1;-- ERROR: cannot resume a prepared transactionxa_start xa_resume 1;-- ERROR: bad flagxa_start xa_fail 1;-- ERROR: bad flagxa_start xa_noflags 1;-- rollback prepared transaction is OKxa_rollback 1;-- ERROR: dup idxa_start xa_noflags 3;xa_start xa_resume 3;-- now that 1 is rolled back, this should succeedselect * from APP.negative;select * from global_xactTable order by gxid, status, username, type;-- ERROR: bad flagxa_end xa_noflags 3;xa_end xa_fail 3;xa_rollback 3;-- ensure switching back and forward does not commit-- the xact due to the commit in setAutoCommit();AUTOCOMMIT ON;create table t44g(a int);insert into t44g values 1,2;select * from t44g where a > 4000;create table t44(i int);xa_start xa_noflags 44;insert into t44g values(4400);insert into t44g values(4401);xa_end xa_suspend 44;values (1,2,3);commit;AUTOCOMMIT OFF;insert into t44 values(1);insert into t44 values(2);commit;insert into t44 values(3);insert into t44 values(4);rollback;AUTOCOMMIT ON;-- fail with lock issuesselect * from t44g;xa_start xa_resume 44;insert into t44g values(4500);insert into t44g values(4501);xa_end xa_success 44;insert into t44 values(5);insert into t44 values(6);commit;AUTOCOMMIT OFF;insert into t44 values(7);insert into t44 values(8);commit;AUTOCOMMIT ON;xa_start xa_join 44;select * from t44g where a > 4000;xa_end xa_success 44;-- fail with lock issuesselect * from t44g;xa_rollback 44;-- should be empty if no commit occurred in the middle;select * from t44g where a > 4000;select * from t44;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -