mariadb/mysql-test/suite/compat/oracle/r/sp-package-i_s.result
Alexander Barkov 400c101332 MDEV-30662 SQL/PL package body does not appear in I_S.ROUTINES.ROUTINE_DEFINITION
- Moving the code from a public function trim_whitespaces()
  to the class Lex_cstring as methods. This code may
  be useful in other contexts, and also this code becomes
  visible inside sql_class.h

- Adding a helper method THD::strmake_lex_cstring_trim_whitespaces()

- Unifying the way how CREATE PROCEDURE/CREATE FUNCTION and
  CREATE PACKAGE/CREATE PACKAGE BODY work:

  a) Now CREATE PACKAGE/CREATE PACKAGE BODY also calls
  Lex->sphead->set_body_start() to remember the cpp body start inside
  an sp_head member.

  b) adding a "const char *cpp_body_end" parameter to
  sp_head::set_stmt_end().

  These changes made it possible to reuse sp_head::set_stmt_end() inside
  LEX::create_package_finalize() and remove the duplucate code.

- Renaming sp_head::m_body_begin to m_cpp_body_begin and adding a comment
  to make it clear that this member is used only during parsing, and
  points to a fragment inside the cpp buffer.

- Changed sp_head::set_body_start() and sp_head::set_stmt_end()
  to skip the calls related to "body_utf8" in cases when m_parent is not NULL.
  A non-NULL m_parent means that we're inside a package routine.
  "body_utf8" in such case belongs not to the current sphead itself,
  but to parent (the package) sphead.
  So an sphead instance of a package routine should neither initialize,
  nor finalize, nor change in any other ways the "body_utf8" related
  members of Lex_input_stream, and should not take over or copy "body_utf8"
  data from Lex_input_stream to "this".
2023-07-14 13:26:26 +04:00

75 lines
1.3 KiB
Text

#
# Start of 10.5 tests
#
#
# MDEV-30662 SQL/PL package body does not appear in I_S.ROUTINES.ROUTINE_DEFINITION
#
SET sql_mode=ORACLE;
CREATE OR REPLACE PACKAGE pkg1 AS
FUNCTION f1() RETURN INT;
END;
$$
CREATE PACKAGE BODY pkg1 AS
FUNCTION f1() RETURN INT AS
BEGIN
RETURN 1;
END;
END;
$$
SELECT routine_name, routine_type, routine_definition
FROM information_schema.routines
WHERE routine_type LIKE 'PACKAGE%'
ORDER BY routine_type;
routine_name pkg1
routine_type PACKAGE
routine_definition AS
FUNCTION f1() RETURN INT;
END
routine_name pkg1
routine_type PACKAGE BODY
routine_definition AS
FUNCTION f1() RETURN INT AS
BEGIN
RETURN 1;
END;
END
DROP PACKAGE pkg1;
SET sql_mode=ORACLE;
CREATE OR REPLACE PACKAGE pkg1 AS
FUNCTION f1() RETURN INT;
END;
$$
CREATE PACKAGE BODY pkg1 AS
FUNCTION f1() RETURN INT AS
BEGIN
RETURN 1;
END;
BEGIN
SET @a=10;
SET @a=f1();
END;
$$
SELECT routine_name, routine_type, routine_definition
FROM information_schema.routines
WHERE routine_type LIKE 'PACKAGE%'
ORDER BY routine_type;
routine_name pkg1
routine_type PACKAGE
routine_definition AS
FUNCTION f1() RETURN INT;
END
routine_name pkg1
routine_type PACKAGE BODY
routine_definition AS
FUNCTION f1() RETURN INT AS
BEGIN
RETURN 1;
END;
BEGIN
SET @a=10;
SET @a=f1();
END
DROP PACKAGE pkg1;
#
# End of 10.5 tests
#