Commit 9500575f authored by Alexander Barkov's avatar Alexander Barkov

MDEV-33428 Error messages ER_PACKAGE_ROUTINE_* are not good enough

Changing the format in error messages:
- ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY
- ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED

from
  "Subroutine 'db.pkg.f1' ..."

to a more clear:
  "FUNCTION `db.pkg.f1` ..."
  "PROCEDURE `db.pkg.p1` ..."
parent 9b1ea690
#
# Start of 11.4 tests
#
SET sql_mode=''; SET sql_mode='';
CREATE OR REPLACE PACKAGE pkg CREATE OR REPLACE PACKAGE pkg
PROCEDURE p1(); PROCEDURE p1();
...@@ -49,3 +52,72 @@ SELECT pkg.f1(); ...@@ -49,3 +52,72 @@ SELECT pkg.f1();
pkg.f1() pkg.f1()
1 1
DROP PACKAGE pkg; DROP PACKAGE pkg;
#
# MDEV-33428 Error messages ER_PACKAGE_ROUTINE_* are not good enough
#
#
# Routines declared in CREATE PACKAGE missing in CREATE PACKAGE BODY
#
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
CREATE PACKAGE BODY test2
PROCEDURE p2() BEGIN SELECT 0; END;
END;
$$
ERROR HY000: PROCEDURE `test.test2.p1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2;
CREATE PACKAGE test2
FUNCTION f1() RETURNS INT;
END;
$$
CREATE PACKAGE BODY test2
FUNCTION f2() RETURNS INT BEGIN RETURN 10; END;
END;
$$
ERROR HY000: FUNCTION `test.test2.f1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2;
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
CREATE PACKAGE BODY test2
FUNCTION p1() RETURNS INT BEGIN RETURN 10; END;
END;
$$
ERROR HY000: PROCEDURE `test.test2.p1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2;
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
CREATE PACKAGE BODY test2
PROCEDURE p1(a INT) BEGIN SELECT 0; END; -- Notice different prototype
END;
$$
ERROR HY000: PROCEDURE `test.test2.p1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2;
#
# Forward declarations in CREATE PACKAGE BODY with missing implementations
#
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
CREATE PACKAGE BODY test2
PROCEDURE p1() BEGIN SELECT 0; END;
PROCEDURE p2();
END;
$$
ERROR HY000: PROCEDURE `test.test2.p2` has a forward declaration but is not defined
CREATE PACKAGE BODY test2
FUNCTION f1() RETURNS INT;
PROCEDURE p1() BEGIN SELECT 0; END;
END;
$$
ERROR HY000: FUNCTION `test.test2.f1` has a forward declaration but is not defined
DROP PACKAGE test2;
#
# End of 11.4 tests
#
--echo #
--echo # Start of 11.4 tests
--echo #
# #
# CREATE PACKAGE for sql_mode=''; # CREATE PACKAGE for sql_mode='';
# Resebmles SQL Standard 'CREATE MODULE'. # Resebmles SQL Standard 'CREATE MODULE'.
...@@ -44,3 +48,93 @@ CALL pkg.p1(); ...@@ -44,3 +48,93 @@ CALL pkg.p1();
SELECT pkg.f1(); SELECT pkg.f1();
DROP PACKAGE pkg; DROP PACKAGE pkg;
--echo #
--echo # MDEV-33428 Error messages ER_PACKAGE_ROUTINE_* are not good enough
--echo #
--echo #
--echo # Routines declared in CREATE PACKAGE missing in CREATE PACKAGE BODY
--echo #
DELIMITER $$;
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
--error ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY
CREATE PACKAGE BODY test2
PROCEDURE p2() BEGIN SELECT 0; END;
END;
$$
DELIMITER ;$$
DROP PACKAGE test2;
DELIMITER $$;
CREATE PACKAGE test2
FUNCTION f1() RETURNS INT;
END;
$$
--error ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY
CREATE PACKAGE BODY test2
FUNCTION f2() RETURNS INT BEGIN RETURN 10; END;
END;
$$
DELIMITER ;$$
DROP PACKAGE test2;
DELIMITER $$;
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
--error ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY
CREATE PACKAGE BODY test2
FUNCTION p1() RETURNS INT BEGIN RETURN 10; END;
END;
$$
DELIMITER ;$$
DROP PACKAGE test2;
DELIMITER $$;
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
--error ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY
CREATE PACKAGE BODY test2
PROCEDURE p1(a INT) BEGIN SELECT 0; END; -- Notice different prototype
END;
$$
DELIMITER ;$$
DROP PACKAGE test2;
--echo #
--echo # Forward declarations in CREATE PACKAGE BODY with missing implementations
--echo #
DELIMITER $$;
CREATE PACKAGE test2
PROCEDURE p1();
END;
$$
--error ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED
CREATE PACKAGE BODY test2
PROCEDURE p1() BEGIN SELECT 0; END;
PROCEDURE p2();
END;
$$
--error ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED
CREATE PACKAGE BODY test2
FUNCTION f1() RETURNS INT;
PROCEDURE p1() BEGIN SELECT 0; END;
END;
$$
DELIMITER ;$$
DROP PACKAGE test2;
--echo #
--echo # End of 11.4 tests
--echo #
...@@ -444,7 +444,7 @@ CREATE PACKAGE BODY test2 AS ...@@ -444,7 +444,7 @@ CREATE PACKAGE BODY test2 AS
PROCEDURE p2 AS BEGIN NULL; END; PROCEDURE p2 AS BEGIN NULL; END;
END; END;
$$ $$
ERROR HY000: Subroutine 'test.test2.p1' is declared in the package specification but is not defined in the package body ERROR HY000: PROCEDURE `test.test2.p1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2; DROP PACKAGE test2;
CREATE PACKAGE test2 AS CREATE PACKAGE test2 AS
FUNCTION f1 RETURN INT; FUNCTION f1 RETURN INT;
...@@ -454,7 +454,7 @@ CREATE PACKAGE BODY test2 AS ...@@ -454,7 +454,7 @@ CREATE PACKAGE BODY test2 AS
FUNCTION f2 RETURN INT AS BEGIN RETURN 10; END; FUNCTION f2 RETURN INT AS BEGIN RETURN 10; END;
END; END;
$$ $$
ERROR HY000: Subroutine 'test.test2.f1' is declared in the package specification but is not defined in the package body ERROR HY000: FUNCTION `test.test2.f1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2; DROP PACKAGE test2;
CREATE PACKAGE test2 AS CREATE PACKAGE test2 AS
PROCEDURE p1; PROCEDURE p1;
...@@ -464,7 +464,7 @@ CREATE PACKAGE BODY test2 AS ...@@ -464,7 +464,7 @@ CREATE PACKAGE BODY test2 AS
FUNCTION p1 RETURN INT AS BEGIN RETURN 10; END; FUNCTION p1 RETURN INT AS BEGIN RETURN 10; END;
END; END;
$$ $$
ERROR HY000: Subroutine 'test.test2.p1' is declared in the package specification but is not defined in the package body ERROR HY000: PROCEDURE `test.test2.p1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2; DROP PACKAGE test2;
CREATE PACKAGE test2 AS CREATE PACKAGE test2 AS
PROCEDURE p1; PROCEDURE p1;
...@@ -474,7 +474,7 @@ CREATE PACKAGE BODY test2 AS ...@@ -474,7 +474,7 @@ CREATE PACKAGE BODY test2 AS
PROCEDURE p1(a INT) AS BEGIN NULL; END; -- Notice different prototype PROCEDURE p1(a INT) AS BEGIN NULL; END; -- Notice different prototype
END; END;
$$ $$
ERROR HY000: Subroutine 'test.test2.p1' is declared in the package specification but is not defined in the package body ERROR HY000: PROCEDURE `test.test2.p1` is declared in the package specification but is not defined in the package body
DROP PACKAGE test2; DROP PACKAGE test2;
# #
# Forward declarations in CREATE PACKAGE BODY with missing implementations # Forward declarations in CREATE PACKAGE BODY with missing implementations
...@@ -488,13 +488,13 @@ PROCEDURE p1 AS BEGIN NULL; END; ...@@ -488,13 +488,13 @@ PROCEDURE p1 AS BEGIN NULL; END;
PROCEDURE p2; PROCEDURE p2;
END; END;
$$ $$
ERROR HY000: Subroutine 'test.test2.p2' has a forward declaration but is not defined ERROR HY000: PROCEDURE `test.test2.p2` has a forward declaration but is not defined
CREATE PACKAGE BODY test2 AS CREATE PACKAGE BODY test2 AS
FUNCTION f1 RETURN INT; FUNCTION f1 RETURN INT;
PROCEDURE p1 AS BEGIN NULL; END; PROCEDURE p1 AS BEGIN NULL; END;
END; END;
$$ $$
ERROR HY000: Subroutine 'test.test2.f1' has a forward declaration but is not defined ERROR HY000: FUNCTION `test.test2.f1` has a forward declaration but is not defined
DROP PACKAGE test2; DROP PACKAGE test2;
# #
# Creating a new package # Creating a new package
......
...@@ -11782,15 +11782,15 @@ ER_SP_STACK_TRACE ...@@ -11782,15 +11782,15 @@ ER_SP_STACK_TRACE
spa "En la línea %u en %s" spa "En la línea %u en %s"
sw "Kwenye mstari %u katika %s" sw "Kwenye mstari %u katika %s"
ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY
chi "在包规范中声明子程序'%-.192s',但未在包主体中定义" chi "在包规范中声明子程序%s %`s,但未在包主体中定义"
eng "Subroutine '%-.192s' is declared in the package specification but is not defined in the package body" eng "%s %`s is declared in the package specification but is not defined in the package body"
spa "La subrutina '%-.192s' está declarada en la especificación del paquete pero no está definida en el cuerpo del paquete" spa "La %s %`s está declarada en la especificación del paquete pero no está definida en el cuerpo del paquete"
sw "Utaratibu mdogo '%-.192s' umetangazwa katika ubainisho wa kifurushi lakini haijafafanuliwa kwenye mwili wa kifurushi" sw "Utaratibu mdogo %s %`s umetangazwa katika ubainisho wa kifurushi lakini haijafafanuliwa kwenye mwili wa kifurushi"
ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED
chi "子程序'%-.192s'具有前向声明但未定义" chi "子程序%s %`s 具有前向声明但未定义"
eng "Subroutine '%-.192s' has a forward declaration but is not defined" eng "%s %`s has a forward declaration but is not defined"
spa "La subrutina '%-.192s' tiene una declaración adelantada pero no está definida" spa "La %s %`s tiene una declaración adelantada pero no está definida"
sw "Utaratibu mdogo '%-.192s' una tamko la mbele lakini haijafafanuliwa" sw "Utaratibu mdogo %s %`s una tamko la mbele lakini haijafafanuliwa"
ER_COMPRESSED_COLUMN_USED_AS_KEY ER_COMPRESSED_COLUMN_USED_AS_KEY
chi "压缩列'%-.192s'不能用于索引规范" chi "压缩列'%-.192s'不能用于索引规范"
eng "Compressed column '%-.192s' can't be used in key specification" eng "Compressed column '%-.192s' can't be used in key specification"
......
...@@ -708,6 +708,7 @@ bool sp_package::validate_public_routines(THD *thd, sp_package *spec) ...@@ -708,6 +708,7 @@ bool sp_package::validate_public_routines(THD *thd, sp_package *spec)
if (!found) if (!found)
{ {
my_error(ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY, MYF(0), my_error(ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY, MYF(0),
lex->sphead->m_handler->type_str(),
ErrConvDQName(lex->sphead).ptr()); ErrConvDQName(lex->sphead).ptr());
return true; return true;
} }
...@@ -742,6 +743,7 @@ bool sp_package::validate_private_routines(THD *thd) ...@@ -742,6 +743,7 @@ bool sp_package::validate_private_routines(THD *thd)
if (!found) if (!found)
{ {
my_error(ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED, MYF(0), my_error(ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED, MYF(0),
lex->sphead->m_handler->type_str(),
ErrConvDQName(lex->sphead).ptr()); ErrConvDQName(lex->sphead).ptr());
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment