From b91b6b8f9f19e44e7bce1992271f2a2dab3d76d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Thu, 18 Jul 2024 09:03:35 +0200 Subject: [PATCH] Add list of special permitted variables tracking errors - Closes #4591 This list hold tracking errors that in practice are equivalent to ER_UNKNOWN_SYSTEM_VARIABLE and that we want to handle in the same way. --- include/MySQL_Variables.h | 1 + include/proxysql_structs.h | 8 ++++++-- lib/MySQL_Session.cpp | 2 ++ lib/MySQL_Variables.cpp | 18 ++++++++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/MySQL_Variables.h b/include/MySQL_Variables.h index 678d594a06..4d0aa5c8a9 100644 --- a/include/MySQL_Variables.h +++ b/include/MySQL_Variables.h @@ -20,6 +20,7 @@ bool update_server_variable(MySQL_Session* session, int idx, int &_rc); bool verify_server_variable(MySQL_Session* session, int idx, uint32_t client_hash, uint32_t server_hash); bool verify_set_names(MySQL_Session* session); bool logbin_update_server_variable(MySQL_Session* session, int idx, int &_rc); +bool is_perm_track_err(int err, const char* varname); class MySQL_Variables { static verify_var verifiers[SQL_NAME_LAST_HIGH_WM]; diff --git a/include/proxysql_structs.h b/include/proxysql_structs.h index f3d322305c..deac187de0 100644 --- a/include/proxysql_structs.h +++ b/include/proxysql_structs.h @@ -277,6 +277,11 @@ typedef struct { char * default_value; // default value bool is_global_variable; // is it a global variable? } mysql_variable_st; + +typedef struct { + int err; + const char* name; +} var_track_err_st; #endif enum mysql_data_stream_status { @@ -1218,10 +1223,9 @@ mysql_variable_st mysql_tracked_variables[] { session_track_system_variables session_track_transaction_info */ - - }; #else extern mysql_variable_st mysql_tracked_variables[]; +extern var_track_err_st perm_track_errs[]; #endif // PROXYSQL_EXTERN #endif // MYSQL_TRACKED_VARIABLES diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index ae306e36e4..b40d922539 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -2974,6 +2974,8 @@ bool MySQL_Session::handler_again___status_SETTING_GENERIC_VARIABLE(int *_rc, co (myerr == 1193) // variable is not found || (myerr == 1651) // Query cache is disabled + || + (is_perm_track_err(myerr, var_name)) // Special permitted tracking errors (~= '1193') ) { int idx = SQL_NAME_LAST_HIGH_WM; for (int i=0; i +#include "mysql/mysqld_error.h" static inline char is_digit(char c) { @@ -17,6 +18,23 @@ static inline char is_digit(char c) { return 0; } +var_track_err_st perm_track_errs[] { + // ERROR 1210 (HY000): Variable not supported in combination with Galera: + // - Changed by MySQL, previously 'ER_UNKNOWN_SYSTEM_VARIABLE' + { ER_WRONG_ARGUMENTS, "sql_generate_invisible_primary_key" } +}; + +bool is_perm_track_err(int err, const char* varname) { + const size_t count = sizeof(perm_track_errs) / sizeof(var_track_err_st); + + for (size_t i = 0; i < count; i++) { + if (perm_track_errs[i].err == err && (strcasecmp(varname, perm_track_errs[i].name) == 0)) { + return true; + } + } + return false; +} + #include "proxysql_find_charset.h" verify_var MySQL_Variables::verifiers[SQL_NAME_LAST_HIGH_WM];