Description:
When i launch a delete as : "delete from perfiles_servicios_tipologias where ID_PERFIL=68 and ID_SERVICIO=33" with the mysql_execute command the mysql_execute returns a non-zero value and the error message is : Error writing file 'linux-bin' (errno: 0)) and the rows affected by the sql delete command are deleted. The delete command runs ok but notifies and error. The message associated with "errno:0" is "success".
My C code is :
static
int __execute(SQL_CURSOR *cursor, int itera)
{
int status;
status = mysql_execute(cursor);
return status;
}
#define TRY(command1,command2) { int status=command1; if (status) { printf("Error ==> %d <==\n",status);command2;} }
int SQLexecute(SQL_CONNECTION *connection, const char *sql_stmt, int *auto_int, char **error)
{
SQL_CURSOR *cursor;
int type;
int i;
cursor = mysql_prepare(connection, sql_stmt, strlen(sql_stmt));
if (!cursor) { return -3; }
TRY( __execute(cursor,1), *error = strdup(SQLgetError(connection, cursor)); mysql_stmt_close(cursor); return -2;);
*auto_int = mysql_insert_id(connection);
i = __num_rows(cursor);
mysql_stmt_close(cursor);
return i;
}
char *SQLgetError(SQL_CONNECTION *connection, SQL_CURSOR *cursor)
{
if (connection) { return mysql_error(connection); }
return "Unknown error";
}
How to repeat:
- Install Mysql 4.1.1 in the server side.
- Install Mysql 4.1.0 in the client. ( i think the problem is not a incomptibility but we must be sure and the releases notes of 4.1.1 don't speak about this bug ) .
In the client execute:
char *sql_stmt = "delete from ... where ...";
stmt = mysql_prepare(connection, sql_stmt, strlen(sql_stmt));
if (mysql_execute(stmt))
{
printf("%s\n",mysql_error(connection));
}
Suggested fix:
The linux-bixXXX files and its directory have write permissions for the mysql linux user and the server can write.
- If the error is in the client side the delete command must not return an error.
- If the error is in the server side the server must not delete rows if the return code of the mysql_execute is different of 0.