| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Used by scripts testing XA crash recovery, it checks the line count |
| 4 |
# returnes by `XA RECOVER` against the given count parameter and, if |
| 5 |
# different from zero, tries to find the given XID in the list. |
| 6 |
# |
| 7 |
# ==== Parameters ==== |
| 8 |
# |
| 9 |
# $expected_prepared_xa_count |
| 10 |
# The expected line count return by `XA RECOVER` |
| 11 |
# |
| 12 |
# $xid_data |
| 13 |
# The XID raw data, to find in the `XA RECOVER` returned list. If |
| 14 |
# `$expected_prepared_xa_count` is non-zero, will try to assert that the |
| 15 |
# provided XID exists in the `XA RECOVER` outputted list. Support for |
| 16 |
# more than one XID to test isn't provided. |
| 17 |
# |
| 18 |
# ==== References ==== |
| 19 |
# |
| 20 |
# Related tests: |
| 21 |
# see extra/xa_crash_safe_tests/setup.inc |
| 22 |
# |
| 23 |
|
| 24 |
--let $statement = XA RECOVER |
| 25 |
--let $column = data |
| 26 |
--source include/get_row_count.inc |
| 27 |
|
| 28 |
if ($expected_prepared_xa_count == 0) { |
| 29 |
--let $assert_text = No XA transactions in PREPARED state |
| 30 |
} |
| 31 |
if ($expected_prepared_xa_count != 0) { |
| 32 |
--let $assert_text = $expected_prepared_xa_count XA transaction(s) in PREPARED state |
| 33 |
} |
| 34 |
# Test `XA RECOVER` returned line count |
| 35 |
--let $assert_cond = "$row_count" = "$expected_prepared_xa_count" |
| 36 |
--source include/assert.inc |
| 37 |
|
| 38 |
if ($expected_prepared_xa_count != 0) { |
| 39 |
if ($xid_data != '') { |
| 40 |
# For each line returned from `XA RECOVER`, try to find the given XID |
| 41 |
--let $row_number = $row_count |
| 42 |
while($row_number != 0) { |
| 43 |
--let $pending_xa = query_get_value(XA RECOVER, data, $row_number) |
| 44 |
if ($pending_xa != $xid_data) { |
| 45 |
--let $pending_xa = |
| 46 |
--dec $row_number |
| 47 |
} |
| 48 |
if ($pending_xa == $xid_data) { |
| 49 |
# If found, exit loop |
| 50 |
--let $row_number = 0 |
| 51 |
} |
| 52 |
} |
| 53 |
--let $assert_text = XA transaction $xid is in PREPARED state |
| 54 |
--let $assert_cond = "$pending_xa" = "$xid_data" |
| 55 |
--source include/assert.inc |
| 56 |
} |
| 57 |
} |