[CONC-633] mariadb_stmt_execute_direct: mysql_error returns error from execute instead of prepare Created: 2023-02-06  Updated: 2023-05-02  Resolved: 2023-05-02

Status: Closed
Project: MariaDB Connector/C
Component/s: Prepared Statements
Affects Version/s: 3.1.19, 3.3.3
Fix Version/s: 3.1.21, 3.3.5

Type: Task Priority: Major
Reporter: Georg Richter Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None


 Description   

While mysql_stmt_error() returns the correct result from failing mysql_stmt_prepare(), mysql_error() returns the error from mysql_stmt_execute()

static int test_execute_direct_error(MYSQL *mysql)
{
  MYSQL_STMT *stmt= mysql_stmt_init(mysql);
  int rc;
 
  rc= mariadb_stmt_execute_direct(stmt, SL("SELECT SYNTAX_ERROR"));
  diag("stmt_error: %s", mysql_stmt_error(stmt))
  diag("mysql_error: %s", mysql_error(mysql))
  FAIL_IF(!rc, "Error expected")
 
  mysql_stmt_close(stmt);
  return OK;
}

Output:

# stmt_error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CALL P1()' at line 1
# mysql_error: Unknown prepared statement handler (4294967295) given to mysqld_stmt_execute



 Comments   
Comment by Georg Richter [ 2023-05-02 ]

commit 669726a1d9c00217403fe405bf8681c8949a8d5d

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.

Generated at Thu Feb 08 03:06:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.