From 45988e6488e88217c4d076e3d4a8e839f45560dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 25 Jun 2015 17:27:00 +0000 Subject: [PATCH] Converted ProxySQL_Admin::__attach_db_to_admindb() to a more generic ProxySQL_Admin::__attach_db() to allow access to monitor via stats --- include/proxysql_admin.h | 2 +- lib/ProxySQL_Admin.cpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index 73b344ca0..a7c7a49f6 100644 --- a/include/proxysql_admin.h +++ b/include/proxysql_admin.h @@ -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); diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index f28a4540f..f932d8cfd 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -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); }