Bug #4236 Server crash on attempt to execute non-prepared statement
Submitted: 21 Jun 2004 19:57 Modified: 22 Jun 2004 9:07
Reporter: Konstantin Osipov (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.3 OS:Any (All)
Assigned to: Konstantin Osipov CPU Architecture:Any

[21 Jun 2004 19:57] Konstantin Osipov
Description:
This statement sequence crashes 4.1.3 server:
*
    First part of this bug is that mysql_stmt_execute() of statement
    with statement id= 0 crashed server
  */
  stmt_text= "SELECT 1";
  /* We need to prepare statement to pass by possible check in libmysql */
  rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
  check_execute(stmt, rc);
  /* Hack to check that server works OK if statement wasn't found */
  backup.stmt_id= stmt->stmt_id;
  stmt->stmt_id= 0;
  rc= mysql_stmt_execute(stmt);
  assert(rc);
  /* Restore original statement id to be able to reprepare it */
  stmt->stmt_id= backup.stmt_id;

How to repeat:
See description above.

Suggested fix:
Fix Statement_map::find method to not check stmt->name if it's not found.
[21 Jun 2004 20:40] Konstantin Osipov
bk commit - 4.1 tree (konstantin:1.1947) BUG#4236
[22 Jun 2004 9:07] Konstantin Osipov
Fixed in 4.1.3