1** Setup **
2
3SET @global_max_prepared_stmt_count = @@global.max_prepared_stmt_count;
4'#---------------------FN_DYNVARS_031_01----------------------#'
5SET GLOBAL max_prepared_stmt_count=2;
6** Prepare statements **
7PREPARE stmt  from "SELECT * FROM information_schema.CHARACTER_SETS C";
8PREPARE stmt1 from "SELECT * FROM information_schema.CHARACTER_SETS C";
9PREPARE stmt2 from "SELECT * FROM information_schema.CHARACTER_SETS C";
10ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 2)
11Expected error "Max prepared statements count reached"
12SHOW STATUS like 'Prepared_stmt_count';
13Variable_name	Value
14Prepared_stmt_count	2
152 Expected
16'#---------------------FN_DYNVARS_031_02----------------------#'
17SET GLOBAL max_prepared_stmt_count=0;
18PREPARE stmt3  from "SELECT * FROM information_schema.CHARACTER_SETS C";
19ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
20Expected error "Max prepared statements count reached"
21SHOW STATUS like 'Prepared_stmt_count';
22Variable_name	Value
23Prepared_stmt_count	2
242 Expected
25PREPARE stmt  from "SELECT * FROM information_schema.CHARACTER_SETS C";
26ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
27Expected error "Max prepared statements count reached"
28SHOW STATUS like 'Prepared_stmt_count';
29Variable_name	Value
30Prepared_stmt_count	1
312 Expected
32'Bug#35389 A pre existing valid prepared statement DROPS if a PREPARE'
33'STATEMENT command is issued with the same name that'
34'causes ER_MAX_PREPARED_STMT_COUNT_REACHED error'
35'#---------------------FN_DYNVARS_031_03----------------------#'
36SHOW STATUS like 'Prepared_stmt_count';
37Variable_name	Value
38Prepared_stmt_count	1
39SET GLOBAL max_prepared_stmt_count=4;
40PREPARE stmt from "SELECT * FROM information_schema.CHARACTER_SETS C";
41PREPARE stmt1 from "SELECT * FROM information_schema.CHARACTER_SETS C";
42PREPARE stmt2 from "SELECT * FROM information_schema.CHARACTER_SETS C";
43PREPARE stmt3 from "SELECT * FROM information_schema.CHARACTER_SETS C";
44** Value of prepared stmt'
45SHOW STATUS LIKE 'Prepared_stmt_count';
46Variable_name	Value
47Prepared_stmt_count	4
484 Expected
49'#---------------------FN_DYNVARS_031_04----------------------#'
50** preparing stmts **
51PREPARE stmt from "SELECT * FROM information_schema.CHARACTER_SETS C";
52PREPARE stmt1 from "SELECT * FROM information_schema.CHARACTER_SETS C";
53PREPARE stmt2 from "SELECT * FROM information_schema.CHARACTER_SETS C";
54** setting value **
55SET GLOBAL max_prepared_stmt_count=3;
56** Check wether any more statements can be  prepared **
57PREPARE stmt5 from "SELECT * FROM information_schema.CHARACTER_SETS C";
58ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3)
59Expected error "Max prepared statements count reached"
60SHOW STATUS LIKE 'Prepared_stmt_count';
61Variable_name	Value
62Prepared_stmt_count	4
634 Expected
64'#---------------------FN_DYNVARS_031_05----------------------#'
65SET GLOBAL max_prepared_stmt_count=3;
66** Creating procedure **
67DROP PROCEDURE  IF EXISTS  sp_checkstmts;
68Warnings:
69Note	1305	PROCEDURE test.sp_checkstmts does not exist
70CREATE PROCEDURE sp_checkstmts ()
71BEGIN
72PREPARE newstmt from "SELECT * FROM information_schema.CHARACTER_SETS C";
73END //
74CALL sp_checkstmts();
75ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3)
76Expected error "Max prepared statements count reached"
77DROP PREPARE stmt;
78DROP PREPARE stmt1;
79DROP PREPARE stmt2;
80DROP PREPARE stmt3;
81DROP PROCEDURE sp_checkstmts;
82SET @@global.max_prepared_stmt_count = @global_max_prepared_stmt_count;
83