Skip to content

Commit 323e6cd

Browse files
committed
MDEV-18092 Query with the table I_S.PARAMETERS stop working after a package is created
This patch was originally made by Anel Husakovic. Skip `PACKAGE` and `PACKAGE BODY` records quickly. These stored objects do not have any parameters or return values (only procedures and functions have). So no needs to build a `CREATE` statement (in `Sp_handler::sp_load_for_information_schema()`) and parse it: this won't give us any data useful for `INFORMATION_SCHEMA.PARAMETERS`.
1 parent 250799f commit 323e6cd

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

mysql-test/suite/compat/oracle/r/information_schema_parameters.result

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,3 +814,41 @@ DTD_IDENTIFIER ROW
814814
ROUTINE_TYPE FUNCTION
815815
-------- --------
816816
DROP FUNCTION f1;
817+
#
818+
# MDEV 18092 Query with the table I_S.PARAMETERS stop working
819+
# after a package is created
820+
#
821+
SET sql_mode=ORACLE;
822+
CREATE DATABASE db1_mdev18092;
823+
USE db1_mdev18092;
824+
CREATE PROCEDURE p1(a INT)
825+
AS BEGIN
826+
NULL;
827+
END;
828+
$$
829+
CREATE OR REPLACE PACKAGE employee_tools AS
830+
FUNCTION getSalary(eid INT) RETURN DECIMAL(10,2);
831+
PROCEDURE raiseSalary(eid INT, amount DECIMAL(10,2));
832+
PROCEDURE raiseSalaryStd(eid INT);
833+
PROCEDURE hire(ename TEXT, esalary DECIMAL(10,2));
834+
END;
835+
$$
836+
SELECT *, '---------------' FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_SCHEMA='db1_mdev18092';
837+
SPECIFIC_CATALOG def
838+
SPECIFIC_SCHEMA db1_mdev18092
839+
SPECIFIC_NAME p1
840+
ORDINAL_POSITION 1
841+
PARAMETER_MODE IN
842+
PARAMETER_NAME a
843+
DATA_TYPE int
844+
CHARACTER_MAXIMUM_LENGTH NULL
845+
CHARACTER_OCTET_LENGTH NULL
846+
NUMERIC_PRECISION 10
847+
NUMERIC_SCALE 0
848+
DATETIME_PRECISION NULL
849+
CHARACTER_SET_NAME NULL
850+
COLLATION_NAME NULL
851+
DTD_IDENTIFIER int(11)
852+
ROUTINE_TYPE PROCEDURE
853+
--------------- ---------------
854+
DROP DATABASE db1_mdev18092;

mysql-test/suite/compat/oracle/t/information_schema_parameters.test

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,36 @@ SET sql_mode=ORACLE;
9292
SELECT *, '--------' FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME='f1';
9393
--horizontal_results
9494
DROP FUNCTION f1;
95+
96+
--echo #
97+
--echo # MDEV 18092 Query with the table I_S.PARAMETERS stop working
98+
--echo # after a package is created
99+
--echo #
100+
101+
SET sql_mode=ORACLE;
102+
103+
CREATE DATABASE db1_mdev18092;
104+
USE db1_mdev18092;
105+
106+
DELIMITER $$;
107+
108+
CREATE PROCEDURE p1(a INT)
109+
AS BEGIN
110+
NULL;
111+
END;
112+
$$
113+
114+
CREATE OR REPLACE PACKAGE employee_tools AS
115+
FUNCTION getSalary(eid INT) RETURN DECIMAL(10,2);
116+
PROCEDURE raiseSalary(eid INT, amount DECIMAL(10,2));
117+
PROCEDURE raiseSalaryStd(eid INT);
118+
PROCEDURE hire(ename TEXT, esalary DECIMAL(10,2));
119+
END;
120+
$$
121+
DELIMITER ;$$
122+
123+
--vertical_results
124+
SELECT *, '---------------' FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_SCHEMA='db1_mdev18092';
125+
--horizontal_results
126+
127+
DROP DATABASE db1_mdev18092;

sql/sql_show.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6268,7 +6268,8 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table,
62686268
sph= Sp_handler::handler_mysql_proc((stored_procedure_type)
62696269
proc_table->field[MYSQL_PROC_MYSQL_TYPE]->
62706270
val_int());
6271-
if (!sph)
6271+
if (!sph || sph->type() == TYPE_ENUM_PACKAGE ||
6272+
sph->type() == TYPE_ENUM_PACKAGE_BODY)
62726273
DBUG_RETURN(0);
62736274

62746275
if (!full_access)

0 commit comments

Comments
 (0)