Skip to content

Commit

Permalink
Merge pull request #4283 from sysown/v2.x_reordering_mysql_variables
Browse files Browse the repository at this point in the history
Reordered SQL_ISOLATION_LEVEL, SQL_TRANSACTION_READ, and SQL_WSREP_SYNC_WAIT tracked variables
  • Loading branch information
renecannao authored Jul 17, 2023
2 parents e02813c + 8d03589 commit 299c833
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
15 changes: 7 additions & 8 deletions include/proxysql_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,10 @@ enum mysql_variable_name {
SQL_CHARACTER_SET_CONNECTION,
SQL_CHARACTER_SET_CLIENT,
SQL_CHARACTER_SET_DATABASE,
SQL_ISOLATION_LEVEL,
SQL_TRANSACTION_READ,
SQL_COLLATION_CONNECTION,
SQL_WSREP_SYNC_WAIT,
SQL_NAME_LAST_LOW_WM,
SQL_ISOLATION_LEVEL,
SQL_TRANSACTION_READ,
SQL_AURORA_READ_REPLICA_READ_COMMITTED,
SQL_AUTO_INCREMENT_INCREMENT,
SQL_AUTO_INCREMENT_OFFSET,
Expand Down Expand Up @@ -225,6 +224,7 @@ enum mysql_variable_name {
SQL_NEXT_TRANSACTION_READ,
SQL_UNIQUE_CHECKS,
SQL_WSREP_OSU_METHOD,
SQL_WSREP_SYNC_WAIT,
SQL_NAME_LAST_HIGH_WM,
};

Expand Down Expand Up @@ -1139,13 +1139,12 @@ mysql_variable_st mysql_tracked_variables[] {
{ SQL_CHARACTER_SET_CONNECTION, SETTING_VARIABLE, false, false, false, false, (char *)"character_set_connection", (char *)"character_set_connection", (char *)"utf8", false } ,
{ SQL_CHARACTER_SET_CLIENT, SETTING_VARIABLE, false, false, false, false, (char *)"character_set_client", (char *)"character_set_client", (char *)"utf8" , false} ,
{ SQL_CHARACTER_SET_DATABASE, SETTING_VARIABLE, false, false, false, false, (char *)"character_set_database", (char *)"character_set_database", (char *)"utf8" , false} ,
{ SQL_ISOLATION_LEVEL, SETTING_ISOLATION_LEVEL, false, true, false, false, (char *)"SESSION TRANSACTION ISOLATION LEVEL", (char *)"isolation_level", (char *)"READ COMMITTED" , false} ,
// NOTE: we also need support for transaction_read_only session variable
{ SQL_TRANSACTION_READ, SETTING_TRANSACTION_READ, false, true, false, false, (char *)"SESSION TRANSACTION READ", (char *)"transaction_read", (char *)"WRITE" , false} ,
{ SQL_COLLATION_CONNECTION, SETTING_VARIABLE, true, false, false, false, (char *)"collation_connection", (char *)"collation_connection", (char *)"utf8_general_ci" , true} ,
// { SQL_NET_WRITE_TIMEOUT, SETTING_VARIABLE, false, false, true, false, (char *)"net_write_timeout", (char *)"net_write_timeout", (char *)"60" , false} ,
{ SQL_WSREP_SYNC_WAIT, SETTING_VARIABLE, false, false, true, false, (char *)"wsrep_sync_wait", (char *)"wsrep_sync_wait", (char *)"0" , false} ,
{ SQL_NAME_LAST_LOW_WM, SETTING_VARIABLE, false, false, true, false, (char *)"placeholder", (char *)"placeholder", (char *)"0" , false} , // this is just a placeholder to separate the previous index from the next block
{ SQL_ISOLATION_LEVEL, SETTING_ISOLATION_LEVEL, false, true, false, false, (char *)"SESSION TRANSACTION ISOLATION LEVEL", (char *)"isolation_level", (char *)"READ COMMITTED" , false} ,
// NOTE: we also need support for transaction_read_only session variable
{ SQL_TRANSACTION_READ, SETTING_TRANSACTION_READ, false, true, false, false, (char *)"SESSION TRANSACTION READ", (char *)"transaction_read", (char *)"WRITE" , false} ,
{ SQL_AURORA_READ_REPLICA_READ_COMMITTED, SETTING_VARIABLE, false, false, false, true, ( char *)"aurora_read_replica_read_committed", NULL, (char *)"" , false} ,
{ SQL_AUTO_INCREMENT_INCREMENT, SETTING_VARIABLE, false, false, true, false, (char *)"auto_increment_increment", NULL, (char *)"" , false} ,
{ SQL_AUTO_INCREMENT_OFFSET, SETTING_VARIABLE, false, false, true, false, (char *)"auto_increment_offset", NULL, (char *)"" , false} ,
Expand Down Expand Up @@ -1196,7 +1195,7 @@ mysql_variable_st mysql_tracked_variables[] {
{ SQL_NEXT_TRANSACTION_READ, SETTING_NEXT_TRANSACTION_READ, false, true, false, false, (char *)"transaction read", (char *)"next_transaction_read", (char *)"WRITE" , false} ,
{ SQL_UNIQUE_CHECKS, SETTING_VARIABLE, true, false, false, true, (char *)"unique_checks", NULL, (char *)"" , false} ,
{ SQL_WSREP_OSU_METHOD, SETTING_VARIABLE, true, false, false, false, (char *)"wsrep_osu_method", NULL, (char *)"" , false} ,

{ SQL_WSREP_SYNC_WAIT, SETTING_VARIABLE, false, false, true, false, (char *)"wsrep_sync_wait", (char *)"wsrep_sync_wait", (char *)"0" , false} ,
/*
variables that will need input validation:
binlog_row_image
Expand Down
9 changes: 1 addition & 8 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2564,14 +2564,7 @@ bool MySQL_Session::handler_again___status_SETTING_GENERIC_VARIABLE(int *_rc, co
// https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Reference.html#AuroraMySQL.Reference.IsolationLevels
// Basically, to change isolation level you must first set
// aurora_read_replica_read_committed , and then isolation level
MySQL_Connection *beconn = mybe->server_myds->myconn;
if (beconn->var_hash[SQL_ISOLATION_LEVEL] != 0) {
beconn->var_hash[SQL_ISOLATION_LEVEL] = 0;
if (beconn->variables[SQL_ISOLATION_LEVEL].value) {
free(beconn->variables[SQL_ISOLATION_LEVEL].value);
beconn->variables[SQL_ISOLATION_LEVEL].value = NULL;
}
}
mysql_variables.server_reset_value(this, SQL_ISOLATION_LEVEL);
sprintf(query,q,var_name, var_value);
} else {
sprintf(query,q,var_name, var_value);
Expand Down

0 comments on commit 299c833

Please sign in to comment.