Bug #35389 Statement drops on setting name of prepared statement that already exists
Submitted: 18 Mar 2008 10:54 Modified: 18 Mar 2008 11:14
Reporter: Salman Rawala Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.1.22 OS:Windows
Assigned to: CPU Architecture:Any

[18 Mar 2008 10:54] Salman Rawala
Description:
A pre-existing valid prepared statement DROPS if a PREPARE STATEMENT command is issued with the same name that causes ER_MAX_PREPARED_STMT_COUNT_REACHED error

How to repeat:
SET GLOBAL max_prepared_stmt_count=2;
** Prepare statements **
PREPARE stmt  from "SELECT * FROM information_schema.CHARACTER_SETS C";
PREPARE stmt1 from "SELECT * FROM information_schema.CHARACTER_SETS C";

SHOW STATUS like 'Prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	2
## 2 Expected ##

SET GLOBAL max_prepared_stmt_count=0;

SHOW STATUS like 'Prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	2
## 2 Expected ##

PREPARE stmt1  from "SELECT * FROM information_schema.CHARACTER_SETS C";

Expected error "Max prepared statements count reached"
SHOW STATUS like 'Prepared_stmt_count';
Variable_name	Value
Prepared_stmt_count	1
## 2 Expected ##

Bug: In this case we have tried to prepare statement with the name "stmt1" that already exists and this try drops the previously created 'stmt1' statement
[18 Mar 2008 11:14] Valeriy Kravchuk
I think, this is not a bug formally. Please, read the manual, http://dev.mysql.com/doc/refman/5.1/en/sqlps.html:

"If a prepared statement with the given name already exists, it is deallocated implicitly before the new statement is prepared."