mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-35953 mysql_stmt_errno() returns 0 after an error in mysql_stmt_execute()
The goal of the fix for MDEV-34718 was to avoid Diagnostics_area::reset_diagnostics_area() changing DA_OK_BULK to DA_EMPTY for bulk operations. But it was too indiscriminative and also didn't reset DA_ERROR if the bulk operation was in progress. This was leaving Diagnostics_area in the inconsistent state: the status was DA_ERROR, but sql_errno was 0. Fix it to reset the DA_ERROR status as reset_diagnostics_area() is supposed to do.
This commit is contained in:
@@ -318,18 +318,16 @@ Diagnostics_area::reset_diagnostics_area()
|
|||||||
#endif
|
#endif
|
||||||
get_warning_info()->clear_error_condition();
|
get_warning_info()->clear_error_condition();
|
||||||
set_is_sent(false);
|
set_is_sent(false);
|
||||||
/** Tiny reset in debug mode to see garbage right away */
|
/*
|
||||||
if (!is_bulk_op())
|
For BULK DML operations (e.g. UPDATE) the data member m_status
|
||||||
/*
|
has the value DA_OK_BULK. Keep this value in order to handle
|
||||||
For BULK DML operations (e.g. UPDATE) the data member m_status
|
m_affected_rows, m_statement_warn_count in correct way. Else,
|
||||||
has the value DA_OK_BULK. Keep this value in order to handle
|
the number of rows and the number of warnings affected by
|
||||||
m_affected_rows, m_statement_warn_count in correct way. Else,
|
the last statement executed as part of a trigger fired by the dml
|
||||||
the number of rows and the number of warnings affected by
|
(e.g. UPDATE statement fires a trigger on AFTER UPDATE) would counts
|
||||||
the last statement executed as part of a trigger fired by the dml
|
rows modified by trigger's statement.
|
||||||
(e.g. UPDATE statement fires a trigger on AFTER UPDATE) would counts
|
*/
|
||||||
rows modified by trigger's statement.
|
m_status= is_bulk_op() ? DA_OK_BULK : DA_EMPTY;
|
||||||
*/
|
|
||||||
m_status= DA_EMPTY;
|
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22886,8 +22886,58 @@ void test_mdev_10075()
|
|||||||
DIE_UNLESS(rc == 1);
|
DIE_UNLESS(rc == 1);
|
||||||
|
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
|
mysql_query(mysql, "drop table t1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void test_mdev35953()
|
||||||
|
{
|
||||||
|
#ifndef EMBEDDED_LIBRARY
|
||||||
|
int rc;
|
||||||
|
MYSQL_STMT *stmt;
|
||||||
|
MYSQL_BIND bind[1];
|
||||||
|
int vals[]= {1, 2}, count= array_elements(vals);
|
||||||
|
MYSQL *con= mysql_client_init(NULL);
|
||||||
|
DIE_UNLESS(con);
|
||||||
|
if (!mysql_real_connect(con, opt_host, opt_user, opt_password, current_db,
|
||||||
|
opt_port, opt_unix_socket, 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to connect to database: Error: %s\n",
|
||||||
|
mysql_error(con));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
rc= mysql_query(mysql, "create table t1 (a int)");
|
||||||
|
myquery(rc);
|
||||||
|
|
||||||
|
stmt= mysql_stmt_init(con);
|
||||||
|
rc= mysql_stmt_prepare(stmt, "insert into t1 (a) values (?)", -1);
|
||||||
|
check_execute(stmt, rc);
|
||||||
|
|
||||||
|
memset(bind, 0, sizeof(bind));
|
||||||
|
bind[0].buffer_type = MYSQL_TYPE_LONG;
|
||||||
|
bind[0].buffer = vals;
|
||||||
|
|
||||||
|
mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &count);
|
||||||
|
rc= mysql_stmt_bind_param(stmt, bind);
|
||||||
|
check_execute(stmt, rc);
|
||||||
|
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
check_execute(stmt, rc);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "alter table t1 add xx int");
|
||||||
|
myquery(rc);
|
||||||
|
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
check_execute(stmt, rc);
|
||||||
|
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
mysql_close(con);
|
||||||
|
|
||||||
|
mysql_query(mysql, "drop table t1");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct my_tests_st my_tests[]= {
|
static struct my_tests_st my_tests[]= {
|
||||||
{ "test_mdev_20516", test_mdev_20516 },
|
{ "test_mdev_20516", test_mdev_20516 },
|
||||||
{ "test_mdev24827", test_mdev24827 },
|
{ "test_mdev24827", test_mdev24827 },
|
||||||
@@ -23206,6 +23256,7 @@ static struct my_tests_st my_tests[]= {
|
|||||||
{ "test_mdev_34958", test_mdev_34958 },
|
{ "test_mdev_34958", test_mdev_34958 },
|
||||||
#endif
|
#endif
|
||||||
{ "test_mdev_10075", test_mdev_10075},
|
{ "test_mdev_10075", test_mdev_10075},
|
||||||
|
{ "test_mdev35953", test_mdev35953 },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user