Skip to content

Commit

Permalink
Disable multiplexing for SQL_CALC_FOUND_ROWS #732
Browse files Browse the repository at this point in the history
Port to 1.4.0
  • Loading branch information
renecannao committed Feb 27, 2017
1 parent 5689b9d commit 45cfb14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/mysql_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define STATUS_MYSQL_CONNECTION_GET_LOCK 0x00000040
#define STATUS_MYSQL_CONNECTION_NO_MULTIPLEX 0x00000080
#define STATUS_MYSQL_CONNECTION_SQL_LOG_BIN0 0x00000100
#define STATUS_MYSQL_CONNECTION_FOUND_ROWS 0x00000200

class MySQL_Connection_userinfo {
private:
Expand Down Expand Up @@ -103,6 +104,7 @@ class MySQL_Connection {
void set_status_user_variable(bool);
void set_status_no_multiplex(bool);
void set_status_sql_log_bin0(bool);
void set_status_found_rows(bool);
bool get_status_transaction();
bool get_status_compression();
bool get_status_get_lock();
Expand All @@ -112,6 +114,7 @@ class MySQL_Connection {
bool get_status_user_variable();
bool get_status_no_multiplex();
bool get_status_sql_log_bin0();
bool get_status_found_rows();
void connect_start();
void connect_cont(short event);
void change_user_start();
Expand Down
19 changes: 18 additions & 1 deletion lib/mysql_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ void MySQL_Connection::set_status_get_lock(bool v) {
}
}

void MySQL_Connection::set_status_found_rows(bool v) {
if (v) {
status_flags |= STATUS_MYSQL_CONNECTION_FOUND_ROWS;
} else {
status_flags &= ~STATUS_MYSQL_CONNECTION_FOUND_ROWS;
}
}

void MySQL_Connection::set_status_lock_tables(bool v) {
if (v) {
status_flags |= STATUS_MYSQL_CONNECTION_LOCK_TABLES;
Expand Down Expand Up @@ -315,6 +323,10 @@ bool MySQL_Connection::get_status_get_lock() {
return status_flags & STATUS_MYSQL_CONNECTION_GET_LOCK;
}

bool MySQL_Connection::get_status_found_rows() {
return status_flags & STATUS_MYSQL_CONNECTION_FOUND_ROWS;
}

bool MySQL_Connection::get_status_lock_tables() {
return status_flags & STATUS_MYSQL_CONNECTION_LOCK_TABLES;
}
Expand Down Expand Up @@ -1424,7 +1436,7 @@ bool MySQL_Connection::MultiplexDisabled() {
// status_flags stores information about the status of the connection
// can be used to determine if multiplexing can be enabled or not
bool ret=false;
if (status_flags & (STATUS_MYSQL_CONNECTION_TRANSACTION|STATUS_MYSQL_CONNECTION_USER_VARIABLE|STATUS_MYSQL_CONNECTION_PREPARED_STATEMENT|STATUS_MYSQL_CONNECTION_LOCK_TABLES|STATUS_MYSQL_CONNECTION_TEMPORARY_TABLE|STATUS_MYSQL_CONNECTION_GET_LOCK|STATUS_MYSQL_CONNECTION_NO_MULTIPLEX|STATUS_MYSQL_CONNECTION_SQL_LOG_BIN0) ) {
if (status_flags & (STATUS_MYSQL_CONNECTION_TRANSACTION|STATUS_MYSQL_CONNECTION_USER_VARIABLE|STATUS_MYSQL_CONNECTION_PREPARED_STATEMENT|STATUS_MYSQL_CONNECTION_LOCK_TABLES|STATUS_MYSQL_CONNECTION_TEMPORARY_TABLE|STATUS_MYSQL_CONNECTION_GET_LOCK|STATUS_MYSQL_CONNECTION_NO_MULTIPLEX|STATUS_MYSQL_CONNECTION_SQL_LOG_BIN0|STATUS_MYSQL_CONNECTION_FOUND_ROWS) ) {
ret=true;
}
return ret;
Expand Down Expand Up @@ -1484,6 +1496,11 @@ void MySQL_Connection::ProcessQueryAndSetStatusFlags(char *query_digest_text) {
set_status_get_lock(true);
}
}
if (get_status_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_found_rows(true);
}
}
if (myds) {
if (myds->sess) {
if (myds->sess->qpo) {
Expand Down

0 comments on commit 45cfb14

Please sign in to comment.