Commit e1c2646a authored by unknown's avatar unknown

prohibit opening Query cache for SP cursors (BUG#9715)


mysql-test/r/query_cache.result:
  testing cursors in SP with QC
  testing suspicious but working using selects in function with QC
mysql-test/t/query_cache.test:
  testing cursors in SP with QC
  testing suspicious but working using selects in function with QC
sql/sp_head.h:
  method for prohibiting of QC using SP query
sql/sp_rcontext.cc:
  prohibit opening Query cache for SP cursors
sql/sp_rcontext.h:
  constructor moved to .cc file to be able to use methods from lex_keeper
parent d5600efd
This diff is collapsed.
......@@ -756,4 +756,36 @@ flush query cache;
drop table t1, t2;
#
# SP cursors and selects with query cache (BUG#9715)
#
create table t1 (a int);
insert into t1 values (1),(2);
delimiter //;
CREATE PROCEDURE `p1`()
begin
Declare c1 cursor for select a from t1;
open c1;
select * from t1;
end//
call p1()//
drop procedure p1;
create function f1() returns int
begin
Declare var1 int;
select max(a) from t1 into var1;
return var1;
end//
create procedure `p1`()
begin
select a, f1() from t1;
end//
call p1()//
drop procedure p1//
drop table t1//
delimiter ;//
set GLOBAL query_cache_size=0;
......@@ -377,6 +377,10 @@ public:
return (uint)m_lex->sql_command;
}
void disable_query_cache()
{
m_lex->safe_to_cache_query= 0;
}
private:
LEX *m_lex;
......
......@@ -169,6 +169,17 @@ sp_rcontext::pop_cursors(uint count)
*
*/
sp_cursor::sp_cursor(sp_lex_keeper *lex_keeper)
:m_lex_keeper(lex_keeper), m_prot(NULL), m_isopen(0), m_current_row(NULL)
{
/*
currsor can't be stored in QC, so we should prevent opening QC for
try to write results which are absent.
*/
lex_keeper->disable_query_cache();
}
/*
pre_open cursor
......
......@@ -203,11 +203,7 @@ class sp_cursor : public Sql_alloc
{
public:
sp_cursor(sp_lex_keeper *lex_keeper)
: m_lex_keeper(lex_keeper), m_prot(NULL), m_isopen(0), m_current_row(NULL)
{
/* Empty */
}
sp_cursor(sp_lex_keeper *lex_keeper);
virtual ~sp_cursor()
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment