| 1 |
# ==== Initialize ==== |
| 2 |
CREATE TABLE t1 (a INT); |
| 3 |
CREATE TABLE t2 (a INT); |
| 4 |
PREPARE stmt1 FROM 'INSERT INTO t1 VALUES (1)'; |
| 5 |
CREATE PROCEDURE p1 () |
| 6 |
BEGIN |
| 7 |
INSERT INTO t2 VALUES(2); |
| 8 |
END |
| 9 |
$ |
| 10 |
CREATE PROCEDURE p2 () |
| 11 |
BEGIN |
| 12 |
EXECUTE stmt1; |
| 13 |
END |
| 14 |
$ |
| 15 |
# ==== Case 1 ==== |
| 16 |
# Test case to verify gtid_next update with prepared statement re-prepare. |
| 17 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'; |
| 18 |
BEGIN; |
| 19 |
EXECUTE stmt1; |
| 20 |
COMMIT; |
| 21 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2'; |
| 22 |
TRUNCATE TABLE t1; |
| 23 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:3'; |
| 24 |
# Without fix, following statement execution fails. |
| 25 |
EXECUTE stmt1; |
| 26 |
# ==== Case 2 ==== |
| 27 |
# Test case to verify gtid_next update with stored procedure statement |
| 28 |
# re-prepare. |
| 29 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:4'; |
| 30 |
CALL p1(); |
| 31 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:5'; |
| 32 |
TRUNCATE TABLE t2; |
| 33 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:6'; |
| 34 |
# Without fix, following statement execution fails. |
| 35 |
CALL p1(); |
| 36 |
# ==== Case 3 ==== |
| 37 |
# Test case to verify gtid_next update with prepared statement re-prepare |
| 38 |
# in stored procedure. |
| 39 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:7'; |
| 40 |
CALL p2(); |
| 41 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:8'; |
| 42 |
TRUNCATE TABLE t1; |
| 43 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:9'; |
| 44 |
# Without fix, following statement execution fails. |
| 45 |
CALL p2(); |
| 46 |
# === Case 4 === |
| 47 |
# Test case to verify gtid_next update with prepared statement max |
| 48 |
# re-prepare attempt hits. |
| 49 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:10'; |
| 50 |
TRUNCATE TABLE t1; |
| 51 |
# Adding debug point 'simulate_max_reprepare_attempts_hit_case' to @@SESSION.debug |
| 52 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:11'; |
| 53 |
# Error is reported when max re-prepare limit is hit. Transaction is |
| 54 |
# rolled back and gtid_next is updated. |
| 55 |
EXECUTE stmt1; |
| 56 |
ERROR HY000: Prepared statement needs to be re-prepared |
| 57 |
INSERT INTO t1 VALUES(10); |
| 58 |
ERROR HY000: When @@SESSION.GTID_NEXT is set to a GTID, you must explicitly set it to a different value after a COMMIT or ROLLBACK. Please check GTID_NEXT variable manual page for detailed explanation. Current @@SESSION.GTID_NEXT is 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:11'. |
| 59 |
# === Case 5 === |
| 60 |
# Test case to verify gtid_next update with stored procedure statement |
| 61 |
# max re-prepare attempt hits. |
| 62 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:12'; |
| 63 |
TRUNCATE TABLE t2; |
| 64 |
SET gtid_next = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:13'; |
| 65 |
# Error is reported when max re-prepare limit is hit. Transaction is |
| 66 |
# rolled back and gtid_next is updated. |
| 67 |
CALL p1; |
| 68 |
ERROR HY000: Prepared statement needs to be re-prepared |
| 69 |
INSERT INTO t2 VALUES(10); |
| 70 |
ERROR HY000: When @@SESSION.GTID_NEXT is set to a GTID, you must explicitly set it to a different value after a COMMIT or ROLLBACK. Please check GTID_NEXT variable manual page for detailed explanation. Current @@SESSION.GTID_NEXT is 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:13'. |
| 71 |
# ==== Cleanup ==== |
| 72 |
SET gtid_next = DEFAULT; |
| 73 |
# Removing debug point 'simulate_max_reprepare_attempts_hit_case' from @@SESSION.debug |
| 74 |
DEALLOCATE PREPARE stmt1; |
| 75 |
DROP TABLE t1, t2; |
| 76 |
DROP PROCEDURE p1; |
| 77 |
DROP PROCEDURE p2; |