Skip to content

Commit 3d752f0

Browse files
committed
MDEV-16708: correct server side cursor detection in embedded
fixes a bunch of tests failures in --ps --embed also, don't use cli_advanced_command().
1 parent 12bcbfc commit 3d752f0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

libmysqld/libmysql.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
21322132
buff[4]= (char) stmt->flags;
21332133
int4store(buff+5, 1); /* iteration count */
21342134

2135-
res= MY_TEST(cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff),
2135+
res= MY_TEST((*mysql->methods->advanced_command)(mysql, COM_STMT_EXECUTE, buff, sizeof(buff),
21362136
(uchar*) packet, length, 1, stmt) ||
21372137
(*mysql->methods->read_query_result)(mysql));
21382138
stmt->affected_rows= mysql->affected_rows;
@@ -2524,9 +2524,16 @@ static void reinit_result_set_metadata(MYSQL_STMT *stmt)
25242524
}
25252525

25262526

2527+
static int has_cursor(MYSQL_STMT *stmt)
2528+
{
2529+
return stmt->server_status & SERVER_STATUS_CURSOR_EXISTS &&
2530+
stmt->flags & CURSOR_TYPE_READ_ONLY;
2531+
}
2532+
2533+
25272534
static void prepare_to_fetch_result(MYSQL_STMT *stmt)
25282535
{
2529-
if (stmt->server_status & SERVER_STATUS_CURSOR_EXISTS)
2536+
if (has_cursor(stmt))
25302537
{
25312538
stmt->mysql->status= MYSQL_STATUS_READY;
25322539
stmt->read_row_func= stmt_read_row_from_cursor;
@@ -4470,8 +4477,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
44704477
DBUG_RETURN(1);
44714478
}
44724479

4473-
if (mysql->status == MYSQL_STATUS_READY &&
4474-
stmt->server_status & SERVER_STATUS_CURSOR_EXISTS)
4480+
if (mysql->status == MYSQL_STATUS_READY && has_cursor(stmt))
44754481
{
44764482
/*
44774483
Server side cursor exist, tell server to start sending the rows
@@ -4483,7 +4489,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
44834489
/* Send row request to the server */
44844490
int4store(buff, stmt->stmt_id);
44854491
int4store(buff + 4, (int)~0); /* number of rows to fetch */
4486-
if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff),
4492+
if ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH, buff, sizeof(buff),
44874493
(uchar*) 0, 0, 1, stmt))
44884494
{
44894495
/*

0 commit comments

Comments
 (0)