Track NO_BACKSLASH_ESCAPES

Track NO_BACKSLASH_ESCAPES in case it is changed:
- using SET sql_mode by the client
- directly on the backend (for example default sql_mode, or an
  sql_mode set from another variable)
pull/3854/head
René Cannaò 4 years ago
parent 50f1c9f61a
commit 9275e2858d

@ -5645,6 +5645,16 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C
auto values = std::begin(it->second);
if (var == "sql_mode") {
std::string value1 = *values;
if (strcasecmp(value1.c_str(),"NO_BACKSLASH_ESCAPE") != 0) {
// client is setting NO_BACKSLASH_ESCAPE in sql_mode
// Because we will reply with an OK packet without
// first setting sql_mode to the backend (this is
// by design) we need to set no_backslash_escapes
// in the client connection
if (client_myds && client_myds->myconn) { // some extra sanity check
client_myds->myconn->set_no_backslash_escapes(true);
}
}
if (
( strcasecmp(value1.c_str(),(char *)"CONCAT") == 0 )
||

@ -2537,6 +2537,17 @@ void MySQL_Connection::ProcessQueryAndSetStatusFlags(char *query_digest_text) {
set_status(false, STATUS_MYSQL_CONNECTION_HAS_SAVEPOINT);
}
}
if (mysql) {
if (myds && myds->sess) {
if (myds->sess->client_myds && myds->sess->client_myds->myconn) {
// if SERVER_STATUS_NO_BACKSLASH_ESCAPES is changed it is likely
// because of sql_mode was changed
// we set the same on the client connection
unsigned int ss = mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES;
myds->sess->client_myds->myconn->set_no_backslash_escapes(ss);
}
}
}
}
void MySQL_Connection::optimize() {

Loading…
Cancel
Save