rdebug_set_variable

NAME

rdebug_set_variable(): Modify value of local or user defined variable.

TYPE

Procedure

DESCRIPTION

This procedure is part of the rdebug API.

rdebug_set_variable() allows the debugger to modify values of worker's visible local routine variables and user defined variables.

Variables which are eligible for modifications are those presented by rdebug_watch_variables(). These are the local variables in scope at the worker's currently executing routine, and the user defined variables used anywhere by that routine.

Calling rdebug_set_variable() should take place while the worker is being suspended on a breakpoint or by a step (into/out/over). 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 worker resumes execution.

The new value is passed as BLOB and is later translated to the appropriate data type via MySQL's internal assignment mechanism.

Execution of this routine only makes sense on an active debugging session, i.e. after calling rdebug_start().

SYNOPSIS

rdebug_set_variable(
    in rdebug_variable_name varchar(128),
    in rdebug_variable_value blob
  )
  MODIFIES SQL DATA

Input:

  • rdebug_variable_name: name of local variable or user defined variable to change. User defined variables are preceded by "@".
  • rdebug_variable_value: new value for variable.

EXAMPLES

Watch current variables, modify a variable, and watch the change:

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       |
+----------------+--------------------------+-------------------+---------------+----------------+
The above only shows the debugger's view of the variables. At this point, the worker is still unaware of the changes since it is still suspended. Once the worker resumes execution, it updates the value of current_continent to 'Atlantis'.

ENVIRONMENT

MySQL 5.1 or newer

SEE ALSO

rdebug_get_variable(), rdebug_watch_variables()

AUTHOR

Shlomi Noach
 
common_schema documentation