Add extensive Doxygen documentation for ProxySQL_Config and Read_Global_Variables_from_configfile

This commit adds detailed Doxygen documentation for:
1. The ProxySQL_Config class - describes its role in configuration management
2. The Read_Global_Variables_from_configfile() method - documents its behavior,
   parameters, return value, and the automatic prefix stripping feature

The documentation explains the automatic prefix stripping behavior that handles
cases where users mistakenly include module prefix (e.g., "mysql-") in variable
names within configuration files.
pull/5247/head
Rene Cannao 5 months ago
parent 7ebdf561ca
commit 6c97d3d244

@ -15,12 +15,25 @@ enum proxysql_config_type {
PROXYSQL_CONFIG_PROXY_SERVERS,
};
/**
* @brief Configuration management class for ProxySQL.
*
* Handles reading and writing configuration from/to SQLite database and config files.
* This class provides methods to load configuration sections (variables, users, servers,
* query rules, scheduler, restapi) from config files into the database and vice versa.
*
* The class supports automatic prefix stripping for configuration variables to handle
* cases where users mistakenly include the module prefix (e.g., "mysql-") in variable names.
*/
class ProxySQL_Config {
public:
SQLite3DB* admindb;
/** @brief Constructs ProxySQL_Config with a database handle */
ProxySQL_Config(SQLite3DB* db);
/** @brief Virtual destructor */
virtual ~ProxySQL_Config();
/** @copydoc ProxySQL_Config::Read_Global_Variables_from_configfile */
int Read_Global_Variables_from_configfile(const char *prefix);
int Read_MySQL_Users_from_configfile(std::string& error);
int Read_MySQL_Query_Rules_from_configfile();

@ -60,6 +60,33 @@ void ProxySQL_Config::addField(std::string& data, const char* name, const char*
data += ss.str();
}
/**
* @brief Reads global variables from configuration file for a given module prefix.
*
* This function parses the configuration file section named `<prefix>_variables`
* (e.g., "mysql_variables", "pgsql_variables", "admin_variables") and inserts
* the variables into the global_variables table in the format "prefix-variable_name".
*
* The function automatically strips duplicate module prefixes from variable names.
* For example, if a user writes "mysql-log_unhealthy_connections" in the mysql_variables
* section, the prefix "mysql-" is automatically removed, and the variable is stored
* as "mysql-log_unhealthy_connections" (with a single prefix).
*
* @param prefix The module prefix: "mysql", "pgsql", or "admin".
* @return Number of variables processed (successfully read and stored).
* @retval 0 if the prefix_variables section does not exist in the config file.
*
* @note The function temporarily disables foreign keys for performance.
* @note Variable values are converted to strings: booleans become "true"/"false",
* integers are converted via std::to_string, and strings are used as-is.
*
* @par Example:
* For prefix="mysql", the function reads the "mysql_variables" section from config.
* If the config contains "mysql-log_unhealthy_connections=false", it's stored as
* "mysql-log_unhealthy_connections" with value "false".
*
* @see ProxySQL_Config::Write_Global_Variables_to_configfile()
*/
int ProxySQL_Config::Read_Global_Variables_from_configfile(const char *prefix) {
const Setting& root = GloVars.confFile->cfg.getRoot();
char *groupname=(char *)malloc(strlen(prefix)+strlen((char *)"_variables")+1);

Loading…
Cancel
Save