Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
2.1
-
None
-
None
-
All
Description
If you call mysql_stmt_send_long_data while the MYSQL* is in the wrong state, it returns the fact that there is an error, but no error code.
See line 1826 of my_stmt.c.
To correct, I think the conditional on line 1816 needs to be changed from:
if (stmt->mysql->status== MYSQL_STATUS_READY && (length || !stmt->params[param_number].long_data_used))
{
To:
if (stmt->mysql->status != MYSQL_STATUS_READY)
SET_CLIENT_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
DBUG_RETURN(1);
}
if (length || !stmt->params[param_number].long_data_used))
{
Hi Matt,
thanks for your bug report.
The extra check for status is redundant, since it will be checked in simple_command/mthd_my_send_cmd. To be compatible with libmysql we also should allow to pass a zero length buffer instead of returning an error.:
--- a/libmariadb/my_stmt.c
+++ b/libmariadb/my_stmt.c
@@ -1811,7 +1811,7 @@ my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
DBUG_RETURN(1);
}
- if (stmt->mysql->status== MYSQL_STATUS_READY && (length || !stmt->params[param_number].long_data_used))
+ if (length || !stmt->params[param_number].long_data_used)
{
int ret;
size_t packet_len;
@@ -1824,7 +1824,7 @@ my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
my_free(cmd_buff);
DBUG_RETURN(ret);
}
- DBUG_RETURN(1);
+ DBUG_RETURN(0);
}
my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt)