In this plugin we will show how to access MySQL's internal data structures—the list of user variables created in a connection. User variables are used to store data that will persist just for one connection inside the MySQL server. Unfortunately, one of their limitations is that there is no way to see what variables have been created. In this example we will develop an Information Schema table that shows them.
User variables are stored in the
user_vars member of the
THD structure. It is a hash that maps variable names to corresponding
user_var_entry objects. We simply need to traverse the hash, and for every
user_var_entry element print its name and its value converted to a string.
To be able to see the ...