File: assert_xa_recover.inc

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (57 lines) | stat: -rw-r--r-- 1,798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# ==== Purpose ====
#
# Used by scripts testing XA crash recovery, it checks the line count
# returnes by `XA RECOVER` against the given count parameter and, if
# different from zero, tries to find the given XID in the list.
#
# ==== Parameters ====
#
# $expected_prepared_xa_count
#   The expected line count return by `XA RECOVER`
#
# $xid_data
#   The XID raw data, to find in the `XA RECOVER` returned list. If
#   `$expected_prepared_xa_count` is non-zero, will try to assert that the
#   provided XID exists in the `XA RECOVER` outputted list. Support for
#   more than one XID to test isn't provided.
#
# ==== References ====
#
# Related tests:
#   see extra/xa_crash_safe_tests/setup.inc
#

--let $statement = XA RECOVER
--let $column = data
--source include/get_row_count.inc

if ($expected_prepared_xa_count == 0) {
  --let $assert_text = No XA transactions in PREPARED state
}
if ($expected_prepared_xa_count != 0) {
  --let $assert_text = $expected_prepared_xa_count XA transaction(s) in PREPARED state
}
# Test `XA RECOVER` returned line count
--let $assert_cond = "$row_count" = "$expected_prepared_xa_count"
--source include/assert.inc

if ($expected_prepared_xa_count != 0) {
  if ($xid_data != '') {
    # For each line returned from `XA RECOVER`, try to find the given XID
    --let $row_number = $row_count
    while($row_number != 0) {
      --let $pending_xa = query_get_value(XA RECOVER, data, $row_number)
      if ($pending_xa != $xid_data) {
        --let $pending_xa =
        --dec $row_number
      }
      if ($pending_xa == $xid_data) {
        # If found, exit loop
        --let $row_number = 0
      }
    }
    --let $assert_text = XA transaction $xid is in PREPARED state
    --let $assert_cond = "$pending_xa" = "$xid_data"
    --source include/assert.inc
  }
}