From 2ab49689c689b1c1daeb080ea568c268c5256952 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 10 Jan 2015 14:07:46 +0100 Subject: [PATCH] MDEV-7410 Temporary table name conflict between sessions workaround for missing SP auto-reparse. allow the user to disable stored_program_cache_size, if he wants --- .../r/stored_program_cache_basic.result | 6 +-- .../r/stored_program_cache_func.result | 52 +++++++++++++++++++ .../sys_vars/t/stored_program_cache_func.test | 43 +++++++++++++++ sql/sys_vars.cc | 2 +- 4 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 mysql-test/suite/sys_vars/r/stored_program_cache_func.result create mode 100644 mysql-test/suite/sys_vars/t/stored_program_cache_func.test diff --git a/mysql-test/suite/sys_vars/r/stored_program_cache_basic.result b/mysql-test/suite/sys_vars/r/stored_program_cache_basic.result index f1638520f7225..7f882255567c0 100644 --- a/mysql-test/suite/sys_vars/r/stored_program_cache_basic.result +++ b/mysql-test/suite/sys_vars/r/stored_program_cache_basic.result @@ -23,7 +23,7 @@ Warnings: Warning 1292 Truncated incorrect stored_program_cache value: '-1' SELECT @@global.stored_program_cache; @@global.stored_program_cache -256 +0 SET @@global.stored_program_cache =100000000000; Warnings: Warning 1292 Truncated incorrect stored_program_cache value: '100000000000' @@ -31,11 +31,9 @@ SELECT @@global.stored_program_cache; @@global.stored_program_cache 524288 SET @@global.stored_program_cache = 0; -Warnings: -Warning 1292 Truncated incorrect stored_program_cache value: '0' SELECT @@global.stored_program_cache; @@global.stored_program_cache -256 +0 SET @@global.stored_program_cache = 10000.01; ERROR 42000: Incorrect argument type to variable 'stored_program_cache' SET @@global.stored_program_cache = ON; diff --git a/mysql-test/suite/sys_vars/r/stored_program_cache_func.result b/mysql-test/suite/sys_vars/r/stored_program_cache_func.result new file mode 100644 index 0000000000000..11151847d6b9d --- /dev/null +++ b/mysql-test/suite/sys_vars/r/stored_program_cache_func.result @@ -0,0 +1,52 @@ +create procedure p1() select 1; +flush status; +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 0 +call p1; +1 +1 +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 1 +call p1; +1 +1 +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 1 +set global stored_program_cache=0; +call p1; +1 +1 +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 2 +call p1; +1 +1 +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 3 +drop procedure p1; +set global stored_program_cache=default; +create procedure pr(i int) begin +create table t1 (a int, b int); +if (i = 1) then alter table t1 drop a; +else alter table t1 drop b; +end if; +select * from t1; +drop table t1; +end | +call pr(1); +b +call pr(2); +ERROR 42S22: Unknown column 'test.t1.b' in 'field list' +drop table t1; +set global stored_program_cache=0; +call pr(1); +b +call pr(2); +a +drop procedure pr; +set global stored_program_cache=default; diff --git a/mysql-test/suite/sys_vars/t/stored_program_cache_func.test b/mysql-test/suite/sys_vars/t/stored_program_cache_func.test new file mode 100644 index 0000000000000..f85fc8eb1bfb1 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/stored_program_cache_func.test @@ -0,0 +1,43 @@ +create procedure p1() select 1; + +flush status; +show status like 'handler_read_key'; +call p1; +show status like 'handler_read_key'; +call p1; +show status like 'handler_read_key'; + +set global stored_program_cache=0; + +call p1; +show status like 'handler_read_key'; +call p1; +show status like 'handler_read_key'; + +drop procedure p1; +set global stored_program_cache=default; + +# Test for missing SP automatic reparsing. +# when MDEV-5816 is implemented, it should be removed. + +--delimiter | +create procedure pr(i int) begin + create table t1 (a int, b int); + if (i = 1) then alter table t1 drop a; + else alter table t1 drop b; + end if; + select * from t1; + drop table t1; +end | +--delimiter ; +call pr(1); +--error ER_BAD_FIELD_ERROR +call pr(2); +drop table t1; + +set global stored_program_cache=0; +call pr(1); +call pr(2); +drop procedure pr; +set global stored_program_cache=default; + diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 7cad362f6f21e..47bf6baa46b02 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3679,7 +3679,7 @@ static Sys_var_ulong Sys_sp_cache_size( "The soft upper limit for number of cached stored routines for " "one connection.", GLOBAL_VAR(stored_program_cache_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(256, 512 * 1024), DEFAULT(256), BLOCK_SIZE(1)); + VALID_RANGE(0, 512 * 1024), DEFAULT(256), BLOCK_SIZE(1)); export const char *plugin_maturity_names[]= { "unknown", "experimental", "alpha", "beta", "gamma", "stable", 0 };