From b912d978b00ec8b6dc88cf273d1bb875208b9ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Tue, 10 Aug 2021 22:12:55 +0200 Subject: [PATCH] Removing or commenting legacy/unused code --- include/MySQL_PreparedStatement.h | 3 +- include/configfile.hpp | 4 - lib/MySQL_PreparedStatement.cpp | 8 +- lib/MySQL_Session.cpp | 2 +- lib/configfile.cpp | 140 +----------------------------- 5 files changed, 13 insertions(+), 144 deletions(-) diff --git a/include/MySQL_PreparedStatement.h b/include/MySQL_PreparedStatement.h index 709f41dd89..344eb945e2 100644 --- a/include/MySQL_PreparedStatement.h +++ b/include/MySQL_PreparedStatement.h @@ -253,7 +253,8 @@ class MySQL_STMT_Manager_v14 { public: MySQL_STMT_Manager_v14(); ~MySQL_STMT_Manager_v14(); - MySQL_STMT_Global_info * find_prepared_statement_by_hash(uint64_t hash, bool lock=true); + //MySQL_STMT_Global_info * find_prepared_statement_by_hash(uint64_t hash, bool lock=true); // removed in 2.3 + MySQL_STMT_Global_info * find_prepared_statement_by_hash(uint64_t hash); MySQL_STMT_Global_info * find_prepared_statement_by_stmt_id(uint64_t id, bool lock=true); void rdlock() { pthread_rwlock_rdlock(&rwlock_); } void wrlock() { pthread_rwlock_wrlock(&rwlock_); } diff --git a/include/configfile.hpp b/include/configfile.hpp index bcf73493a7..bae393115b 100644 --- a/include/configfile.hpp +++ b/include/configfile.hpp @@ -15,10 +15,6 @@ class ProxySQL_ConfigFile { 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 *); }; diff --git a/lib/MySQL_PreparedStatement.cpp b/lib/MySQL_PreparedStatement.cpp index c8616e4575..4c89b86ff0 100644 --- a/lib/MySQL_PreparedStatement.cpp +++ b/lib/MySQL_PreparedStatement.cpp @@ -725,12 +725,14 @@ MySQL_STMTs_local_v14::~MySQL_STMTs_local_v14() { MySQL_STMT_Global_info *MySQL_STMT_Manager_v14::find_prepared_statement_by_hash( - uint64_t hash, bool lock) { + uint64_t hash) { + //uint64_t hash, bool lock) { // removed in 2.3 MySQL_STMT_Global_info *ret = NULL; // assume we do not find it +/* removed in 2.3 if (lock) { pthread_rwlock_wrlock(&rwlock_); } - +*/ auto s = map_stmt_hash_to_info.find(hash); if (s != map_stmt_hash_to_info.end()) { ret = s->second; @@ -740,9 +742,11 @@ MySQL_STMT_Global_info *MySQL_STMT_Manager_v14::find_prepared_statement_by_hash( // __sync_fetch_and_add(&ret->ref_count_client, 1); } +/* removed in 2.3 if (lock) { pthread_rwlock_unlock(&rwlock_); } +*/ return ret; } diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 9a9f583ea4..e4e9a0bbef 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -2979,7 +2979,7 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C MySQL_STMT_Global_info *stmt_info=NULL; // we first lock GloStmt GloMyStmt->wrlock(); - stmt_info=GloMyStmt->find_prepared_statement_by_hash(hash,false); + stmt_info=GloMyStmt->find_prepared_statement_by_hash(hash); if (stmt_info) { // the prepared statement exists in GloMyStmt // for this reason, we do not need to prepare it again, and we can already reply to the client diff --git a/lib/configfile.cpp b/lib/configfile.cpp index 3f29bcb9ea..31da0a07d9 100644 --- a/lib/configfile.cpp +++ b/lib/configfile.cpp @@ -62,145 +62,13 @@ bool ProxySQL_ConfigFile::OpenFile(const char *__filename) { return true; }; + void ProxySQL_ConfigFile::CloseFile() { + // this function is now empty + // perhaps we can remove it + // see e85c34b2952f5a05d3f02a8afca30c0de334d898 for reference } bool ProxySQL_ConfigFile::ReadGlobals() { return true; }; - -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(); - if (root.exists(group)==true) { - const Setting& mygroup=root[group]; - if (mygroup.isGroup()==true) { - // group exists - if (mygroup.exists(key)==true) { - const Setting& myvar=mygroup[key]; - if ((myvar.getType()==Setting::Type::TypeInt) || (myvar.getType()==Setting::Type::TypeInt64)) { - int var=myvar; - if ( var < minValue ) { - cerr << "[ERROR] Out of range value for " << group << "." << key << " in config file\n"; - var=minValue; - } - if ( var > maxValue ) { - cerr << "[ERROR] Out of range value for " << group << "." << key << " in config file\n"; - var=maxValue; - } - variable=var*(multiplier > 0 ? multiplier : 1); - } else { - cerr << "[ERROR] Incorrect datatype for " << group << "." << key << " in config file. Setting default\n"; - variable=defValue*(multiplier > 0 ? multiplier : 1); - return false; - } - } else { - variable=defValue*(multiplier > 0 ? multiplier : 1); - return false; - } - } else { - variable=defValue*(multiplier > 0 ? multiplier : 1); - return false; - } - } else { - variable=defValue*(multiplier > 0 ? multiplier : 1); - return false; - } - return true; -} - -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(); - if (root.exists(group)==true) { - const Setting& mygroup=root[group]; - if (mygroup.isGroup()==true) { - // group exists - if (mygroup.exists(key)==true) { - const Setting& myvar=mygroup[key]; - if ((myvar.getType()==Setting::Type::TypeInt) || (myvar.getType()==Setting::Type::TypeInt64)) { - int64_t var=myvar; - if ( var < minValue ) { - cerr << "[ERROR] Out of range value for " << group << "." << key << " in config file\n"; - var=minValue; - } - if ( var > maxValue ) { - cerr << "[ERROR] Out of range value for " << group << "." << key << " in config file\n"; - var=maxValue; - } - variable=var*(multiplier > 0 ? multiplier : 1); - } else { - cerr << "[ERROR] Incorrect datatype for " << group << "." << key << " in config file. Setting default\n"; - variable=defValue*multiplier; - return false; - } - } else { - variable=defValue*(multiplier > 0 ? multiplier : 1); - return false; - } - } else { - variable=defValue*(multiplier > 0 ? multiplier : 1); - return false; - } - } else { - variable=defValue*(multiplier > 0 ? multiplier : 1); - return false; - } - return true; -} - -bool ProxySQL_ConfigFile::configVariable(const char *group, const char *key, bool & variable, bool defValue) { - const Setting& root = cfg.getRoot(); - if (root.exists(group)==true) { - const Setting& mygroup=root[group]; - if (mygroup.isGroup()==true) { - // group exists - if (mygroup.exists(key)==true) { - const Setting& myvar=mygroup[key]; - if (myvar.getType()==Setting::Type::TypeBoolean) { - } else { - cerr << "[ERROR] Incorrect datatype for " << group << "." << key << " in config file. Setting default\n"; - variable=defValue; - return false; - } - } else { - variable=defValue; - return false; - } - } else { - variable=defValue; - return false; - } - } else { - variable=defValue; - return false; - } - return true; -} - -bool ProxySQL_ConfigFile::configVariable(const char *group, const char *key, char **variable, const char *defValue) { - const Setting& root = cfg.getRoot(); - if (root.exists(group)==true) { - const Setting& mygroup=root[group]; - if (mygroup.isGroup()==true) { - // group exists - if (mygroup.exists(key)==true) { - const Setting& myvar=mygroup[key]; - if (myvar.getType()==Setting::Type::TypeString) { - } else { - cerr << "[ERROR] Incorrect datatype for " << group << "." << key << " in config file. Setting default\n"; - *variable=strdup(defValue); - return false; - } - } else { - *variable=strdup(defValue); - return false; - } - } else { - *variable=strdup(defValue); - return false; - } - } else { - *variable=strdup(defValue); - return false; - } - return true; -}