File: add_debug_point.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 (131 lines) | stat: -rw-r--r-- 3,648 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# ==== Purpose ====
#
# This include will add a debug point to the current GLOBAL or SESSION
# debug variable without changing other debugging flags set.
#
# This is useful when generating debug trace for test cases that uses
# debug point features. By using this include the trace generation will
# not be stopped.
#
# ==== Usage ====
#
# --let $debug_point= debug_point
# [--let $debug_point_silent= 1]
# [--let $debug_type= GLOBAL | SESSION]
# --source include/add_debug_point.inc
#
# Parameters:
#   $debug_point
#     The debug point to be activated.
#
#   $debug_point_silent
#     By default, this script prints the name of the debug point. If
#     this parameter is set, it does not print anything.
#
#   $debug_type
#     If the debug variable to be changed is the GLOBAL or SESSION one.
#     The default (if not specified one) is GLOBAL.
#

--let $_previous_include_silent= $include_silent
--let $include_silent= 1
--let $include_filename= add_debug_point.inc
--source include/begin_include_file.inc
--let $include_silent= $_previous_include_silent

if (!$debug_type)
{
  --let $_debug_type= GLOBAL
}
if ($debug_type)
{
  --let $_debug_type= $debug_type
}
if ( `SELECT UPPER('$_debug_type') <> 'GLOBAL' AND UPPER('$_debug_type') <> 'SESSION'` )
{
  --die ERROR IN TEST: invalid value for mysqltest variable 'debug_type': $debug_type
}
if (!$debug_point)
{
  --die ERROR IN TEST: the mysqltest variable 'debug_point' must be set
}

--let $_debug_point= $debug_point
if (!$rpl_debug)
{
  --disable_query_log
}

--eval SET @previous_debug = @@$_debug_type.debug;
SET @before_debug_point='';
SET @after_debug_point='';

# check if debug is empty
if ( `SELECT @previous_debug = ''` )
{
  SET @before_debug_point='d,';
}

# check if debug is 'd'
if ( `SELECT @previous_debug = 'd'` )
{
  SET @before_debug_point='d,';
}

# check if debug starts with 'd:'
if ( `SELECT INSTR(@previous_debug,'d:') = 1` )
{
  SET @before_debug_point='d,';
  SET @after_debug_point=RIGHT(@previous_debug, LENGTH(@previous_debug) - 1);
}

# check if debug starts with 'd,' and has no ':'
if ( `SELECT INSTR(@previous_debug,'d,') = 1 AND INSTR(@previous_debug,':') = 0` )
{
  SET @before_debug_point=CONCAT(@previous_debug, ',');
}

# check if debug starts with 'd,' and has ':'
if ( `SELECT INSTR(@previous_debug,'d,') = 1 AND INSTR(@previous_debug,':') > 0` )
{
  SET @before_debug_point=LEFT(@previous_debug, INSTR(@previous_debug,':') - 1);
  SET @after_debug_point=RIGHT(@previous_debug, LENGTH(@previous_debug) - INSTR(@previous_debug,':') + 1);
  --let $_debug_point= ,$_debug_point
}

if (!$debug_point_silent)
{
  --let $message_prefix=`SELECT REPEAT("#", $_include_file_depth)`
  --echo $message_prefix Adding debug point '$debug_point' to @@$_debug_type.debug
}

if ($rpl_debug)
{
  --let $_to_display=`SELECT @@$_debug_type.debug`
  --echo @@$_debug_type.debug was '$_to_display'
}

# If the current debug setting is already too big it might compromise the above checks
# as the shown debug info will be cut and end with '...'
# In this case we simply revert to the +d strategy
if(`SELECT LENGTH(@@$_debug_type.debug) >= 512`)
{
  SET @before_debug_point="+d,";
  --let $_debug_point= $debug_point
  SET @after_debug_point='';
  if ($rpl_debug)
  {
    --echo Warning: the current value for @@$_debug_type.debug is too big to be displayed.
  }
}

--eval SET @@$_debug_type.debug=CONCAT(@before_debug_point, '$_debug_point', @after_debug_point)

if ($rpl_debug)
{
  --let $_to_display=`SELECT @@$_debug_type.debug`
  --echo @@$_debug_type.debug set to '$_to_display'
}

--let $include_filename= add_debug_point.inc
--source include/end_include_file.inc