Converted ProxySQL_Admin::__attach_db_to_admindb() to a more generic ProxySQL_Admin::__attach_db() to allow access to monitor via stats

pull/317/head
René Cannaò 11 years ago
parent 893b3c26f0
commit 45988e6488

@ -52,7 +52,7 @@ class ProxySQL_Admin {
void __delete_disktable();
void __insert_or_replace_disktable_select_maintable();
// void __attach_configdb_to_admindb();
void __attach_db_to_admindb(SQLite3DB *db, char *alias);
void __attach_db(SQLite3DB *db1, SQLite3DB *db2, char *alias);
void __add_active_users(enum cred_username_type usertype);

@ -1349,9 +1349,10 @@ bool ProxySQL_Admin::init() {
check_and_build_standard_tables(configdb, tables_defs_config);
check_and_build_standard_tables(statsdb, tables_defs_stats);
__attach_db_to_admindb(configdb, (char *)"disk");
__attach_db_to_admindb(statsdb, (char *)"stats");
__attach_db_to_admindb(monitordb, (char *)"monitor");
__attach_db(admindb, configdb, (char *)"disk");
__attach_db(admindb, statsdb, (char *)"stats");
__attach_db(admindb, monitordb, (char *)"monitor");
__attach_db(statsdb, monitordb, (char *)"monitor");
#ifdef DEBUG
admindb->execute("ATTACH DATABASE 'file:mem_mydb?mode=memory&cache=shared' AS myhgm");
@ -2096,12 +2097,12 @@ void ProxySQL_Admin::flush_mysql_query_rules__from_memory_to_disk() {
void ProxySQL_Admin::__attach_db_to_admindb(SQLite3DB *db, char *alias) {
void ProxySQL_Admin::__attach_db(SQLite3DB *db1, SQLite3DB *db2, char *alias) {
const char *a="ATTACH DATABASE '%s' AS %s";
int l=strlen(a)+strlen(db->get_url())+strlen(alias)+5;
int l=strlen(a)+strlen(db2->get_url())+strlen(alias)+5;
char *cmd=(char *)malloc(l);
sprintf(cmd,a,db->get_url(), alias);
admindb->execute(cmd);
sprintf(cmd,a,db2->get_url(), alias);
db1->execute(cmd);
free(cmd);
}

Loading…
Cancel
Save