Bug #7407 "Unknown prepared statement handler" on Mac OS X
Submitted: 18 Dec 2004 16:57 Modified: 18 Dec 2004 17:24
Reporter: Peter Schäfer Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S1 (Critical)
Version:4.1.7 OS:MacOS (Mac OS X 10.2.8)
Assigned to: CPU Architecture:Any

[18 Dec 2004 16:57] Peter Schäfer
Description:
calling

  mysql_stmt_execute(stmt)

causes the following error:

  Unknown prepared statement handler (16777216) given to mysql_stmt_execute 

stmt->stmt_id is 1 before the call. 
However, the error reports stmt_id = 16777216 = 0x01000000

this error appears with the embedded library on Mac OS X, but not on Windows and Linux.

I suspect that there is some confusion between little-endian and big-endian integers.

Explictly setting stmt->stmt_id = 0x01000000 avoids the error, but it's not a solution, of course.

How to repeat:

  MYSQL_STMT* stmt = mysql_stmt_init(connection)
  mysql_stmt_prepare(...);

  fprintf(stderr,"stmt_id = %ux \n", stmt->stmt_id);
  // stmt_id == 1

  int error = mysql_stmt_execute(stmt);

  // error == 1243 
  // Unknown prepared statement handler (16777216) given to mysql_stmt_execute (HY000)

Suggested fix:
Statement_map seems not to work correctly with big-endian statement Id's.
[18 Dec 2004 17:03] Peter Schäfer
just found that this error has already been reported:

#7365
[18 Dec 2004 17:24] MySQL Verification Team
duplicate of #7365