mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-4.1-bug23159
into moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug23159 mysql-test/r/ps.result: Manual merge. mysql-test/t/ps.test: Manual merge. sql/mysqld.cc: Manual merge. sql/set_var.cc: Manual merge.
This commit is contained in:
@ -795,12 +795,12 @@ set @old_max_prepared_stmt_count= @@max_prepared_stmt_count;
|
||||
show variables like 'max_prepared_stmt_count';
|
||||
Variable_name Value
|
||||
max_prepared_stmt_count 16382
|
||||
show variables like 'prepared_stmt_count';
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
prepared_stmt_count 0
|
||||
select @@max_prepared_stmt_count, @@prepared_stmt_count;
|
||||
@@max_prepared_stmt_count @@prepared_stmt_count
|
||||
16382 0
|
||||
Prepared_stmt_count 0
|
||||
select @@max_prepared_stmt_count;
|
||||
@@max_prepared_stmt_count
|
||||
16382
|
||||
set global max_prepared_stmt_count=-1;
|
||||
select @@max_prepared_stmt_count;
|
||||
@@max_prepared_stmt_count
|
||||
@ -819,81 +819,84 @@ set max_prepared_stmt_count=1;
|
||||
ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
set local max_prepared_stmt_count=1;
|
||||
ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
set local prepared_stmt_count=0;
|
||||
ERROR HY000: Variable 'prepared_stmt_count' is a read only variable
|
||||
set @@prepared_stmt_count=0;
|
||||
ERROR HY000: Variable 'prepared_stmt_count' is a read only variable
|
||||
set global prepared_stmt_count=1;
|
||||
ERROR HY000: Variable 'prepared_stmt_count' is a read only variable
|
||||
set global max_prepared_stmt_count=1;
|
||||
select @@max_prepared_stmt_count;
|
||||
@@max_prepared_stmt_count
|
||||
1
|
||||
set global max_prepared_stmt_count=0;
|
||||
select @@max_prepared_stmt_count, @@prepared_stmt_count;
|
||||
@@max_prepared_stmt_count @@prepared_stmt_count
|
||||
0 0
|
||||
prepare stmt from "select 1";
|
||||
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
|
||||
select @@prepared_stmt_count;
|
||||
@@prepared_stmt_count
|
||||
select @@max_prepared_stmt_count;
|
||||
@@max_prepared_stmt_count
|
||||
0
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 0
|
||||
prepare stmt from "select 1";
|
||||
ERROR HY000: Unknown error
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 0
|
||||
set global max_prepared_stmt_count=1;
|
||||
prepare stmt from "select 1";
|
||||
select @@prepared_stmt_count;
|
||||
@@prepared_stmt_count
|
||||
1
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 1
|
||||
prepare stmt1 from "select 1";
|
||||
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 1)
|
||||
select @@prepared_stmt_count;
|
||||
@@prepared_stmt_count
|
||||
1
|
||||
ERROR HY000: Unknown error
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 1
|
||||
deallocate prepare stmt;
|
||||
select @@prepared_stmt_count;
|
||||
@@prepared_stmt_count
|
||||
0
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 0
|
||||
prepare stmt from "select 1";
|
||||
select @@prepared_stmt_count;
|
||||
@@prepared_stmt_count
|
||||
1
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 1
|
||||
prepare stmt from "select 2";
|
||||
select @@prepared_stmt_count;
|
||||
@@prepared_stmt_count
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 1
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 1
|
||||
select @@max_prepared_stmt_count;
|
||||
@@max_prepared_stmt_count
|
||||
1
|
||||
select @@prepared_stmt_count, @@max_prepared_stmt_count;
|
||||
@@prepared_stmt_count @@max_prepared_stmt_count
|
||||
1 1
|
||||
set global max_prepared_stmt_count=0;
|
||||
prepare stmt from "select 1";
|
||||
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
|
||||
ERROR HY000: Unknown error
|
||||
execute stmt;
|
||||
ERROR HY000: Unknown prepared statement handler (stmt) given to EXECUTE
|
||||
select @@prepared_stmt_count;
|
||||
@@prepared_stmt_count
|
||||
0
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 0
|
||||
prepare stmt from "select 1";
|
||||
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
|
||||
select @@prepared_stmt_count;
|
||||
@@prepared_stmt_count
|
||||
0
|
||||
ERROR HY000: Unknown error
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 0
|
||||
set global max_prepared_stmt_count=3;
|
||||
select @@max_prepared_stmt_count, @@prepared_stmt_count;
|
||||
@@max_prepared_stmt_count @@prepared_stmt_count
|
||||
3 0
|
||||
select @@max_prepared_stmt_count;
|
||||
@@max_prepared_stmt_count
|
||||
3
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 0
|
||||
prepare stmt from "select 1";
|
||||
prepare stmt from "select 2";
|
||||
prepare stmt1 from "select 3";
|
||||
prepare stmt2 from "select 4";
|
||||
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3)
|
||||
ERROR HY000: Unknown error
|
||||
prepare stmt2 from "select 4";
|
||||
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3)
|
||||
select @@max_prepared_stmt_count, @@prepared_stmt_count;
|
||||
@@max_prepared_stmt_count @@prepared_stmt_count
|
||||
3 3
|
||||
ERROR HY000: Unknown error
|
||||
select @@max_prepared_stmt_count;
|
||||
@@max_prepared_stmt_count
|
||||
3
|
||||
show status like 'prepared_stmt_count';
|
||||
Variable_name Value
|
||||
Prepared_stmt_count 3
|
||||
deallocate prepare stmt;
|
||||
select @@max_prepared_stmt_count, @@prepared_stmt_count;
|
||||
@@max_prepared_stmt_count @@prepared_stmt_count
|
||||
3 0
|
||||
set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
|
||||
drop table if exists t1;
|
||||
create temporary table if not exists t1 (a1 int);
|
||||
|
@ -848,6 +848,9 @@ drop table t1;
|
||||
# Bug#16365 Prepared Statements: DoS with too many open statements
|
||||
# Check that the limit @@max_prpeared_stmt_count works.
|
||||
#
|
||||
# This is also the test for bug#23159 prepared_stmt_count should be
|
||||
# status variable.
|
||||
#
|
||||
# Save the old value
|
||||
set @old_max_prepared_stmt_count= @@max_prepared_stmt_count;
|
||||
#
|
||||
@ -857,17 +860,17 @@ set @old_max_prepared_stmt_count= @@max_prepared_stmt_count;
|
||||
#
|
||||
--disable_ps_protocol
|
||||
#
|
||||
# A. Check that the new variables are present in SHOW VARIABLES list.
|
||||
# A. Check that the new variables are present in SHOW VARIABLES and
|
||||
# SHOW STATUS lists.
|
||||
#
|
||||
show variables like 'max_prepared_stmt_count';
|
||||
show variables like 'prepared_stmt_count';
|
||||
show status like 'prepared_stmt_count';
|
||||
#
|
||||
# B. Check that the new variables are selectable.
|
||||
# B. Check that the new system variable is selectable.
|
||||
#
|
||||
select @@max_prepared_stmt_count, @@prepared_stmt_count;
|
||||
select @@max_prepared_stmt_count;
|
||||
#
|
||||
# C. Check that max_prepared_stmt_count is settable (global only),
|
||||
# whereas prepared_stmt_count is readonly.
|
||||
# C. Check that max_prepared_stmt_count is settable (global only).
|
||||
#
|
||||
set global max_prepared_stmt_count=-1;
|
||||
select @@max_prepared_stmt_count;
|
||||
@ -875,18 +878,12 @@ set global max_prepared_stmt_count=10000000000000000;
|
||||
select @@max_prepared_stmt_count;
|
||||
set global max_prepared_stmt_count=default;
|
||||
select @@max_prepared_stmt_count;
|
||||
--error ER_GLOBAL_VARIABLE
|
||||
--error 1229 # ER_GLOBAL_VARIABLE
|
||||
set @@max_prepared_stmt_count=1;
|
||||
--error ER_GLOBAL_VARIABLE
|
||||
--error 1229 # ER_GLOBAL_VARIABLE
|
||||
set max_prepared_stmt_count=1;
|
||||
--error ER_GLOBAL_VARIABLE
|
||||
--error 1229 # ER_GLOBAL_VARIABLE
|
||||
set local max_prepared_stmt_count=1;
|
||||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
|
||||
set local prepared_stmt_count=0;
|
||||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
|
||||
set @@prepared_stmt_count=0;
|
||||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
|
||||
set global prepared_stmt_count=1;
|
||||
# set to a reasonable limit works
|
||||
set global max_prepared_stmt_count=1;
|
||||
select @@max_prepared_stmt_count;
|
||||
@ -894,75 +891,72 @@ select @@max_prepared_stmt_count;
|
||||
# D. Check that the variables actually work.
|
||||
#
|
||||
set global max_prepared_stmt_count=0;
|
||||
select @@max_prepared_stmt_count, @@prepared_stmt_count;
|
||||
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
|
||||
select @@max_prepared_stmt_count;
|
||||
show status like 'prepared_stmt_count';
|
||||
--error 1105 # ER_UNKNOWN_ERROR
|
||||
prepare stmt from "select 1";
|
||||
select @@prepared_stmt_count;
|
||||
show status like 'prepared_stmt_count';
|
||||
set global max_prepared_stmt_count=1;
|
||||
prepare stmt from "select 1";
|
||||
select @@prepared_stmt_count;
|
||||
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
|
||||
show status like 'prepared_stmt_count';
|
||||
--error 1105 # ER_UNKNOWN_ERROR
|
||||
prepare stmt1 from "select 1";
|
||||
select @@prepared_stmt_count;
|
||||
show status like 'prepared_stmt_count';
|
||||
deallocate prepare stmt;
|
||||
select @@prepared_stmt_count;
|
||||
show status like 'prepared_stmt_count';
|
||||
#
|
||||
# E. Check that we can prepare a statement with the same name
|
||||
# successfully, without hitting the limit.
|
||||
#
|
||||
prepare stmt from "select 1";
|
||||
select @@prepared_stmt_count;
|
||||
show status like 'prepared_stmt_count';
|
||||
prepare stmt from "select 2";
|
||||
select @@prepared_stmt_count;
|
||||
show status like 'prepared_stmt_count';
|
||||
#
|
||||
# F. We can set the max below the current count. In this case no new
|
||||
# statements should be allowed to prepare.
|
||||
#
|
||||
select @@prepared_stmt_count, @@max_prepared_stmt_count;
|
||||
show status like 'prepared_stmt_count';
|
||||
select @@max_prepared_stmt_count;
|
||||
set global max_prepared_stmt_count=0;
|
||||
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
|
||||
--error 1105 # ER_UNKNOWN_ERROR
|
||||
prepare stmt from "select 1";
|
||||
# Result: the old statement is deallocated, the new is not created.
|
||||
--error 1243 # ER_UNKNOWN_STMT_HANDLER
|
||||
execute stmt;
|
||||
select @@prepared_stmt_count;
|
||||
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
|
||||
show status like 'prepared_stmt_count';
|
||||
--error 1105 # ER_UNKNOWN_ERROR
|
||||
prepare stmt from "select 1";
|
||||
select @@prepared_stmt_count;
|
||||
show status like 'prepared_stmt_count';
|
||||
#
|
||||
# G. Show that the variables are up to date even after a connection with all
|
||||
# statements in it was terminated.
|
||||
#
|
||||
set global max_prepared_stmt_count=3;
|
||||
select @@max_prepared_stmt_count, @@prepared_stmt_count;
|
||||
select @@max_prepared_stmt_count;
|
||||
show status like 'prepared_stmt_count';
|
||||
prepare stmt from "select 1";
|
||||
connect (con1,localhost,root,,);
|
||||
connection con1;
|
||||
prepare stmt from "select 2";
|
||||
prepare stmt1 from "select 3";
|
||||
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
|
||||
--error 1105 # ER_UNKNOWN_ERROR
|
||||
prepare stmt2 from "select 4";
|
||||
connection default;
|
||||
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
|
||||
--error 1105 # ER_UNKNOWN_ERROR
|
||||
prepare stmt2 from "select 4";
|
||||
select @@max_prepared_stmt_count, @@prepared_stmt_count;
|
||||
select @@max_prepared_stmt_count;
|
||||
show status like 'prepared_stmt_count';
|
||||
disconnect con1;
|
||||
connection default;
|
||||
# Wait for the connection to die: deal with a possible race
|
||||
deallocate prepare stmt;
|
||||
let $count= `select @@prepared_stmt_count`;
|
||||
if ($count)
|
||||
{
|
||||
--sleep 2
|
||||
let $count= `select @@prepared_stmt_count`;
|
||||
}
|
||||
select @@max_prepared_stmt_count, @@prepared_stmt_count;
|
||||
#
|
||||
# Restore the old value.
|
||||
#
|
||||
set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
|
||||
--enable_ps_protocol
|
||||
|
||||
|
||||
#
|
||||
# Bug#19399 "Stored Procedures 'Lost Connection' when dropping/creating
|
||||
# tables"
|
||||
|
Reference in New Issue
Block a user