diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result index 2160eee08a7..e17bb73d4e7 100644 --- a/mysql-test/main/information_schema.result +++ b/mysql-test/main/information_schema.result @@ -2401,3 +2401,25 @@ progress # # End of 10.3 tests # +# +# MDEV-MDEV-31064 Changes of the procedure are not immediatly seen in queries to I_S.parameter from other connections +# +CREATE PROCEDURE sp1(IN p1 INT, IN p2 INT) +BEGIN +END; +connect con2, localhost, root,,; +CALL sp1(10, 20); +connection default; +CREATE OR REPLACE PROCEDURE sp1(p1 INT) +BEGIN +END; +connection con2; +SELECT COUNT(*) FROM information_schema.parameters WHERE SPECIFIC_NAME = 'sp1'; +COUNT(*) +1 +disconnect con2; +connection default; +DROP PROCEDURE sp1; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/information_schema.test b/mysql-test/main/information_schema.test index b9ed6326350..7b5884ef6b5 100644 --- a/mysql-test/main/information_schema.test +++ b/mysql-test/main/information_schema.test @@ -2114,3 +2114,25 @@ select progress from information_schema.processlist limit 1; --echo # --echo # End of 10.3 tests --echo # + +--echo # +--echo # MDEV-MDEV-31064 Changes of the procedure are not immediatly seen in queries to I_S.parameter from other connections +--echo # +CREATE PROCEDURE sp1(IN p1 INT, IN p2 INT) +BEGIN +END; +--connect(con2, localhost, root,,) +CALL sp1(10, 20); +--connection default +CREATE OR REPLACE PROCEDURE sp1(p1 INT) +BEGIN +END; +--connection con2 +SELECT COUNT(*) FROM information_schema.parameters WHERE SPECIFIC_NAME = 'sp1'; +--disconnect con2 +--connection default +DROP PROCEDURE sp1; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/sql/sp.cc b/sql/sp.cc index af9c7901c5a..87af91187e7 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -3018,7 +3018,9 @@ Sp_handler::sp_load_for_information_schema(THD *thd, TABLE *proc_table, sp_cache **spc= get_cache(thd); sp_name sp_name_obj(&db, &name, true); // This can change "name" *free_sp_head= 0; - if ((sp= sp_cache_lookup(spc, &sp_name_obj))) + sp= sp_cache_lookup(spc, &sp_name_obj); + + if (sp && !(sp->sp_cache_version() < sp_cache_version())) { return sp; }