rdebug_get_variable

NAME

rdebug_get_variable(): Get value of local or user defined variable.

TYPE

Function

DESCRIPTION

This function is part of the rdebug API.

rdebug_get_variable() returns the value of a single parameter or local or user defined variable currently visible by the worker.

Variables which are visible 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_get_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.

This function is provided as convenience: it is sometimes desired to call upon a function than to invoke a routine and read its result set. It works similarly to rdebug_watch_variables(). However, it does not return any metadata for the variable.

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

SYNOPSIS

rdebug_get_variable(
    rdebug_variable_name varchar(128)
  ) returns blob
  READS SQL DATA

Input:

  • rdebug_variable_name: name of local variable or user defined variable. User defined variables are preceded by "@".

EXAMPLES

Compare usage of rdebug_watch_variables() and rdebug_get_variable():

mysql> call rdebug_watch_variables();
+----------------+--------------------------+-------------------+---------------+----------------+
| routine_schema | routine_name             | variable_name     | variable_type | variable_value |
+----------------+--------------------------+-------------------+---------------+----------------+
| test           | analyze_continent_cities | @avg_count_cities | user_defined  | 34.627450980   |
| test           | analyze_continent_cities | @count_countries  | user_defined  | 51             |
| test           | analyze_continent_cities | current_continent | param         | Asia           |
+----------------+--------------------------+-------------------+---------------+----------------+

mysql> select rdebug_get_variable('current_continent') as result_cont;
+-------------+
| result_cont |
+-------------+
| Asia        |
+-------------+

mysql> select rdebug_get_variable('@avg_count_cities') as result_avg;
+--------------+
| result_avg   |
+--------------+
| 34.627450980 |
+--------------+

ENVIRONMENT

MySQL 5.1 or newer

SEE ALSO

rdebug_set_variable(), rdebug_watch_variables()

AUTHOR

Shlomi Noach
 
common_schema documentation