O'Reilly logo

Understanding MySQL Internals by Sasha Pachev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Global Variables

MySQL code uses a large number of global variables for various purposes: configuration settings, server status information, various data structures shared among threads, and other things. Studying the global variables provides numerous insights on the server architecture. Often the very existence of the variable concisely tells a story about how and why different components work together.

Table 3-7 summarizes the most commonly used global variables. Many of those were moved under the system_status_var structure in version 5.0.

Table 3-7. Commonly used global variables

Variable definition

Defined in

Description

char *mysql_data_home

sql/mysqld.cc

Points to the path of the data directory, which is set by the datadir configuration parameter.

char server_version SERVER_VERSION_LENGTH]

sql/mysqld.cc

Contains the server version string displayed in the connection greeting and in the log; for example, mysql-4.1.5-log.

char mysql_charsets_dir [FN_REFLEN]

sql/mysqld.cc

Contains the path to the configuration directory holding the character set definition files. The value is set by the character-sets-dir configuration parameter.

ulong refresh_version

sql/mysqld.cc

The value gets incremented every time the database administrator issues the FLUSH TABLES command. When a request is made to use an already open table, the value of table→refresh_version is checked against the global refresh_version to determine whether the table needs to be reloaded.

ulong thread_id

sql/mysqld.cc ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required