File: set_gtid_next.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 (64 lines) | stat: -rw-r--r-- 1,894 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
58
59
60
61
62
63
64
# ==== Purpose ====
#
# This is a simplified version of set_gtid_next__gtid_mode_agnostic.inc.
#
# It will set the GTID_NEXT session variable to ANONYMOUS if GTIDs
# are OFF or to SERVER_UUID:N (where N is the larger GTID executed plus one)
# if GTIDs are enabled.
#
# It is useful to test some functionalities regardless of GTIDs being enabled
# or not, when there is a need for non-automatic GTID_NEXT.
#
# It doesn't require gtid_utils.inc as set_gtid_next__gtid_mode_agnostic.inc.
#
# ==== Usage ====
#
# [--let $non_masked_gtid= 1]
# [--let $expected_error= error_number]
# --source include/set_gtid_next.inc
#
# Parameters:
#   $non_masked_gtids
#     By default, this include will mask the output of the statement in order
#     to produce the same output with or without GTIDs enabled. By setting this
#     parameter the include will not mask the output.
#
#   $expected_error
#     When set, the include will expect an error before setting the GTID_NEXT.
#

--let $_sgn_gtid_next= ANONYMOUS

if ( `SELECT @@GLOBAL.GTID_MODE = 'ON'` )
{
  # This routine assume that GTID_EXECUTED has only GTIDs from a single server
  --let $_sgn_colon= `SELECT LOCATE(':', @@GLOBAL.GTID_EXECUTED)`
  if ($_sgn_colon)
  {
    --let $_sgn_minus= `SELECT LOCATE('-', @@GLOBAL.GTID_EXECUTED, $_sgn_colon)`
    if ($_sgn_minus)
    {
      --let $_sgn_next= `SELECT SUBSTR(@@GLOBAL.GTID_EXECUTED, LOCATE('-', @@GLOBAL.GTID_EXECUTED, $_sgn_colon) + 1) + 1`
    }
    if (!$_sgn_minus)
    {
      --let $_sgn_next= `SELECT SUBSTR(@@GLOBAL.GTID_EXECUTED, $_sgn_colon + 1) + 1`
    }
  }
  if (!$_sgn_colon)
  {
    --let $_sgn_next= 1
  }
  --let $_sgn_server_uuid= `SELECT @@GLOBAL.SERVER_UUID`
  --let $_sgn_gtid_next= $_sgn_server_uuid:$_sgn_next
}

if (!$non_masked_gtid)
{
  --replace_result $_sgn_gtid_next #
}
if ($expected_error)
{
  --error $expected_error
}
--eval SET GTID_NEXT= '$_sgn_gtid_next'