SET sql_mode=ORACLE;
DO GET_LOCK('lock',300);
connect  conn1,localhost,root,,;
SET sql_mode=ORACLE;
CREATE PACKAGE pkg1 AS
PROCEDURE p1;
FUNCTION f1 RETURN INT;
END;
$$
CREATE PACKAGE BODY pkg1 AS
PROCEDURE p1 AS
BEGIN
DO GET_LOCK('lock',300);
END;
FUNCTION f1 RETURN INT AS
BEGIN
CALL p1;
RETURN 1;
END;
END;
$$
SELECT pkg1.f1();
connection default;
connect  conn2,localhost,root,,;
SET sql_mode=ORACLE;
DROP PACKAGE pkg1;
connection default;
CREATE TEMPORARY TABLE mythreads(t_id INT UNSIGNED NOT NULL, t_name VARCHAR(16));
INSERT INTO mythreads VALUES(CONNECTION_ID(), 'default_id'),($conn1_id, 'conn1_id'),($conn2_id, 'conn2_id');
SELECT t_name AS CONN,INFO,STATE,LOCK_MODE,LOCK_TYPE,TABLE_NAME
FROM INFORMATION_SCHEMA.PROCESSLIST
INNER JOIN mythreads
ON (ID=t_id)
LEFT JOIN INFORMATION_SCHEMA.METADATA_LOCK_INFO
ON (ID=THREAD_ID)
ORDER BY ID,TABLE_NAME,LOCK_MODE,LOCK_TYPE;
CONN	default_id
INFO	SELECT t_name AS CONN,INFO,STATE,LOCK_MODE,LOCK_TYPE,TABLE_NAME
FROM INFORMATION_SCHEMA.PROCESSLIST
INNER JOIN mythreads
ON (ID=t_id)
LEFT JOIN INFORMATION_SCHEMA.METADATA_LOCK_INFO
ON (ID=THREAD_ID)
ORDER BY ID,TABLE_NAME,LOCK_MODE,LOCK_TYPE
STATE	Filling schema table
LOCK_MODE	MDL_SHARED_NO_WRITE
LOCK_TYPE	User lock
TABLE_NAME	
CONN	conn1_id
INFO	DO GET_LOCK('lock',300)
STATE	User lock
LOCK_MODE	MDL_SHARED
LOCK_TYPE	Stored package body metadata lock
TABLE_NAME	pkg1
CONN	conn1_id
INFO	DO GET_LOCK('lock',300)
STATE	User lock
LOCK_MODE	MDL_SHARED
LOCK_TYPE	Stored function metadata lock
TABLE_NAME	pkg1.f1
CONN	conn1_id
INFO	DO GET_LOCK('lock',300)
STATE	User lock
LOCK_MODE	MDL_SHARED
LOCK_TYPE	Stored procedure metadata lock
TABLE_NAME	pkg1.p1
CONN	conn2_id
INFO	DROP PACKAGE pkg1
STATE	Waiting for stored package body metadata lock
LOCK_MODE	MDL_BACKUP_DDL
LOCK_TYPE	Backup lock
TABLE_NAME	
CONN	conn2_id
INFO	DROP PACKAGE pkg1
STATE	Waiting for stored package body metadata lock
LOCK_MODE	MDL_INTENTION_EXCLUSIVE
LOCK_TYPE	Schema metadata lock
TABLE_NAME	
DROP TABLE mythreads;
DO RELEASE_LOCK('lock');
connection conn1;
pkg1.f1()
1
disconnect conn1;
connection conn2;
disconnect conn2;
connection default;
