|
| 1 | +# ==== Purpose ==== |
| 2 | +# |
| 3 | +# The purpose of this test is to ensure that the server properly disregards XA |
| 4 | +# transaction related statements that try to operate upon an unknown XID, when |
| 5 | +# on SBR. |
| 6 | +# |
| 7 | +# ==== Requirements ==== |
| 8 | +# |
| 9 | +# R1. Ensure that execution proceeds normaly after trying - and failling - to |
| 10 | +# execute `XA COMMIT / ROLLBACK` with an unkown XID. |
| 11 | +# |
| 12 | +# ==== Implementation ==== |
| 13 | +# |
| 14 | +# Ensure that the server properly disregards XA related statements that operate |
| 15 | +# on unknown XIDs given the following setup / statements combinations: |
| 16 | +# |
| 17 | +# TC1. Manual GTID and apply `XA ROLLBACK` with unkown XID |
| 18 | +# -------------------------------------------------------- |
| 19 | +# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 20 | +# 2) Set `GTID_NEXT` to manually introduced value. |
| 21 | +# 3) Execute a DML statement. |
| 22 | +# 4) Execute `XA ROLLBACK` with an unknown XID. |
| 23 | +# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 24 | +# commited. |
| 25 | +# |
| 26 | +# TC2. Manual GTID and apply `XA ROLLBACK` with unkown XID |
| 27 | +# -------------------------------------------------------- |
| 28 | +# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 29 | +# 2) Set `GTID_NEXT` to manually introduced value. |
| 30 | +# 3) Execute a DML statement. |
| 31 | +# 4) Execute `XA ROLLBACK` with an unknown XID. |
| 32 | +# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 33 | +# commited. |
| 34 | +# |
| 35 | +# TC3. Manual GTID and apply `XA ROLLBACK` to an existent XA transaction |
| 36 | +# -------------------------------------------------------------------- |
| 37 | +# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 38 | +# 2) Set `GTID_NEXT` to manually introduced value. |
| 39 | +# 3) Execute a DML statement. |
| 40 | +# 4) Execute `XA ROLLBACK` with an existent XID. |
| 41 | +# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 42 | +# commited. |
| 43 | +# |
| 44 | +# TC4. Manual GTID and apply `XA COMMIT` to an existent XA transaction |
| 45 | +# ----------------------------------------------------------------------- |
| 46 | +# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 47 | +# 2) Set `GTID_NEXT` to manually introduced value. |
| 48 | +# 3) Execute a DML statement. |
| 49 | +# 4) Execute `XA COMMIT` with an existent XID. |
| 50 | +# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 51 | +# commited. |
| 52 | +# |
| 53 | +# ==== References ==== |
| 54 | +# |
| 55 | +# BUG#27928837 `HEAD->VARIABLES.GTID_NEXT.TYPE != UNDEFINED_GTID` |
| 56 | + |
| 57 | +--source include/have_gtid.inc |
| 58 | + |
| 59 | +--let $current_autocommit= `SELECT @@AUTOCOMMIT` |
| 60 | + |
| 61 | +CREATE TABLE t2(a INT); |
| 62 | + |
| 63 | +# TC1. Manual GTID and apply `XA ROLLBACK` with unkown XID |
| 64 | +# -------------------------------------------------------- |
| 65 | +# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 66 | +SET @@AUTOCOMMIT=0; |
| 67 | +# 2) Set `GTID_NEXT` to manually introduced value. |
| 68 | +SET SESSION GTID_NEXT='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:1'; |
| 69 | +# 3) Execute a DML statement. |
| 70 | +INSERT INTO t2 VALUES(1); |
| 71 | +# 4) Execute `XA ROLLBACK` with an unknown XID. |
| 72 | +--error ER_XAER_NOTA |
| 73 | +XA ROLLBACK 'xa1'; |
| 74 | +# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 75 | +# commited. |
| 76 | +SET @@AUTOCOMMIT=1; |
| 77 | +# |
| 78 | + |
| 79 | +# TC2. Manul GTID and apply `XA ROLLBACK` with unkown XID |
| 80 | +# ----------------------------------------------------------- |
| 81 | +# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 82 | +SET @@AUTOCOMMIT=0; |
| 83 | +# 2) Set `GTID_NEXT` to manually introduced value. |
| 84 | +SET SESSION GTID_NEXT='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:2'; |
| 85 | +# 3) Execute a DML statement. |
| 86 | +INSERT INTO t2 VALUES(2); |
| 87 | +# 4) Execute `XA COMMIT` with an unknown XID. |
| 88 | +--error ER_XAER_NOTA |
| 89 | +XA COMMIT 'xa1'; |
| 90 | +# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 91 | +# commited. |
| 92 | +SET @@AUTOCOMMIT=1; |
| 93 | +# |
| 94 | + |
| 95 | +--connect (other_conn, 127.0.0.1,root,,test,$MASTER_MYPORT,) |
| 96 | +XA START 'xa1'; |
| 97 | +XA END 'xa1'; |
| 98 | +XA PREPARE 'xa1'; |
| 99 | +--disconnect other_conn |
| 100 | + |
| 101 | +--connection default |
| 102 | +# TC3. Manual GTID and apply `XA ROLLBACK` to an existent XA transaction |
| 103 | +# -------------------------------------------------------------------- |
| 104 | +# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 105 | +SET @@AUTOCOMMIT=0; |
| 106 | +# 2) Set `GTID_NEXT` to manually introduced value. |
| 107 | +SET SESSION GTID_NEXT='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:3'; |
| 108 | +# 3) Execute a DML statement. |
| 109 | +INSERT INTO t2 VALUES(3); |
| 110 | +# 4) Execute `XA ROLLBACK` with an existent XID. |
| 111 | +--error ER_XAER_RMFAIL |
| 112 | +XA ROLLBACK 'xa1'; |
| 113 | +# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 114 | +# commited. |
| 115 | +SET @@AUTOCOMMIT=1; |
| 116 | +# |
| 117 | + |
| 118 | +# TC4. Manual GTID and apply `XA COMMIT` to an existent XA transaction |
| 119 | +# ----------------------------------------------------------------------- |
| 120 | +# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 121 | +SET @@AUTOCOMMIT=0; |
| 122 | +# 2) Set `GTID_NEXT` to manually introduced value. |
| 123 | +SET SESSION GTID_NEXT='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:4'; |
| 124 | +# 3) Execute a DML statement. |
| 125 | +INSERT INTO t2 VALUES(4); |
| 126 | +# 4) Execute `XA COMMIT` with an existent XID. |
| 127 | +--error ER_XAER_RMFAIL |
| 128 | +XA COMMIT 'xa1'; |
| 129 | +# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 130 | +# commited. |
| 131 | +SET @@AUTOCOMMIT=1; |
| 132 | +# |
| 133 | + |
| 134 | +--let $assert_text= All inserts were committed, XA statements and respective failures, were disregarded |
| 135 | +--let $assert_cond= "[SELECT COUNT(1) FROM t2]" = "4" |
| 136 | +--source include/assert.inc |
| 137 | + |
| 138 | +SET SESSION GTID_NEXT='AUTOMATIC'; |
| 139 | + |
| 140 | +DROP TABLE t2; |
| 141 | + |
| 142 | +--replace_result $current_autocommit DEFAULT_AUTOCOMMIT |
| 143 | +--eval SET @@AUTOCOMMIT=$current_autocommit |
| 144 | + |
| 145 | +RESET MASTER; |
0 commit comments