Merge branch 'v2.0.9' of https://github.com/sysown/proxysql into v2.0.9

pull/2392/head
René Cannaò 7 years ago
commit b2f3ffce5e

@ -247,7 +247,7 @@ class MySQL_Monitor {
unsigned long long read_only_check_ERR;
unsigned long long replication_lag_check_OK;
unsigned long long replication_lag_check_ERR;
wqueue<WorkItem*> * queue = NULL;
std::unique_ptr<wqueue<WorkItem*>> queue;
MySQL_Monitor_Connection_Pool *My_Conn_Pool;
bool shutdown;
pthread_mutex_t mon_en_mutex;

@ -63,7 +63,7 @@
#define STATSDB_SQLITE_TABLE_MYSQL_QUERY_CACHE_DAY "CREATE TABLE mysql_query_cache_day (timestamp INT NOT NULL, count_GET INT NOT NULL, count_GET_OK INT NOT NULL, count_SET INT NOT NULL, bytes_IN INT NOT NULL, bytes_OUT INT NOT NULL, Entries_Purged INT NOT NULL, Entries_In_Cache INT NOT NULL, Memory_Bytes INT NOT NULL, PRIMARY KEY (timestamp))"
#define STATSDB_SQLITE_TABLE_HISTORY_MYSQL_QUERY_DIGEST "CREATE TABLE history_mysql_query_digest (hostgroup INT , schemaname VARCHAR NOT NULL , username VARCHAR NOT NULL , client_address VARCHAR NOT NULL , digest VARCHAR NOT NULL , digest_text VARCHAR NOT NULL , count_star INTEGER NOT NULL , first_seen INTEGER NOT NULL , last_seen INTEGER NOT NULL , sum_time INTEGER NOT NULL , min_time INTEGER NOT NULL , max_time INTEGER NOT NULL , sum_rows_affected INTEGER NOT NULL , sum_rows_sent INTEGER NOT NULL)"
#define STATSDB_SQLITE_TABLE_HISTORY_MYSQL_QUERY_DIGEST "CREATE TABLE history_mysql_query_digest (dump_time INT , hostgroup INT , schemaname VARCHAR NOT NULL , username VARCHAR NOT NULL , client_address VARCHAR NOT NULL , digest VARCHAR NOT NULL , digest_text VARCHAR NOT NULL , count_star INTEGER NOT NULL , first_seen INTEGER NOT NULL , last_seen INTEGER NOT NULL , sum_time INTEGER NOT NULL , min_time INTEGER NOT NULL , max_time INTEGER NOT NULL , sum_rows_affected INTEGER NOT NULL , sum_rows_sent INTEGER NOT NULL)"
class ProxySQL_Statistics {
SQLite3DB *statsdb_mem; // internal statistics DB

@ -9,18 +9,16 @@ using namespace libconfig;
class ProxySQL_ConfigFile {
private:
//struct stat statbuf;
char *filename;
std::string filename;
public:
Config *cfg;
ProxySQL_ConfigFile();
Config cfg;
bool OpenFile(const char *);
void CloseFile();
bool ReadGlobals();
bool configVariable(const char *, const char *, int &, int, int, int, int);
bool configVariable(const char *, const char *, int64_t &, int64_t, int64_t, int64_t, int64_t);
bool configVariable(const char *, const char *, bool &, bool);
bool configVariable(const char *, const char *, char **, const char *);
~ProxySQL_ConfigFile();
void CloseFile();
bool ReadGlobals();
bool configVariable(const char *, const char *, int &, int, int, int, int);
bool configVariable(const char *, const char *, int64_t &, int64_t, int64_t, int64_t, int64_t);
bool configVariable(const char *, const char *, bool &, bool);
bool configVariable(const char *, const char *, char **, const char *);
};

@ -2805,7 +2805,8 @@ void MySQL_HostGroups_Manager::destroy_MyConn_from_pool(MySQL_Connection *c, boo
switch (myerr) {
case 1231:
break;
default: {
default:
if (c->mysql->thread_id) {
MySQL_Connection_userinfo *ui=c->userinfo;
char *auth_password=NULL;
if (ui->password) {
@ -2825,7 +2826,7 @@ void MySQL_HostGroups_Manager::destroy_MyConn_from_pool(MySQL_Connection *c, boo
proxy_error("Thread creation\n");
assert(0);
}
}
}
break;
}
}

@ -161,13 +161,13 @@ private:
PtrArray *conns;
#endif // DEBUG
// std::map<std::pair<std::string, int>, std::vector<MYSQL*> > my_connections;
PtrArray *servers;
std::unique_ptr<PtrArray> servers;
public:
MYSQL * get_connection(char *hostname, int port, MySQL_Monitor_State_Data *mmsd);
void put_connection(char *hostname, int port, MYSQL *my);
void purge_some_connections();
MySQL_Monitor_Connection_Pool() {
servers = new PtrArray();
servers = std::unique_ptr<PtrArray>(new PtrArray());
#ifdef DEBUG
conns = new PtrArray();
pthread_mutex_init(&m2, NULL);
@ -522,7 +522,7 @@ MySQL_Monitor::MySQL_Monitor() {
My_Conn_Pool=new MySQL_Monitor_Connection_Pool();
queue = new wqueue<WorkItem*>();
queue = std::unique_ptr<wqueue<WorkItem*>>(new wqueue<WorkItem*>());
pthread_mutex_init(&group_replication_mutex,NULL);
Group_Replication_Hosts_resultset=NULL;

@ -164,8 +164,9 @@ void * kill_query_thread(void *arg) {
}
// FIXME: these 2 calls are blocking, fortunately on their own thread
mysql_query(mysql,buf);
mysql_close(mysql);
__exit_kill_query_thread:
if (mysql)
mysql_close(mysql);
delete ka;
return NULL;
}

@ -485,8 +485,8 @@ int ProxySQL_Admin::FlushDigestTableToDisk(SQLite3DB *_db) {
sqlite3_stmt *statement32=NULL;
char *query1=NULL;
char *query32=NULL;
query1=(char *)"INSERT INTO history_mysql_query_digest VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14)";
query32=(char *)"INSERT INTO history_mysql_query_digest VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14), (?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28), (?29, ?30, ?31, ?32, ?33, ?34, ?35, ?36, ?37, ?38, ?39, ?40, ?41, ?42), (?43, ?44, ?45, ?46, ?47, ?48, ?49, ?50, ?51, ?52, ?53, ?54, ?55, ?56), (?57, ?58, ?59, ?60, ?61, ?62, ?63, ?64, ?65, ?66, ?67, ?68, ?69, ?70), (?71, ?72, ?73, ?74, ?75, ?76, ?77, ?78, ?79, ?80, ?81, ?82, ?83, ?84), (?85, ?86, ?87, ?88, ?89, ?90, ?91, ?92, ?93, ?94, ?95, ?96, ?97, ?98), (?99, ?100, ?101, ?102, ?103, ?104, ?105, ?106, ?107, ?108, ?109, ?110, ?111, ?112), (?113, ?114, ?115, ?116, ?117, ?118, ?119, ?120, ?121, ?122, ?123, ?124, ?125, ?126), (?127, ?128, ?129, ?130, ?131, ?132, ?133, ?134, ?135, ?136, ?137, ?138, ?139, ?140), (?141, ?142, ?143, ?144, ?145, ?146, ?147, ?148, ?149, ?150, ?151, ?152, ?153, ?154), (?155, ?156, ?157, ?158, ?159, ?160, ?161, ?162, ?163, ?164, ?165, ?166, ?167, ?168), (?169, ?170, ?171, ?172, ?173, ?174, ?175, ?176, ?177, ?178, ?179, ?180, ?181, ?182), (?183, ?184, ?185, ?186, ?187, ?188, ?189, ?190, ?191, ?192, ?193, ?194, ?195, ?196), (?197, ?198, ?199, ?200, ?201, ?202, ?203, ?204, ?205, ?206, ?207, ?208, ?209, ?210), (?211, ?212, ?213, ?214, ?215, ?216, ?217, ?218, ?219, ?220, ?221, ?222, ?223, ?224), (?225, ?226, ?227, ?228, ?229, ?230, ?231, ?232, ?233, ?234, ?235, ?236, ?237, ?238), (?239, ?240, ?241, ?242, ?243, ?244, ?245, ?246, ?247, ?248, ?249, ?250, ?251, ?252), (?253, ?254, ?255, ?256, ?257, ?258, ?259, ?260, ?261, ?262, ?263, ?264, ?265, ?266), (?267, ?268, ?269, ?270, ?271, ?272, ?273, ?274, ?275, ?276, ?277, ?278, ?279, ?280), (?281, ?282, ?283, ?284, ?285, ?286, ?287, ?288, ?289, ?290, ?291, ?292, ?293, ?294), (?295, ?296, ?297, ?298, ?299, ?300, ?301, ?302, ?303, ?304, ?305, ?306, ?307, ?308), (?309, ?310, ?311, ?312, ?313, ?314, ?315, ?316, ?317, ?318, ?319, ?320, ?321, ?322), (?323, ?324, ?325, ?326, ?327, ?328, ?329, ?330, ?331, ?332, ?333, ?334, ?335, ?336), (?337, ?338, ?339, ?340, ?341, ?342, ?343, ?344, ?345, ?346, ?347, ?348, ?349, ?350), (?351, ?352, ?353, ?354, ?355, ?356, ?357, ?358, ?359, ?360, ?361, ?362, ?363, ?364), (?365, ?366, ?367, ?368, ?369, ?370, ?371, ?372, ?373, ?374, ?375, ?376, ?377, ?378), (?379, ?380, ?381, ?382, ?383, ?384, ?385, ?386, ?387, ?388, ?389, ?390, ?391, ?392), (?393, ?394, ?395, ?396, ?397, ?398, ?399, ?400, ?401, ?402, ?403, ?404, ?405, ?406), (?407, ?408, ?409, ?410, ?411, ?412, ?413, ?414, ?415, ?416, ?417, ?418, ?419, ?420), (?421, ?422, ?423, ?424, ?425, ?426, ?427, ?428, ?429, ?430, ?431, ?432, ?433, ?434), (?435, ?436, ?437, ?438, ?439, ?440, ?441, ?442, ?443, ?444, ?445, ?446, ?447, ?448)";
query1=(char *)"INSERT INTO history_mysql_query_digest VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15)";
query32=(char *)"INSERT INTO history_mysql_query_digest VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15), (?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30), (?31, ?32, ?33, ?34, ?35, ?36, ?37, ?38, ?39, ?40, ?41, ?42, ?43, ?44, ?45), (?46, ?47, ?48, ?49, ?50, ?51, ?52, ?53, ?54, ?55, ?56, ?57, ?58, ?59, ?60), (?61, ?62, ?63, ?64, ?65, ?66, ?67, ?68, ?69, ?70, ?71, ?72, ?73, ?74, ?75), (?76, ?77, ?78, ?79, ?80, ?81, ?82, ?83, ?84, ?85, ?86, ?87, ?88, ?89, ?90), (?91, ?92, ?93, ?94, ?95, ?96, ?97, ?98, ?99, ?100, ?101, ?102, ?103, ?104, ?105), (?106, ?107, ?108, ?109, ?110, ?111, ?112, ?113, ?114, ?115, ?116, ?117, ?118, ?119, ?120), (?121, ?122, ?123, ?124, ?125, ?126, ?127, ?128, ?129, ?130, ?131, ?132, ?133, ?134, ?135), (?136, ?137, ?138, ?139, ?140, ?141, ?142, ?143, ?144, ?145, ?146, ?147, ?148, ?149, ?150), (?151, ?152, ?153, ?154, ?155, ?156, ?157, ?158, ?159, ?160, ?161, ?162, ?163, ?164, ?165), (?166, ?167, ?168, ?169, ?170, ?171, ?172, ?173, ?174, ?175, ?176, ?177, ?178, ?179, ?180), (?181, ?182, ?183, ?184, ?185, ?186, ?187, ?188, ?189, ?190, ?191, ?192, ?193, ?194, ?195), (?196, ?197, ?198, ?199, ?200, ?201, ?202, ?203, ?204, ?205, ?206, ?207, ?208, ?209, ?210), (?211, ?212, ?213, ?214, ?215, ?216, ?217, ?218, ?219, ?220, ?221, ?222, ?223, ?224, ?225), (?226, ?227, ?228, ?229, ?230, ?231, ?232, ?233, ?234, ?235, ?236, ?237, ?238, ?239, ?240), (?241, ?242, ?243, ?244, ?245, ?246, ?247, ?248, ?249, ?250, ?251, ?252, ?253, ?254, ?255), (?256, ?257, ?258, ?259, ?260, ?261, ?262, ?263, ?264, ?265, ?266, ?267, ?268, ?269, ?270), (?271, ?272, ?273, ?274, ?275, ?276, ?277, ?278, ?279, ?280, ?281, ?282, ?283, ?284, ?285), (?286, ?287, ?288, ?289, ?290, ?291, ?292, ?293, ?294, ?295, ?296, ?297, ?298, ?299, ?300), (?301, ?302, ?303, ?304, ?305, ?306, ?307, ?308, ?309, ?310, ?311, ?312, ?313, ?314, ?315), (?316, ?317, ?318, ?319, ?320, ?321, ?322, ?323, ?324, ?325, ?326, ?327, ?328, ?329, ?330), (?331, ?332, ?333, ?334, ?335, ?336, ?337, ?338, ?339, ?340, ?341, ?342, ?343, ?344, ?345), (?346, ?347, ?348, ?349, ?350, ?351, ?352, ?353, ?354, ?355, ?356, ?357, ?358, ?359, ?360), (?361, ?362, ?363, ?364, ?365, ?366, ?367, ?368, ?369, ?370, ?371, ?372, ?373, ?374, ?375), (?376, ?377, ?378, ?379, ?380, ?381, ?382, ?383, ?384, ?385, ?386, ?387, ?388, ?389, ?390), (?391, ?392, ?393, ?394, ?395, ?396, ?397, ?398, ?399, ?400, ?401, ?402, ?403, ?404, ?405), (?406, ?407, ?408, ?409, ?410, ?411, ?412, ?413, ?414, ?415, ?416, ?417, ?418, ?419, ?420), (?421, ?422, ?423, ?424, ?425, ?426, ?427, ?428, ?429, ?430, ?431, ?432, ?433, ?434, ?435), (?436, ?437, ?438, ?439, ?440, ?441, ?442, ?443, ?444, ?445, ?446, ?447, ?448, ?449, ?450), (?451, ?452, ?453, ?454, ?455, ?456, ?457, ?458, ?459, ?460, ?461, ?462, ?463, ?464, ?465), (?466, ?467, ?468, ?469, ?470, ?471, ?472, ?473, ?474, ?475, ?476, ?477, ?478, ?479, ?480)";
rc = sdb->prepare_v2(query1, &statement1);
ASSERT_SQLITE_OK(rc, sdb);
rc = sdb->prepare_v2(query32, &statement32);
@ -503,37 +503,38 @@ int ProxySQL_Admin::FlushDigestTableToDisk(SQLite3DB *_db) {
QP_query_digest_stats * qds = (QP_query_digest_stats *)it->second;
int idx=row_idx%32;
if (row_idx<max_bulk_row_idx) { // bulk
rc=sqlite3_bind_int64(statement32, (idx*14)+1, qds->hid); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement32, (idx*14)+2, qds->schemaname, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement32, (idx*14)+3, qds->username, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement32, (idx*14)+4, qds->client_address, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*15)+1, __now); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*15)+2, qds->hid); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement32, (idx*15)+3, qds->schemaname, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement32, (idx*15)+4, qds->username, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement32, (idx*15)+5, qds->client_address, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
sprintf(qdsp.digest,"0x%016llX", (long long unsigned int)qds->digest);
rc=sqlite3_bind_text(statement32, (idx*14)+5, qdsp.digest, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement32, (idx*15)+6, qdsp.digest, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
if (qds->digest_text) {
rc=sqlite3_bind_text(statement32, (idx*14)+6, qds->digest_text, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement32, (idx*15)+7, qds->digest_text, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
} else {
std::unordered_map<uint64_t, char *>::iterator it2;
it2=uqdt.find(qds->digest);
if (it2 != uqdt.end()) {
rc=sqlite3_bind_text(statement32, (idx*14)+6, it2->second, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement32, (idx*15)+7, it2->second, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
} else {
assert(0);
}
}
rc=sqlite3_bind_int64(statement32, (idx*14)+7, qds->count_star); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*15)+8, qds->count_star); ASSERT_SQLITE_OK(rc, sdb);
{
seen_time = __now - curtime/1000000 + qds->first_seen/1000000;
rc=sqlite3_bind_int64(statement32, (idx*14)+8, seen_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*15)+9, seen_time); ASSERT_SQLITE_OK(rc, sdb);
}
{
seen_time = __now - curtime/1000000 + qds->last_seen/1000000;
rc=sqlite3_bind_int64(statement32, (idx*14)+9, seen_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*15)+10, seen_time); ASSERT_SQLITE_OK(rc, sdb);
}
rc=sqlite3_bind_int64(statement32, (idx*14)+10, qds->sum_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*14)+11, qds->min_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*14)+12, qds->max_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*14)+13, qds->rows_affected); ASSERT_SQLITE_OK(rc, sdb); // rows affected
rc=sqlite3_bind_int64(statement32, (idx*14)+14, qds->rows_sent); ASSERT_SQLITE_OK(rc, sdb); // rows sent
rc=sqlite3_bind_int64(statement32, (idx*15)+11, qds->sum_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*15)+12, qds->min_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*15)+13, qds->max_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement32, (idx*15)+14, qds->rows_affected); ASSERT_SQLITE_OK(rc, sdb); // rows affected
rc=sqlite3_bind_int64(statement32, (idx*15)+15, qds->rows_sent); ASSERT_SQLITE_OK(rc, sdb); // rows sent
if (idx==31) {
SAFE_SQLITE3_STEP2(statement32);
rc=sqlite3_clear_bindings(statement32); ASSERT_SQLITE_OK(rc, sdb);
@ -544,38 +545,39 @@ int ProxySQL_Admin::FlushDigestTableToDisk(SQLite3DB *_db) {
}
}
} else { // single row
rc=sqlite3_bind_int64(statement1, 1, qds->hid); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 1, __now); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 2, qds->hid); ASSERT_SQLITE_OK(rc, sdb);
assert(qds->schemaname);
rc=sqlite3_bind_text(statement1, 2, qds->schemaname, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement1, 3, qds->username, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement1, 4, qds->client_address, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement1, 3, qds->schemaname, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement1, 4, qds->username, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement1, 5, qds->client_address, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
sprintf(qdsp.digest,"0x%016llX", (long long unsigned int)qds->digest);
rc=sqlite3_bind_text(statement1, 5, qdsp.digest, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement1, 6, qdsp.digest, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
if (qds->digest_text) {
rc=sqlite3_bind_text(statement1, 6, qds->digest_text, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement1, 7, qds->digest_text, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
} else {
std::unordered_map<uint64_t, char *>::iterator it2;
it2=uqdt.find(qds->digest);
if (it2 != uqdt.end()) {
rc=sqlite3_bind_text(statement1, 6, it2->second, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_text(statement1, 7, it2->second, -1, SQLITE_TRANSIENT); ASSERT_SQLITE_OK(rc, sdb);
} else {
assert(0);
}
}
rc=sqlite3_bind_int64(statement1, 7, qds->count_star); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 8, qds->count_star); ASSERT_SQLITE_OK(rc, sdb);
{
seen_time = __now - curtime/1000000 + qds->first_seen/1000000;
rc=sqlite3_bind_int64(statement1, 8, seen_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 9, seen_time); ASSERT_SQLITE_OK(rc, sdb);
}
{
seen_time = __now - curtime/1000000 + qds->last_seen/1000000;
rc=sqlite3_bind_int64(statement1, 9, seen_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 10, seen_time); ASSERT_SQLITE_OK(rc, sdb);
}
rc=sqlite3_bind_int64(statement1, 10, qds->sum_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 11, qds->min_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 12, qds->max_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 13, qds->rows_affected); ASSERT_SQLITE_OK(rc, sdb); // rows affected
rc=sqlite3_bind_int64(statement1, 14, qds->rows_sent); ASSERT_SQLITE_OK(rc, sdb); // rows sent
rc=sqlite3_bind_int64(statement1, 11, qds->sum_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 12, qds->min_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 13, qds->max_time); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_bind_int64(statement1, 14, qds->rows_affected); ASSERT_SQLITE_OK(rc, sdb); // rows affected
rc=sqlite3_bind_int64(statement1, 15, qds->rows_sent); ASSERT_SQLITE_OK(rc, sdb); // rows sent
SAFE_SQLITE3_STEP2(statement1);
rc=sqlite3_clear_bindings(statement1); ASSERT_SQLITE_OK(rc, sdb);
rc=sqlite3_reset(statement1); ASSERT_SQLITE_OK(rc, sdb);
@ -4548,27 +4550,14 @@ bool ProxySQL_Admin::init() {
if (GloVars.__cmd_proxysql_reload || GloVars.__cmd_proxysql_initial || admindb_file_exists==false) { // see #617
if (GloVars.configfile_open) {
if (GloVars.confFile->cfg) {
Read_MySQL_Servers_from_configfile();
Read_Global_Variables_from_configfile("admin");
Read_Global_Variables_from_configfile("mysql");
Read_MySQL_Users_from_configfile();
Read_MySQL_Query_Rules_from_configfile();
Read_Scheduler_from_configfile();
Read_ProxySQL_Servers_from_configfile();
__insert_or_replace_disktable_select_maintable();
} else {
if (GloVars.confFile->OpenFile(GloVars.config_file)==true) {
Read_MySQL_Servers_from_configfile();
Read_MySQL_Users_from_configfile();
Read_MySQL_Query_Rules_from_configfile();
Read_Global_Variables_from_configfile("admin");
Read_Global_Variables_from_configfile("mysql");
Read_Scheduler_from_configfile();
Read_ProxySQL_Servers_from_configfile();
__insert_or_replace_disktable_select_maintable();
}
}
Read_MySQL_Servers_from_configfile();
Read_MySQL_Users_from_configfile();
Read_MySQL_Query_Rules_from_configfile();
Read_Global_Variables_from_configfile("admin");
Read_Global_Variables_from_configfile("mysql");
Read_Scheduler_from_configfile();
Read_ProxySQL_Servers_from_configfile();
__insert_or_replace_disktable_select_maintable();
}
}
flush_admin_variables___database_to_runtime(admindb,true);
@ -5187,7 +5176,6 @@ bool ProxySQL_Admin::ProxySQL_Test___Verify_mysql_query_rules_fast_routing(int *
unsigned int ProxySQL_Admin::ProxySQL_Test___GenerateRandom_mysql_query_rules_fast_routing(unsigned int cnt) {
char *a = "INSERT OR IGNORE INTO mysql_query_rules_fast_routing VALUES (?1, ?2, ?3, ?4, '')";
int rc;
unsigned int i=0;
sqlite3_stmt *statement1=NULL;
rc=admindb->prepare_v2(a, &statement1);
ASSERT_SQLITE_OK(rc, admindb);
@ -9008,7 +8996,7 @@ char * ProxySQL_Admin::load_mysql_query_rules_to_runtime() {
}
int ProxySQL_Admin::Read_Global_Variables_from_configfile(const char *prefix) {
const Setting& root = GloVars.confFile->cfg->getRoot();
const Setting& root = GloVars.confFile->cfg.getRoot();
char *groupname=(char *)malloc(strlen(prefix)+strlen((char *)"_variables")+1);
sprintf(groupname,"%s%s",prefix,"_variables");
if (root.exists(groupname)==false) {
@ -9049,7 +9037,7 @@ int ProxySQL_Admin::Read_Global_Variables_from_configfile(const char *prefix) {
}
int ProxySQL_Admin::Read_MySQL_Users_from_configfile() {
const Setting& root = GloVars.confFile->cfg->getRoot();
const Setting& root = GloVars.confFile->cfg.getRoot();
if (root.exists("mysql_users")==false) return 0;
const Setting &mysql_users = root["mysql_users"];
int count = mysql_users.getLength();
@ -9098,7 +9086,7 @@ int ProxySQL_Admin::Read_MySQL_Users_from_configfile() {
}
int ProxySQL_Admin::Read_Scheduler_from_configfile() {
const Setting& root = GloVars.confFile->cfg->getRoot();
const Setting& root = GloVars.confFile->cfg.getRoot();
if (root.exists("scheduler")==false) return 0;
const Setting &schedulers = root["scheduler"];
int count = schedulers.getLength();
@ -9198,7 +9186,7 @@ int ProxySQL_Admin::Read_Scheduler_from_configfile() {
}
int ProxySQL_Admin::Read_MySQL_Query_Rules_from_configfile() {
const Setting& root = GloVars.confFile->cfg->getRoot();
const Setting& root = GloVars.confFile->cfg.getRoot();
if (root.exists("mysql_query_rules")==false) return 0;
const Setting &mysql_query_rules = root["mysql_query_rules"];
int count = mysql_query_rules.getLength();
@ -9460,7 +9448,7 @@ int ProxySQL_Admin::Read_MySQL_Query_Rules_from_configfile() {
}
int ProxySQL_Admin::Read_MySQL_Servers_from_configfile() {
const Setting& root = GloVars.confFile->cfg->getRoot();
const Setting& root = GloVars.confFile->cfg.getRoot();
int i;
int rows=0;
admindb->execute("PRAGMA foreign_keys = OFF");
@ -9678,7 +9666,7 @@ int ProxySQL_Admin::Read_MySQL_Servers_from_configfile() {
}
int ProxySQL_Admin::Read_ProxySQL_Servers_from_configfile() {
const Setting& root = GloVars.confFile->cfg->getRoot();
const Setting& root = GloVars.confFile->cfg.getRoot();
int i;
int rows=0;
admindb->execute("PRAGMA foreign_keys = OFF");

@ -114,6 +114,7 @@ void ProxySQL_Statistics::init() {
// statsdb_disk->execute("CREATE INDEX IF NOT EXISTS idx_history_mysql_query_digest_digest ON history_mysql_query_digest (digest)");
statsdb_disk->execute("CREATE INDEX IF NOT EXISTS idx_history_mysql_query_digest_first_seen ON history_mysql_query_digest (first_seen)");
// statsdb_disk->execute("CREATE INDEX IF NOT EXISTS idx_history_mysql_query_digest_last_seen ON history_mysql_query_digest (last_seen)");
statsdb_disk->execute("CREATE INDEX IF NOT EXISTS idx_history_mysql_query_digest_dump_time ON history_mysql_query_digest (dump_time)");
}
void ProxySQL_Statistics::disk_upgrade_mysql_connections() {

@ -32,21 +32,13 @@ struct _global_configfile_entry_t {
void (*func_post)(global_configfile_entry_t *); // function called after initializing variable
};
ProxySQL_ConfigFile::ProxySQL_ConfigFile() {
filename=NULL;
};
bool ProxySQL_ConfigFile::OpenFile(const char *__filename) {
cfg = new Config();
if (__filename) {
filename=strdup(__filename);
} else {
assert(filename);
}
if (FileUtils::isReadable(filename)==false) return false;
assert(__filename);
filename = __filename;
if (FileUtils::isReadable(filename.c_str())==false) return false;
try
{
cfg->readFile(filename);
cfg.readFile(filename.c_str());
}
catch(const FileIOException &fioex)
{
@ -67,12 +59,6 @@ bool ProxySQL_ConfigFile::OpenFile(const char *__filename) {
};
void ProxySQL_ConfigFile::CloseFile() {
/* FIXME
for now we are commenting out this.
It seems that after upgrade to jemalloc 5.2.0 , valgrind crashes here
*/
// delete cfg;
cfg=NULL;
}
bool ProxySQL_ConfigFile::ReadGlobals() {
@ -80,7 +66,7 @@ bool ProxySQL_ConfigFile::ReadGlobals() {
};
bool ProxySQL_ConfigFile::configVariable(const char *group, const char *key, int &variable, int defValue, int minValue, int maxValue, int multiplier) {
const Setting& root = cfg->getRoot();
const Setting& root = cfg.getRoot();
if (root.exists(group)==true) {
const Setting& mygroup=root[group];
if (mygroup.isGroup()==true) {
@ -119,7 +105,7 @@ bool ProxySQL_ConfigFile::configVariable(const char *group, const char *key, int
}
bool ProxySQL_ConfigFile::configVariable(const char *group, const char *key, int64_t &variable, int64_t defValue, int64_t minValue, int64_t maxValue, int64_t multiplier) {
const Setting& root = cfg->getRoot();
const Setting& root = cfg.getRoot();
if (root.exists(group)==true) {
const Setting& mygroup=root[group];
if (mygroup.isGroup()==true) {
@ -158,7 +144,7 @@ bool ProxySQL_ConfigFile::configVariable(const char *group, const char *key, int
}
bool ProxySQL_ConfigFile::configVariable(const char *group, const char *key, bool & variable, bool defValue) {
const Setting& root = cfg->getRoot();
const Setting& root = cfg.getRoot();
if (root.exists(group)==true) {
const Setting& mygroup=root[group];
if (mygroup.isGroup()==true) {
@ -187,7 +173,7 @@ bool ProxySQL_ConfigFile::configVariable(const char *group, const char *key, boo
}
bool ProxySQL_ConfigFile::configVariable(const char *group, const char *key, char **variable, const char *defValue) {
const Setting& root = cfg->getRoot();
const Setting& root = cfg.getRoot();
if (root.exists(group)==true) {
const Setting& mygroup=root[group];
if (mygroup.isGroup()==true) {
@ -215,6 +201,4 @@ bool ProxySQL_ConfigFile::configVariable(const char *group, const char *key, cha
return true;
}
ProxySQL_ConfigFile::~ProxySQL_ConfigFile() {
if (filename) free(filename);
};

@ -701,7 +701,7 @@ void ProxySQL_Main_process_global_variables(int argc, const char **argv) {
if (GloVars.confFile->OpenFile(GloVars.config_file) == true) {
GloVars.configfile_open=true;
proxy_info("Using config file %s\n", GloVars.config_file);
const Setting& root = GloVars.confFile->cfg->getRoot();
const Setting& root = GloVars.confFile->cfg.getRoot();
if (root.exists("restart_on_missing_heartbeats")==true) {
// restart_on_missing_heartbeats datadir from config file
int restart_on_missing_heartbeats;
@ -748,7 +748,7 @@ void ProxySQL_Main_process_global_variables(int argc, const char **argv) {
if (GloVars.__cmd_proxysql_datadir==NULL) {
// datadir was not specified , try to read config file
if (GloVars.configfile_open==true) {
const Setting& root = GloVars.confFile->cfg->getRoot();
const Setting& root = GloVars.confFile->cfg.getRoot();
if (root.exists("datadir")==true) {
// reading datadir from config file
std::string datadir;

Loading…
Cancel
Save