Today, while helping someone find some of the code that implements SHOW VARIABLES I was reminded at how insanely complex it all got with the information_schema implementation and the changes to the SHOW commands that came with it. Specifically, I was trying to find exactly how the SHOW VARIABLES output gets populated — what the source data is.
By way of example, I present the code to implement it in 5.1.51 (the new way), and in 4.1.21 (the old way). I, at least, have a much easier time sorting out the old way. They both start with the same basic entry point, in the parser, in show: within sql/sql_yacc.yy.
SHOW VARIABLES in MySQL 5.1.51 sql/sql_yacc.yy
The show token just does some initialization.
10062 show: 10063 SHOW 10064 { 10065 LEX *lex=Lex; 10066 lex->wild=0; 10067 lex->lock_option= TL_READ; 10068 mysql_init_select(lex); 10069 …[Read more]