Skip to content

Commit

Permalink
Fix SQLCancel not going through proxy (#135)
Browse files Browse the repository at this point in the history
* fix SQLCancel not going through proxy

* cleanup ds during dbc clone

* spacing
  • Loading branch information
yanw-bq committed May 17, 2023
1 parent 61ffa13 commit 6b1b5ac
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions driver/execute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1965,13 +1965,11 @@ SQLRETURN SQL_API SQLCancel(SQLHSTMT hstmt)
interfere with the existing one. Therefore, locking is not needed in
the following block.
*/
second= mysql_init(second);
auto host = std::make_shared<HOST_INFO>((const char*)dbc->ds->server8, dbc->ds->port);
CONNECTION_PROXY* proxy = dbc->connection_handler->connect(host, dbc->ds);

/** @todo need to preserve and use ssl params */

if (!mysql_real_connect(second, (const char*)dbc->ds->server8, (const char*)dbc->ds->uid8,
(const char*)dbc->ds->pwd8, NULL, dbc->ds->port,
(const char*)dbc->ds->socket8, 0))
if (!proxy)
{
/* We do not set the SQLSTATE here, per the ODBC spec. */
return SQL_ERROR;
Expand All @@ -1981,15 +1979,16 @@ SQLRETURN SQL_API SQLCancel(SQLHSTMT hstmt)
char buff[40];
/* buff is always big enough because max length of %lu is 15 */
snprintf(buff, sizeof(buff), "KILL /*!50000 QUERY */ %lu", dbc->connection_proxy->thread_id());
if (mysql_real_query(second, buff, strlen(buff)))
if (proxy->real_query(buff, strlen(buff)))
{
mysql_close(second);
proxy->close();
/* We do not set the SQLSTATE here, per the ODBC spec. */
return SQL_ERROR;
}
}

mysql_close(second);
proxy->delete_ds();
delete proxy;

return SQL_SUCCESS;
}

0 comments on commit 6b1b5ac

Please sign in to comment.