You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
Fix for CONC-633:
If prepare step failed in mariadb_stmt_execute_direct now both mysql_stmt_error and mysql_error return the error message from prepare step instead of error message of execute.
This commit is contained in:
@@ -2569,7 +2569,14 @@ fail:
|
|||||||
stmt->mysql->methods->db_stmt_flush_unbuffered(stmt);
|
stmt->mysql->methods->db_stmt_flush_unbuffered(stmt);
|
||||||
} while(mysql_stmt_more_results(stmt));
|
} while(mysql_stmt_more_results(stmt));
|
||||||
}
|
}
|
||||||
stmt->state= MYSQL_STMT_INITTED;
|
|
||||||
|
/* CONC-633: If prepare returned an error, we ignore error from execute */
|
||||||
|
if (mysql_stmt_errno(stmt))
|
||||||
|
{
|
||||||
|
my_set_error(mysql, mysql_stmt_errno(stmt), mysql_stmt_sqlstate(stmt),
|
||||||
|
mysql_stmt_error(stmt));
|
||||||
|
stmt->state= MYSQL_STMT_INITTED;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5507,7 +5507,83 @@ static int test_conc627(MYSQL *mysql)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_conc633(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||||
|
MYSQL *my= mysql_init(NULL);
|
||||||
|
int ret= FAIL;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (!mariadb_stmt_execute_direct(stmt, SL("SÄLECT 1")))
|
||||||
|
{
|
||||||
|
diag("Syntax error expected");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mysql_errno(mysql) != mysql_stmt_errno(stmt))
|
||||||
|
{
|
||||||
|
diag("Different error codes. mysql_errno= %d, mysql_stmt_errno=%d",
|
||||||
|
mysql_errno(mysql), mysql_stmt_errno(stmt));
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((long)stmt->stmt_id != -1)
|
||||||
|
{
|
||||||
|
diag("Error: expected stmt_id=-1");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(my= test_connect(NULL)))
|
||||||
|
{
|
||||||
|
diag("Can establish connection (%s)", mysql_error(my));
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc= mysql_query(my, "CREATE OR REPLACE TABLE conc633 (a int)");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "SET @@lock_wait_timeout=3");
|
||||||
|
|
||||||
|
rc= mysql_query(my, "LOCK TABLES conc633 WRITE");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "SET @@lock_wait_timeout=3");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
if (!mariadb_stmt_execute_direct(stmt, SL("INSERT INTO conc633 VALUES (1)")))
|
||||||
|
{
|
||||||
|
diag("lock wait timeout error expected");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stmt->state != MYSQL_STMT_PREPARED)
|
||||||
|
{
|
||||||
|
diag("Error: stmt hasn't prepared status");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((long)stmt->stmt_id == -1)
|
||||||
|
{
|
||||||
|
diag("Error: no stmt_id assigned");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc= mysql_query(my, "UNLOCK TABLES");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
rc= mysql_query(my, "DROP TABLE conc633");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
ret= OK;
|
||||||
|
|
||||||
|
end:
|
||||||
|
if (my)
|
||||||
|
mysql_close(my);
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
{"test_conc633", test_conc633, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_conc627", test_conc627, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_conc627", test_conc627, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_mdev19838", test_mdev19838, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_mdev19838", test_mdev19838, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_conc566", test_conc566, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_conc566", test_conc566, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
|
Reference in New Issue
Block a user