Skip to content

Commit

Permalink
Add list of special permitted variables tracking errors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JavierJF committed Jul 18, 2024
1 parent 7f441ec commit 85c80f1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/MySQL_Variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
8 changes: 6 additions & 2 deletions include/proxysql_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SQL_NAME_LAST_HIGH_WM; i++) {
Expand Down
18 changes: 18 additions & 0 deletions lib/MySQL_Variables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#endif

#include <sstream>
#include "mysql/mysqld_error.h"


static inline char is_digit(char c) {
Expand All @@ -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];
Expand Down

0 comments on commit 85c80f1

Please sign in to comment.