MDEV-31064 Changes in a SP are not immediately seen in I_S.parameters

If procedure is changed in one connection, and other procedure has
already called the initial version of the procedure, the query to
INFORMATION_SCHEMA.PARAMETERS would use obsolete information from sp
cache for that connection. That happens because cache invalidating
method only increments cache version, and does not flush (all) the
cache(s), and changing of a procedure only invalidates cache, and
removes the procedure's cache entry from local thread cache only.

The fix adds the check if sp info obtained from the cache for forming of
results for the query to I_S, is not obsoleted, and does not use it, if
it is.

The test has been added to main.information_schema. It changes the SP in
one connection, and ensures, that the change is seen in the query to the
I_S.PARAMETERS in other connection, that already has called the
procedure before the change.
This commit is contained in:
Lawrin Novitsky 2023-05-22 15:07:05 +02:00
parent 8fb863e6a4
commit 02cd3675c4
3 changed files with 47 additions and 1 deletions

View File

@ -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
#

View File

@ -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 #

View File

@ -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;
}