From 386a8929db429fffea984e395bebb1d5ac85a700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Wed, 1 Jul 2020 17:23:51 +0200 Subject: [PATCH] Fixes #2916: 'admindb' is now replaced if current one doesn't match the one in the static object --- include/proxysql_config.h | 2 +- include/proxysql_restapi.h | 2 +- lib/ProxySQL_Admin.cpp | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/proxysql_config.h b/include/proxysql_config.h index bc095b76c7..1a98cce359 100644 --- a/include/proxysql_config.h +++ b/include/proxysql_config.h @@ -7,8 +7,8 @@ class SQLite3DB; extern const char* config_header; class ProxySQL_Config { - SQLite3DB* admindb; public: + SQLite3DB* admindb; ProxySQL_Config(SQLite3DB* db); virtual ~ProxySQL_Config(); diff --git a/include/proxysql_restapi.h b/include/proxysql_restapi.h index 9660a12646..b1de2bd825 100644 --- a/include/proxysql_restapi.h +++ b/include/proxysql_restapi.h @@ -22,8 +22,8 @@ class Restapi_Row { }; class ProxySQL_Restapi { - SQLite3DB* admindb; public: + SQLite3DB* admindb; ProxySQL_Restapi(SQLite3DB* db); virtual ~ProxySQL_Restapi(); diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 84c2e86e47..e672a38ed4 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -778,11 +778,17 @@ int ProxySQL_Test___GetDigestTable(bool reset, bool use_swap) { ProxySQL_Config& ProxySQL_Admin::proxysql_config() { static ProxySQL_Config instance = ProxySQL_Config(admindb); + if (instance.admindb != admindb) { + instance.admindb = admindb; + } return instance; } ProxySQL_Restapi& ProxySQL_Admin::proxysql_restapi() { static ProxySQL_Restapi instance = ProxySQL_Restapi(admindb); + if (instance.admindb != admindb) { + instance.admindb = admindb; + } return instance; }