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

CREATE PACKAGE BODY with a long routine name asserts in check_package_routine_end_name()

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.8, 13.0, 13.1, 13.2, 13.3
    • None
    • None
    • None

    Description

      A debug build asserts (Assertion '!check_name_with_error(name)' failed in Lex_ident_routine::Lex_ident_routine()) in sp_head::check_package_routine_end_name() (sql/sp_head.cc) when CREATE PACKAGE BODY defines a routine whose combined name package.routine is longer than 64 characters. The function builds a Lex_ident_routine from m_name, which is the combined name, before it checks whether the routine has an end name. Repro: sql_mode=ORACLE, a package p with a function whose name has 64 characters (66 characters in total with the package name and the dot), and CREATE PACKAGE BODY that defines the function, see the script below. The code is from 2017 and is not changed by MENT-2349. It was found while writing the test for the check of the name package.routine: the SQL routine case in pkg_test_plugin_decl_misc.test uses a package specification without a body for this reason

      SET sql_mode=ORACLE;
      DELIMITER $$
      CREATE OR REPLACE PACKAGE p AS
        FUNCTION f123456789_123456789_123456789_123456789_123456789_123456789_123 RETURN INT;
      END;
      $$
      -- The server aborts here:
      -- Assertion `!check_name_with_error(name)' failed in
      -- Lex_ident_routine::Lex_ident_routine(const LEX_CSTRING&)
      CREATE PACKAGE BODY p AS
        FUNCTION f123456789_123456789_123456789_123456789_123456789_123456789_123 RETURN INT AS
        BEGIN
          RETURN 1;
        END;
      END;
      $$
      DELIMITER ;
      CALL p1;
      

      #0  0x00007ffff7082e7c in __pthread_kill_implementation ()
         from /lib64/libc.so.6
      #1  0x00007ffff7028f0e in raise () from /lib64/libc.so.6
      #2  0x00007ffff70106d0 in abort () from /lib64/libc.so.6
      #3  0x00007ffff7010639 in __assert_fail_base.cold () from /lib64/libc.so.6
      #4  0x00005555556089d8 in Lex_ident_routine::Lex_ident_routine (
          this=0x7ffff40a20e0, name=...)
          at /home/bar/maria-git/11.8.m41246.rep/sql/lex_ident.h:336
      #5  0x0000555555607feb in sp_head::check_package_routine_end_name (
          this=0x77ffa8067400, end_name=...)
          at /home/bar/maria-git/11.8.m41246.rep/sql/sp_head.cc:4143
      #6  0x0000555555b48997 in ORAparse (thd=0x77ffa8000dc8)
          at /home/bar/maria-git/11.8.m41246.rep/sql/sql_yacc.yy:19803
      #7  0x0000555555736735 in parse_sql (thd=0x77ffa8000dc8, 
          parser_state=0x7ffff40a3f60, creation_ctx=0x0, do_pfs_digest=true)
          at /home/bar/maria-git/11.8.m41246.rep/sql/sql_parse.cc:10334
      #8  0x000055555573067b in mysql_parse (thd=0x77ffa8000dc8, 
          rawbuf=0x77ffa8034b70 "CREATE PACKAGE BODY p AS\n  FUNCTION f123456789_123456789_123456789_123456789_123456789_123456789_123 RETURN INT AS\n  BEGIN\n    RETURN 1;\n  END;\nEND", length=147, parser_state=0x7ffff40a3f60)
          at /home/bar/maria-git/11.8.m41246.rep/sql/sql_parse.cc:7890
      #9  0x000055555571b74b in dispatch_command (command=COM_QUERY, 
          thd=0x77ffa8000dc8, 
          packet=0x77ffa800bd99 "CREATE PACKAGE BODY p AS\n  FUNCTION f123456789_123456789_123456789_123456789_123456789_123456789_123 RETURN INT AS\n  BEGIN\n    RETURN 1;\n  END;\nEND;", packet_length=148, blocking=true)
          at /home/bar/maria-git/11.8.m41246.rep/sql/sql_parse.cc:1923
      #10 0x0000555555719e2d in do_command (thd=0x77ffa8000dc8, blocking=true)
          at /home/bar/maria-git/11.8.m41246.rep/sql/sql_parse.cc:1431
      #11 0x0000555555933b34 in do_handle_one_connection (connect=0x5555592c47c8, 
          put_in_cache=true)
          at /home/bar/maria-git/11.8.m41246.rep/sql/sql_connect.cc:1515
      #12 0x0000555555933881 in handle_one_connection (arg=0x5555592c47c8)
      

      Attachments

        Issue Links

          Activity

            People

              Khaled.amr Khaled Amr
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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