Bug #3053 delete stmt's deletes rows but returns an error
Submitted: 3 Mar 2004 3:00 Modified: 6 Mar 2004 6:43
Reporter: Ignacio Holgado Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.0 OS:Linux (SuSe linux)
Assigned to: CPU Architecture:Any

[3 Mar 2004 3:00] Ignacio Holgado
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.
[3 Mar 2004 6:44] Ignacio Holgado
The client and the server have the same 4.1.0 version

Apologies.
[6 Mar 2004 6:43] MySQL Verification Team
I tested this with 4.1.2 server and  4.1.2 client and my set of tables on Linux and it worked just fine.

There were many bugs fixed since 4.1.0 and 4.1.1. 

4.1.2 will be available in the couple of weeks.