Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SQLCancel not going through proxy #135

Merged
merged 3 commits into from
Apr 12, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions driver/execute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1976,13 +1976,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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can we add a space between the two arguments

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 @@ -1992,15 +1990,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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: inconsistent indentation here.

/* 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;
}