Killed queries now return 1907 #750

pull/762/head
René Cannaò 10 years ago
parent 67f782bed8
commit bf6c93cb16

@ -180,7 +180,7 @@ class MySQL_Session
MySQL_Backend * find_or_create_backend(int, MySQL_Data_Stream *_myds=NULL);
void SQLite3_to_MySQL(SQLite3_result *, char *, int , MySQL_Protocol *);
void MySQL_Result_to_MySQL_wire(MYSQL *mysql, MySQL_ResultSet *MyRS);
void MySQL_Result_to_MySQL_wire(MYSQL *mysql, MySQL_ResultSet *MyRS, MySQL_Data_Stream *_myds=NULL);
void MySQL_Stmt_Result_to_MySQL_wire(MYSQL_STMT *stmt, MySQL_Connection *myconn);
unsigned int NumActiveTransactions();
int FindOneActiveTransaction();

@ -2183,9 +2183,13 @@ handler_again:
bool retry_conn=false;
switch (myerr) {
case 1317: // Query execution was interrupted
if (killed==true || myds->killed_at) {
if (killed==true) { // this session is being kiled
return -1;
}
if (myds->killed_at) {
// we intentionally killed the query
break;
}
case 1290: // read-only
case 1047: // WSREP has not yet prepared node for application use
case 1053: // Server shutdown in progress
@ -2225,7 +2229,7 @@ handler_again:
switch (status) {
case PROCESSING_QUERY:
MySQL_Result_to_MySQL_wire(myconn->mysql, myconn->MyRS);
MySQL_Result_to_MySQL_wire(myconn->mysql, myconn->MyRS, myds);
break;
case PROCESSING_STMT_PREPARE:
//MySQL_Result_to_MySQL_wire(myconn->mysql, myconn->MyRS, true);
@ -2912,7 +2916,7 @@ void MySQL_Session::MySQL_Stmt_Result_to_MySQL_wire(MYSQL_STMT *stmt, MySQL_Conn
}
}
void MySQL_Session::MySQL_Result_to_MySQL_wire(MYSQL *mysql, MySQL_ResultSet *MyRS) {
void MySQL_Session::MySQL_Result_to_MySQL_wire(MYSQL *mysql, MySQL_ResultSet *MyRS, MySQL_Data_Stream *_myds) {
if (MyRS) {
assert(MyRS->result);
bool transfer_started=MyRS->transfer_started;
@ -2955,8 +2959,12 @@ void MySQL_Session::MySQL_Result_to_MySQL_wire(MYSQL *mysql, MySQL_ResultSet *My
} else {
// error
char sqlstate[10];
sprintf(sqlstate,"#%s",mysql_sqlstate(mysql));
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,client_myds->pkt_sid+1,mysql_errno(mysql),sqlstate,mysql_error(mysql));
sprintf(sqlstate,"%s",mysql_sqlstate(mysql));
if (_myds && _myds->killed_at) { // see case #750
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,client_myds->pkt_sid+1,1907,sqlstate,"Query execution was interrupted, query_timeout exceeded");
} else {
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,client_myds->pkt_sid+1,mysql_errno(mysql),sqlstate,mysql_error(mysql));
}
client_myds->pkt_sid++;
}
}

Loading…
Cancel
Save