Refactoring of ProcessQueryAndSetStatusFlags()

pull/4535/head
René Cannaò 2 years ago
parent 4264e9349d
commit 2d89f06a5a

@ -65,6 +65,10 @@ class MySQL_Connection {
void connect_start_SetClientFlag(unsigned long&);
char * connect_start_DNS_lookup();
void connect_start_SetSslSettings();
void ProcessQueryAndSetStatusFlags_Warnings(char *);
void ProcessQueryAndSetStatusFlags_UserVariables(char *, int);
void ProcessQueryAndSetStatusFlags_Savepoint(char *);
void ProcessQueryAndSetStatusFlags_SetBackslashEscapes();
public:
struct {
char *server_version;

@ -2669,24 +2669,7 @@ bool MySQL_Connection::IsKeepMultiplexEnabledVariables(char *query_digest_text)
return true;
}
void MySQL_Connection::ProcessQueryAndSetStatusFlags(char *query_digest_text) {
if (query_digest_text==NULL) return;
// unknown what to do with multiplex
int mul=-1;
if (myds) {
if (myds->sess) {
if (myds->sess->qpo) {
mul=myds->sess->qpo->multiplex;
if (mul==0) {
set_status(true, STATUS_MYSQL_CONNECTION_NO_MULTIPLEX);
} else {
if (mul==1) {
set_status(false, STATUS_MYSQL_CONNECTION_NO_MULTIPLEX);
}
}
}
}
}
void MySQL_Connection::ProcessQueryAndSetStatusFlags_Warnings(char *query_digest_text) {
// checking warnings and disabling multiplexing will be effective only when the mysql-query_digests is enabled
if (get_status(STATUS_MYSQL_CONNECTION_HAS_WARNINGS) == false) {
if (warning_count > 0) {
@ -2712,7 +2695,10 @@ void MySQL_Connection::ProcessQueryAndSetStatusFlags(char *query_digest_text) {
set_status(false, STATUS_MYSQL_CONNECTION_HAS_WARNINGS);
}
}
}
void MySQL_Connection::ProcessQueryAndSetStatusFlags_UserVariables(char *query_digest_text, int mul) {
if (get_status(STATUS_MYSQL_CONNECTION_USER_VARIABLE)==false) { // we search for variables only if not already set
// if (
// strncasecmp(query_digest_text,"SELECT @@tx_isolation", strlen("SELECT @@tx_isolation"))
@ -2757,41 +2743,9 @@ void MySQL_Connection::ProcessQueryAndSetStatusFlags(char *query_digest_text) {
}
}
}
if (get_status(STATUS_MYSQL_CONNECTION_PREPARED_STATEMENT)==false) { // we search if prepared was already executed
if (!strncasecmp(query_digest_text,"PREPARE ", strlen("PREPARE "))) {
set_status(true, STATUS_MYSQL_CONNECTION_PREPARED_STATEMENT);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_TEMPORARY_TABLE)==false) { // we search for temporary if not already set
if (!strncasecmp(query_digest_text,"CREATE TEMPORARY TABLE ", strlen("CREATE TEMPORARY TABLE "))) {
set_status(true, STATUS_MYSQL_CONNECTION_TEMPORARY_TABLE);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_LOCK_TABLES)==false) { // we search for lock tables only if not already set
if (!strncasecmp(query_digest_text,"LOCK TABLE", strlen("LOCK TABLE"))) {
set_status(true, STATUS_MYSQL_CONNECTION_LOCK_TABLES);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_LOCK_TABLES)==false) { // we search for lock tables only if not already set
if (!strncasecmp(query_digest_text,"FLUSH TABLES WITH READ LOCK", strlen("FLUSH TABLES WITH READ LOCK"))) { // issue 613
set_status(true, STATUS_MYSQL_CONNECTION_LOCK_TABLES);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_LOCK_TABLES)==true) {
if (!strncasecmp(query_digest_text,"UNLOCK TABLES", strlen("UNLOCK TABLES"))) {
set_status(false, STATUS_MYSQL_CONNECTION_LOCK_TABLES);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_GET_LOCK)==false) { // we search for get_lock if not already set
if (strcasestr(query_digest_text,"GET_LOCK(")) {
set_status(true, STATUS_MYSQL_CONNECTION_GET_LOCK);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_FOUND_ROWS)==false) { // we search for SQL_CALC_FOUND_ROWS if not already set
if (strcasestr(query_digest_text,"SQL_CALC_FOUND_ROWS")) {
set_status(true, STATUS_MYSQL_CONNECTION_FOUND_ROWS);
}
}
}
void MySQL_Connection::ProcessQueryAndSetStatusFlags_Savepoint(char *query_digest_text) {
if (get_status(STATUS_MYSQL_CONNECTION_HAS_SAVEPOINT)==false) {
if (mysql) {
if (
@ -2821,6 +2775,9 @@ void MySQL_Connection::ProcessQueryAndSetStatusFlags(char *query_digest_text) {
set_status(false, STATUS_MYSQL_CONNECTION_HAS_SAVEPOINT);
}
}
}
void MySQL_Connection::ProcessQueryAndSetStatusFlags_SetBackslashEscapes() {
if (mysql) {
if (myds && myds->sess) {
if (myds->sess->client_myds && myds->sess->client_myds->myconn) {
@ -2834,6 +2791,71 @@ void MySQL_Connection::ProcessQueryAndSetStatusFlags(char *query_digest_text) {
}
}
void MySQL_Connection::ProcessQueryAndSetStatusFlags(char *query_digest_text) {
if (query_digest_text==NULL) return;
// unknown what to do with multiplex
int mul=-1;
if (myds) {
if (myds->sess) {
if (myds->sess->qpo) {
mul=myds->sess->qpo->multiplex;
if (mul==0) {
set_status(true, STATUS_MYSQL_CONNECTION_NO_MULTIPLEX);
} else {
if (mul==1) {
set_status(false, STATUS_MYSQL_CONNECTION_NO_MULTIPLEX);
}
}
}
}
}
ProcessQueryAndSetStatusFlags_Warnings(query_digest_text);
ProcessQueryAndSetStatusFlags_UserVariables(query_digest_text, mul);
if (get_status(STATUS_MYSQL_CONNECTION_PREPARED_STATEMENT)==false) { // we search if prepared was already executed
if (!strncasecmp(query_digest_text,"PREPARE ", strlen("PREPARE "))) {
set_status(true, STATUS_MYSQL_CONNECTION_PREPARED_STATEMENT);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_TEMPORARY_TABLE)==false) { // we search for temporary if not already set
if (!strncasecmp(query_digest_text,"CREATE TEMPORARY TABLE ", strlen("CREATE TEMPORARY TABLE "))) {
set_status(true, STATUS_MYSQL_CONNECTION_TEMPORARY_TABLE);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_LOCK_TABLES)==false) { // we search for lock tables only if not already set
if (!strncasecmp(query_digest_text,"LOCK TABLE", strlen("LOCK TABLE"))) {
set_status(true, STATUS_MYSQL_CONNECTION_LOCK_TABLES);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_LOCK_TABLES)==false) { // we search for lock tables only if not already set
if (!strncasecmp(query_digest_text,"FLUSH TABLES WITH READ LOCK", strlen("FLUSH TABLES WITH READ LOCK"))) { // issue 613
set_status(true, STATUS_MYSQL_CONNECTION_LOCK_TABLES);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_LOCK_TABLES)==true) {
if (!strncasecmp(query_digest_text,"UNLOCK TABLES", strlen("UNLOCK TABLES"))) {
set_status(false, STATUS_MYSQL_CONNECTION_LOCK_TABLES);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_GET_LOCK)==false) { // we search for get_lock if not already set
if (strcasestr(query_digest_text,"GET_LOCK(")) {
set_status(true, STATUS_MYSQL_CONNECTION_GET_LOCK);
}
}
if (get_status(STATUS_MYSQL_CONNECTION_FOUND_ROWS)==false) { // we search for SQL_CALC_FOUND_ROWS if not already set
if (strcasestr(query_digest_text,"SQL_CALC_FOUND_ROWS")) {
set_status(true, STATUS_MYSQL_CONNECTION_FOUND_ROWS);
}
}
ProcessQueryAndSetStatusFlags_Savepoint(query_digest_text);
ProcessQueryAndSetStatusFlags_SetBackslashEscapes();
}
void MySQL_Connection::optimize() {
if (mysql->net.max_packet > 65536) { // FIXME: temporary, maybe for very long time . This needs to become a global variable
if ( ( mysql->net.buff == mysql->net.read_pos ) && ( mysql->net.read_pos == mysql->net.write_pos ) ) {

Loading…
Cancel
Save