Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-30662

SQL/PL package body does not appear in I_S.ROUTINES.ROUTINE_DEFINITION

Details

    Description

      For stored procedures and packages, the text of the object is available in the I_S.ROUTINES table in the routine_definition column. For Oracle SQL/PL packages these are regustered, as expected, in the I_S.ROUTINES table but the ROUTINE_DEFINITION column is empty. The mysql.proc table does keep this in the body column as expected though. The above is true both for PACKAGE and PACKAGE BODY.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov added a comment - - edited

            Repeatable with this script:

            SET sql_mode=ORACLE;
            DELIMITER $$
            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
            END;
            $$
            DELIMITER ;
             
            SELECT routine_name, routine_type, routine_body, routine_definition FROM information_schema.routines WHERE routine_type LIKE 'PACKAGE%'\G
            

            *************************** 1. row ***************************
                  routine_name: pkg1
                  routine_type: PACKAGE
                  routine_body: SQL
            routine_definition: 
            *************************** 2. row ***************************
                  routine_name: pkg1
                  routine_type: PACKAGE BODY
                  routine_body: SQL
            routine_definition: 
            2 rows in set (0.005 sec)
            

            Notice, the column routine_definition is empty.

            mysql.proc query works fine

            An equivalent query to mysql.proc returns definitions without problems:

            SELECT name, type, `body` FROM mysql.proc WHERE type LIKE 'PACKAGE%'\G
            

            *************************** 1. row ***************************
            name: pkg1
            type: PACKAGE
            body: AS
              FUNCTION f1() RETURN INT;
            END
            *************************** 2. row ***************************
            name: pkg1
            type: PACKAGE BODY
            body: AS
             
              FUNCTION f1() RETURN INT AS
              BEGIN
                RETURN 1;
              END;
             
            BEGIN
            END
            2 rows in set (0.002 sec)
            

            bar Alexander Barkov added a comment - - edited Repeatable with this script: SET sql_mode=ORACLE; DELIMITER $$ 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 END ; $$ DELIMITER ;   SELECT routine_name, routine_type, routine_body, routine_definition FROM information_schema.routines WHERE routine_type LIKE 'PACKAGE%' \G *************************** 1. row *************************** routine_name: pkg1 routine_type: PACKAGE routine_body: SQL routine_definition: *************************** 2. row *************************** routine_name: pkg1 routine_type: PACKAGE BODY routine_body: SQL routine_definition: 2 rows in set (0.005 sec) Notice, the column routine_definition is empty. mysql.proc query works fine An equivalent query to mysql.proc returns definitions without problems: SELECT name , type, `body` FROM mysql.proc WHERE type LIKE 'PACKAGE%' \G *************************** 1. row *************************** name: pkg1 type: PACKAGE body: AS FUNCTION f1() RETURN INT; END *************************** 2. row *************************** name: pkg1 type: PACKAGE BODY body: AS   FUNCTION f1() RETURN INT AS BEGIN RETURN 1; END;   BEGIN END 2 rows in set (0.002 sec)

            The problem happens because mysql.proc.body_utf8 is empty for PACKAGE and PACKAGE BODY records for some reasons:

            MariaDB [test]> select name, type, body_utf8 from mysql.proc where name='pkg1';
            +------+--------------+-----------+
            | name | type         | body_utf8 |
            +------+--------------+-----------+
            | pkg1 | PACKAGE      |           |
            | pkg1 | PACKAGE BODY |           |
            +------+--------------+-----------+
            

            bar Alexander Barkov added a comment - The problem happens because mysql.proc.body_utf8 is empty for PACKAGE and PACKAGE BODY records for some reasons: MariaDB [test]> select name , type, body_utf8 from mysql.proc where name = 'pkg1' ; + ------+--------------+-----------+ | name | type | body_utf8 | + ------+--------------+-----------+ | pkg1 | PACKAGE | | | pkg1 | PACKAGE BODY | | + ------+--------------+-----------+

            People

              bar Alexander Barkov
              karlsson Anders Karlsson
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.