Skip to content

Commit

Permalink
Evaluate enforce_autocommit_on_reads on PS #899
Browse files Browse the repository at this point in the history
Variable mysql-enforce_autocommit_on_reads wasn't evaluate for prepared statements.
  • Loading branch information
renecannao committed Feb 12, 2017
1 parent eb52b2b commit 1fd968a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/MySQL_PreparedStatement.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class MySQL_STMT_Global_info {
int timeout;
int delay;
} properties;
bool is_select_NOT_for_update;
MYSQL_BIND **params; // seems unused (?)
MySQL_STMT_Global_info(uint32_t id, unsigned int h, char *u, char *s, char *q, unsigned int ql, MYSQL_STMT *stmt, uint64_t _h);
~MySQL_STMT_Global_info();
Expand Down
16 changes: 16 additions & 0 deletions lib/MySQL_PreparedStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,22 @@ MySQL_STMT_Global_info::MySQL_STMT_Global_info(uint32_t id, unsigned int h, char
compute_hash();
}

is_select_NOT_for_update=false;
{ // see bug #899 . Most of the code is borrowed from Query_Info::is_select_NOT_for_update()
if (ql>=7) {
if (strncasecmp(q,(char *)"SELECT ",7)==0) { // is a SELECT
is_select_NOT_for_update=true;
if (ql>=17) {
char *p=(char *)q;
p+=ql-11;
if (strncasecmp(p," FOR UPDATE",11)==0) { // is a SELECT FOR UPDATE
is_select_NOT_for_update=false;
}
}
}
}
}

// set default properties:
properties.cache_ttl=-1;
properties.timeout=-1;
Expand Down
3 changes: 3 additions & 0 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ char * Query_Info::get_digest_text() {
}

bool Query_Info::is_select_NOT_for_update() {
if (stmt_info) { // we are processing a prepared statement. We already have the information
return stmt_info->is_select_NOT_for_update;
}
// to avoid an expensive strlen() on the digest_text, we consider only the real query
if (QueryPointer==NULL) {
return false;
Expand Down

0 comments on commit 1fd968a

Please sign in to comment.