/
rdebug_set_variable.html
97 lines (85 loc) · 4.05 KB
/
rdebug_set_variable.html
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
<h3>NAME</h3>
rdebug_set_variable(): Modify value of local or user defined variable.
<h3>TYPE</h3>
Procedure
<h3>DESCRIPTION</h3>
<p>
This procedure is part of the <a href="rdebug_api.html">rdebug API</a>.
</p>
<p>
<i>rdebug_set_variable()</i> allows the <i>debugger</i> to modify values of
<i>worker's</i> visible local routine variables and user defined variables.
</p>
<p>
Variables which are eligible for modifications are those presented by
<a href="rdebug_watch_variables.html">rdebug_watch_variables()</a>. These are
the local variables in scope at the <i>worker's</i> currently executing routine,
and the user defined variables used anywhere by that routine.
</p>
<p>
Calling <i>rdebug_set_variable()</i> should take place while the <i>worker</i>
is being suspended on a <a href="rdebug_set_breakpoint.html">breakpoint</a> or
by a step (<a href="rdebug_step_into.html">into</a>/<a
href="rdebug_step_out.html">out</a>/<a
href="rdebug_step_over.html">over</a>).
During that time it is possible to call this routine multiple times for same
variables or for different variables.
Changes take effect immediately as the <i>worker</i> resumes execution.
</p>
<p>
The new value is passed as <strong>BLOB</strong> and is later translated to the
appropriate data type via MySQL's internal assignment mechanism.
</p>
<p>
Execution of this routine only makes sense on an active debugging session, i.e.
after calling <a href="rdebug_start.html">rdebug_start()</a>.
</p>
<h3>SYNOPSIS</h3>
<p>
<blockquote><pre>rdebug_set_variable(
in rdebug_variable_name varchar(128),
in rdebug_variable_value blob
)
MODIFIES SQL DATA</pre></blockquote>
</p>
<p>
Input:
<ul>
<li><strong>rdebug_variable_name</strong>: name of local variable or user defined variable
to change. User defined variables are preceded by <strong>"@"</strong>.
</li>
<li><strong>rdebug_variable_value</strong>: new value for variable.</li>
</ul>
</p>
<h3>EXAMPLES</h3>
<p>
Watch current variables, modify a variable, and watch the change:
<blockquote><pre>mysql> call rdebug_watch_variables();
+----------------+--------------------------+-------------------+---------------+----------------+
| routine_schema | routine_name | variable_name | variable_type | variable_value |
+----------------+--------------------------+-------------------+---------------+----------------+
| test | analyze_continent_cities | @avg_count_cities | user_defined | 18.282608695 |
| test | analyze_continent_cities | @count_countries | user_defined | 46 |
| test | analyze_continent_cities | current_continent | param | Europe |
+----------------+--------------------------+-------------------+---------------+----------------+
mysql> rdebug_set_variable('current_continent', 'Atlantis');
mysql> rdebug_watch_variables();
+----------------+--------------------------+-------------------+---------------+----------------+
| routine_schema | routine_name | variable_name | variable_type | variable_value |
+----------------+--------------------------+-------------------+---------------+----------------+
| test | analyze_continent_cities | @avg_count_cities | user_defined | 18.282608695 |
| test | analyze_continent_cities | @count_countries | user_defined | 46 |
| test | analyze_continent_cities | current_continent | param | Atlantis |
+----------------+--------------------------+-------------------+---------------+----------------+
</pre></blockquote>
The above only shows the <i>debugger's</i> view of the variables. At this point, the <i>worker</i>
is still unaware of the changes since it is still suspended. Once the <i>worker</i> resumes
execution, it updates the value of <strong>current_continent</strong> to <strong>'Atlantis'</strong>.
</p>
<h3>ENVIRONMENT</h3>
MySQL 5.1 or newer
<h3>SEE ALSO</h3>
<a href="rdebug_get_variable.html">rdebug_get_variable()</a>,
<a href="rdebug_watch_variables.html">rdebug_watch_variables()</a>
<h3>AUTHOR</h3>
Shlomi Noach