#define MONITOR_SQLITE_TABLE_PGSQL_SERVER_CONNECT_LOG "CREATE TABLE pgsql_server_connect_log (hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 3306 , time_start_us INT NOT NULL DEFAULT 0 , connect_success_time_us INT DEFAULT 0 , connect_error VARCHAR , PRIMARY KEY (hostname, port, time_start_us))"
#define MONITOR_SQLITE_TABLE_PGSQL_SERVER_PING_LOG "CREATE TABLE pgsql_server_ping_log ( hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 3306 , time_start_us INT NOT NULL DEFAULT 0 , ping_success_time_us INT DEFAULT 0 , ping_error VARCHAR , PRIMARY KEY (hostname, port, time_start_us))"
#define MONITOR_SQLITE_TABLE_PGSQL_SERVERS "CREATE TABLE pgsql_servers (hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 3306 , status INT CHECK (status IN (0, 1, 2, 3, 4)) NOT NULL DEFAULT 0 , use_ssl INT CHECK (use_ssl IN(0,1)) NOT NULL DEFAULT 0 , PRIMARY KEY (hostname, port) )"
#define MONITOR_SQLITE_TABLE_PROXYSQL_SERVERS "CREATE TABLE proxysql_servers (hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 6032 , weight INT CHECK (weight >= 0) NOT NULL DEFAULT 0 , comment VARCHAR NOT NULL DEFAULT '' , PRIMARY KEY (hostname, port) )"
structPgSQL_Monitor{
// @brief Flags if monitoring threads should be shutdown.
boolshutdown=false;
// @brief Mutex to hold to update `monitor_internal.pgsql_servers`
std::mutexpgsql_srvs_mutex{};
// @brief Mutex to hold to update/read `pgsql_servers` to monitor
std::mutexpgsql_srvs_to_monitor_mutex{};
// @brief Used to access monitor database
SQLite3DBmonitordb{};
// @brief Used to access internal monitor database
stringvp0="(?:\\w|\\d)+";// single word with letters and digits , for example utf8mb4 and latin1
//var_patterns.push_back(vp);
/*
stringvp1="(?:"+vp0+"(?:,"+vp0+")*)";// multiple words (letters and digits) separated by commas WITHOUT any spaces between words . Used also for sql_mode , example: ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO
//var_patterns.push_back(vp1); // do NOT add without quote
stringvp2="(?:"+vp0+"(?:-"+vp0+")*)";// multiple words (letters and digits) separated by dash, WITHOUT any spaces between words . Used also for transaction isolation
//vp = "(?:\\w|\\d)+(?:-|\\w|\\d+)*"; // multiple words (letters and digits) separated by dash, WITHOUT any spaces between words . Used ialso for transaction isolation
//var_patterns.push_back(vp);
// for (auto it = quote_symbol.begin(); it != quote_symbol.end(); it++) {
// string s = *it + vp + *it;
// var_patterns.push_back(s); // add with quote
// }
vp="\\w+(?:,\\w+)+";// multiple words separated by commas, WITHOUT any spaces between words
// NOTE: we do not use multiple words without quotes