1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-17124: mariadb 10.1.34, views and prepared statements: ERROR 1615 (HY000): Prepared statement needs to be re-prepared

The problem is that if table definition cache (TDC) is full of real tables
which are in tables cache, view definition can not stay there so will be
removed by its own underlying tables.
In situation above old mechanism of detection matching definition in PS
and current version always require reprepare and so prevent executing
the PS.

One work around is to increase TDC, other - improve version check for
views/triggers (which is done here). Now in suspicious cases we check:
 - timestamp (microseconds) of the view to be sure that version really
   have changed;
 - time (microseconds) of creation of a trigger related to time
   (microseconds) of statement preparation.
This commit is contained in:
Oleksandr Byelkin
2019-04-17 15:50:59 +02:00
parent 98e62e6317
commit f65ba9aeb7
16 changed files with 329 additions and 74 deletions

View File

@ -250,7 +250,8 @@ drop trigger t1_bd;
set @val=11;
execute stmt using @val;
call p_verify_reprepare_count(1);
# No trigger in opened table => nothing to check => no reprepare
call p_verify_reprepare_count(0);
select @message;
--echo Test 6-e: removing a relevant trigger
@ -259,7 +260,8 @@ drop trigger t1_bi;
set @val=12;
execute stmt using @val;
call p_verify_reprepare_count(1);
# No trigger in opened table => nothing to check => no reprepare
call p_verify_reprepare_count(0);
select @message;
set @val=13;
execute stmt using @val;
@ -374,7 +376,8 @@ select * from t3;
flush table t1;
set @var=9;
execute stmt using @var;
call p_verify_reprepare_count(1);
# flush tables now do not mean reprepare
call p_verify_reprepare_count(0);
select * from t2;
select * from t3;
drop view v1;
@ -743,7 +746,7 @@ call p_verify_reprepare_count(1);
flush table t2;
execute stmt;
call p_verify_reprepare_count(1);
call p_verify_reprepare_count(0);
--echo # Check that we properly handle ALTER VIEW statements.
execute stmt;
@ -967,7 +970,8 @@ drop trigger v2_bi;
set @message=null;
set @var=9;
execute stmt using @var;
call p_verify_reprepare_count(1);
# No trigger in opened table => nothing to check => no reprepare
call p_verify_reprepare_count(0);
select @message;
create trigger v2_bi after insert on v2 for each row set @message="v2_ai";
set @var= 10;