File: save_sysvars.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 (78 lines) | stat: -rw-r--r-- 2,623 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# ==== Purpose ====
#
# The purpose of this utility script is to save the values of given
# configuration variables and prepare the restore of such variables upon
# inclusion of `include/restore_sysvars.inc`.
#
# IMPORTANT NOTE: The `include/destroy_json_functions.inc` must be included
# by the test including this script (since there is no knowledge if JSON
# functions are being used prior to invoking this script, JSON functions
# can't be cleared within this script). If using replication
# infra-structure, `include/destroy_json_functions.inc` will be already
# included by `include/rpl_end.inc`.
#
# ==== Usage ====
#
# --let $sysvars_to_save = JSON_ARRAY
# --source include/save_sysvars.inc
#
# Parameters:
#
#   $sysvars_to_save
#     A JSON array with the fully qualified names of the variables to save,
#     for instance:
#
#     let $sysvars_to_save = [
#         "GLOBAL.transaction_write_set_extraction",
#         "GLOBAL.replica_preserve_commit_order",
#         "SESSION.binlog_row_image"
#     ];
#
# Output:
#
#  $sysvar_stack
#    A JSON array containing the SET statements to be executed when
#    `include/restore_sysvars.inc` in included. Each element of the array
#    is a set of SET statements corresponding to a single inclusion of
#    `save_sysvars.inc`. Each invocation to `restore_sysvars.inc` will
#    remove an element of this array.
#
#

if (!$sysvars_to_save) {
  --die ERRROR: `sysvars_to_save` parameter must be set
}

--let $include_filename = save_sysvars.inc $sysvars_to_save
--source include/begin_include_file.inc

--let $json_label = saved_sysvars
--source include/create_json_iterator.inc

--let $sysvars_values_to_save =
--let $json_array = $sysvars_to_save
--source $json_saved_sysvars_start
while (!$json_saved_sysvars_done) {
  --let $sysvar_value = `SELECT @@$json_saved_sysvars_value`
  if ($sysvars_values_to_save != '') {
    --let $sysvars_values_to_save = $sysvars_values_to_save,
  }
  if (`SELECT concat('', @@$json_saved_sysvars_value * 1) != @@$json_saved_sysvars_value`) {
    --let $sysvar_value = '$sysvar_value'
  }
  --let $sysvars_values_to_save = $sysvars_values_to_save @@$json_saved_sysvars_value = $sysvar_value
  --source $json_saved_sysvars_next
}

if ($rpl_debug) {
  --echo DEBUG: sysvars_values_to_save = <SET $sysvars_values_to_save>
}

--let $sysvars_values_to_save = escape(\',$sysvars_values_to_save)
if ($sysvar_stack == '') {
  --let $sysvar_stack = []
}
--let $sysvar_stack = escape(\',$sysvar_stack)
--let $sysvar_stack = `SELECT JSON_ARRAY_INSERT('$sysvar_stack', '$[0]', '$sysvars_values_to_save')`

--source include/end_include_file.inc