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

SHOW PROCEDURE CODE crashes in a package with a body wide assoc array

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 12.1.2
    • 12.3
    • Stored routines
    • None

    Description

      This script:

      SET sql_mode=ORACLE;
      DELIMITER $$
      CREATE OR REPLACE PACKAGE pkg1 AS
        PROCEDURE p1;
      END;
      $$
      CREATE OR REPLACE PACKAGE BODY pkg1 AS
        TYPE record0_t IS RECORD (a INT, b VARCHAR(32));
        TYPE assoc0_t IS TABLE OF record0_t INDEX BY INTEGER;
        assoc0 assoc0_t;
       
        PROCEDURE p1 AS
        BEGIN
          assoc0(0):= record0_t(1,'2');
        END;
       
      END;
      $$
      DELIMITER ;
       
      SHOW PROCEDURE CODE pkg1.p1;
      

      crashes with the following stack trace:

      #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
      #1  0x00007ffff7080343 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:89
      #2  0x00007ffff7026cbe in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
      #3  0x00007ffff700e6d6 in __GI_abort () at abort.c:73
      #4  0x00007ffff700e639 in __assert_fail_base (fmt=<optimized out>, assertion=<optimized out>, file=<optimized out>, line=1596, 
          function=<optimized out>) at assert.c:118
      #5  0x0000555555ab46a3 in sp_instr_set_composite_field_by_name::print (this=0x7fff9c06ed40, str=0x7ffff4189dd0)
          at /home/bar/maria-git/12.3.m10152.rcur/sql/sp_instr.cc:1596
      #6  0x000055555562c4fc in sp_head::show_routine_code (this=0x7fff9c06d8b0, thd=0x7fff9c000dc8)
          at /home/bar/maria-git/12.3.m10152.rcur/sql/sp_head.cc:3500
      #7  0x000055555575f8f7 in Sql_cmd_show_routine_code::execute (this=0x7fff9c035170, thd=0x7fff9c000dc8)
          at /home/bar/maria-git/12.3.m10152.rcur/sql/sql_parse.cc:3251
      

      The problem is in this code:

      void
      sp_instr_set_composite_field_by_name::print(String *str)
      {
        /* set name.field@offset["field"] ... */
        /* set name.field["key"] ... */
        const sp_variable *var= m_ctx->get_pvariable(*this);
      

      It always searches for a local variable. It should search taking into account sp_instr_set_composite_field_by_name::sp_rcontext_handler instead.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Alexander Barkov Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.