Bug #9308 mysql_stmt_execute, STMT_ATTR_CURSOR_TYPE, mysql_stmt_attr_set
Submitted: 21 Mar 2005 8:23 Modified: 21 Mar 2005 12:10
Reporter: Berto van de Kraats Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.2 (also 5.0.3) OS:Windows (windows and linux)
Assigned to: CPU Architecture:Any

[21 Mar 2005 8:23] Berto van de Kraats
Description:
on a windows machine the cpu goes to 100% (and stays that way)

on a linux machine you get error :"2013:Lost connection to MySQL server during query"

How to repeat:
the attached program can be used to reproduce the problem.

the problem occurs the second time the routine "select_statement()" is called on the mysql function "mysql_stmt_execute".

the problem does NOT occur if the where clause does NOT use the primary key of the table directly. If the primary key of the table is surrounded by a function, the problem also does NOT occur.

"select name from xxx where id=1"               ---> crashes     
"select name from xxx where round(id)=1"     ---> does not crash
"select name from xxx where name='aaa'"     ---> does not crash

if the test table does not contain a primary key, the system does not crash either.

My conclusion is that the problem only occurs if the table has a primary key and the where clause uses this primary key.

remark:

the problem does not occur at all if following statement is not used:

mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void *) &type);

However we need this cursor mode for the baan-driver of mysql to enable the multiple cursor scenario.
[21 Mar 2005 8:25] Berto van de Kraats
simple program to reproduce bug

Attachment: bug1.c (application/octet-stream, text), 3.17 KiB.

[21 Mar 2005 12:10] MySQL Verification Team
It is related to the same cause as bug: http://bugs.mysql.com/bug.php?id=9159

According call stack below. Thank you for the bug report

>	mysqld.exe!free_items(Item * item=0xa5a5a5a5)  Line 1259 + 0x3	C++
 	mysqld.exe!Cursor::~Cursor()  Line 1968 + 0xc	C++
 	mysqld.exe!Prepared_statement::~Prepared_statement()  Line 2418	C++
 	mysqld.exe!Prepared_statement::`scalar deleting destructor'(unsigned int __flags=1)  + 0xf	C++
 	mysqld.exe!delete_statement_as_hash_key(void * key=0x02fbc258)  Line 1662 + 0x1f	C++
 	mysqld.exe!hash_delete(st_hash * hash=0x00efa58c, unsigned char * record=0x02fbc258)  Line 492 + 0xa	C
 	mysqld.exe!Statement_map::erase(Statement * statement=0x02fbc258)  Line 892 + 0xd	C++
 	mysqld.exe!mysql_stmt_free(THD * thd=0x00ef96b0, char * packet=0x02fca989)  Line 2301	C++
 	mysqld.exe!dispatch_command(enum_server_command command=COM_CLOSE_STMT, THD * thd=0x00ef96b0, char * packet=0x02fca989, unsigned int packet_length=5)  Line 1632 + 0xd	C++
 	mysqld.exe!do_command(THD * thd=0x00ef96b0)  Line 1453 + 0x31	C++
 	mysqld.exe!handle_one_connection(void * arg=0x00ef96b0)  Line 1110 + 0x9	C++
 	mysqld.exe!pthread_start(void * param=0x00e0bac0)  Line 63 + 0x7	C
 	mysqld.exe!_threadstart(void * ptd=0x02fb4130)  Line 173 + 0xd	C
 	kernel32.dll!7c80b50b() 	
 	kernel32.dll!7c8399f3()