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

Package spec RECORD-field %TYPE anchor is broken

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 13.1
    • 13.1
    • Stored routines
    • None
    • Not for Release Notes
    • Q3/2026 Server Maintenance

    Description

      Server crashes when the anchored column is an INTEGER type and it is used in the field comparison operation

      SET sql_mode=ORACLE;
      CREATE TABLE t (id INT, name VARCHAR(100));
       
      DELIMITER $$;
      CREATE PACKAGE pkga AS TYPE r IS RECORD (f t.id%TYPE); END;
      $$
      CREATE PROCEDURE pa AS v pkga.r;
      BEGIN v.f := 1; IF v.f = 1 THEN SELECT 'ok'; END IF; END;
      $$
      DELIMITER ;$$
      CALL pa;   
      

      Leads to

      MDEV-39587 CS 13.1.0 667959df058b5179e737f103d78abef77f1bca5e (Optimized, Clang 18.1.3-11) Build 22/06/2026

      Core was generated by `/test/mtest/MDEV-39587/MD220626-mariadb-13.1.0-linux-x86_64-opt/bin/mariadbd --'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  my_decimal::operator= (this=0x70b3b8052aa0, rhs=...)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/my_decimal.h:132
       
      [Current thread is 1 (LWP 3830032)]
      (gdb) bt
      #0  my_decimal::operator= (this=0x70b3b8052aa0, rhs=<error reading variable: Cannot access memory at address 0x0>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/my_decimal.h:132
      #1  my_decimal2decimal (from=0x0, to=0x70b3b8052aa0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/my_decimal.h:353
      #2  Item_cache_decimal::cache_value (this=0x70b3b80529f0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/item.cc:11439
      #3  0x00005cbcdc8de26e in Item_cache::has_value (this=0x70b3b80529f0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/item.h:8037
      #4  Item_cache_decimal::val_decimal (this=0x70b3b80529f0, val=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/item.cc:11461
      #5  0x00005cbcdc7ebb2b in VDec::VDec (this=0x78b4f0766bc0, item=0x0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_type.cc:334
      #6  0x00005cbcdc8ef04d in Arg_comparator::compare_decimal (this=0x70b3b804ca98)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/item_cmpfunc.cc:949
      #7  0x00005cbcdc8f060a in Arg_comparator::compare (this=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/item_cmpfunc.h:114
      #8  Item_func_eq::val_bool (this=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/item_cmpfunc.cc:1912
      #9  0x00005cbcdc7e57a8 in sp_instr_jump_if_not::exec_core (this=0x70b3b804cc10, thd=<optimized out>, nextp=0x78b4f0766f64)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp_instr.cc:1892
      #10 0x00005cbcdc7e2638 in sp_lex_keeper::reset_lex_and_exec_core (this=this@entry=0x70b3b804cc48, thd=thd@entry=0x70b3b8000c70, nextp=nextp@entry=0x78b4f0766f64, open_tables=true, instr=instr@entry=0x70b3b804cc10, rerun_the_same_instr=<optimized out>)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp_instr.cc:420
      #11 0x00005cbcdc7e2c36 in sp_lex_keeper::validate_lex_and_exec_core (this=0x70b3b804cc48, thd=0x70b3b8000c70, nextp=0x78b4f0766f64, open_tables=<optimized out>, instr=0x70b3b804cc10)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp_instr.cc:599
      #12 0x00005cbcdc59787a in sp_head::execute (this=this@entry=0x70b3b8021c20, thd=thd@entry=0x70b3b8000c70, merge_da_on_success=true)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp_head.cc:1332
      #13 0x00005cbcdc59915b in sp_head::execute_procedure (this=0x70b3b8021c20, thd=0x70b3b8000c70, args=0x70b3b80061b8)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sp_head.cc:2369
      #14 0x00005cbcdc63e033 in do_execute_sp (thd=thd@entry=0x70b3b8000c70, sp=0x70b3b801b030, sp@entry=0x70b3b8021c20)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:3084
      #15 0x00005cbcdc63dd1d in Sql_cmd_call::execute (this=0x70b3b8017e20, thd=0x70b3b8000c70)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:3322
      #16 0x00005cbcdc63f2eb in mysql_execute_command (thd=thd@entry=0x70b3b8000c70, is_called_from_prepared_stmt=false)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:5905
      #17 0x00005cbcdc63acb2 in mysql_parse (thd=thd@entry=0x70b3b8000c70, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x78b4f0768590)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:7945
      #18 0x00005cbcdc6391f3 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x70b3b8000c70, packet=packet@entry=0x70b3b8008db1 "CALL pr1", packet_length=packet_length@entry=8, blocking=true)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:1903
      #19 0x00005cbcdc63b131 in do_command (thd=thd@entry=0x70b3b8000c70, blocking=true)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_parse.cc:1437
      #20 0x00005cbcdc76367d in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5cbce6253b80, put_in_cache=true)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_connect.cc:1503
      #21 0x00005cbcdc7634b2 in handle_one_connection (arg=arg@entry=0x5cbce6253b80)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/sql/sql_connect.cc:1415
      #22 0x00005cbcdcb042d3 in pfs_spawn_thread (arg=0x5cbce6273dc0)at /test/mtest/MDEV-39587/bb-13.1-bar-MDEV-39587_opt/storage/perfschema/pfs.cc:2198
      #23 0x000078b4f469caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #24 0x000078b4f4729c6c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      MTR test 2

      In test case 2 value silently lost when the anchored column is an VARCHAR type

      SET sql_mode=ORACLE;
       
      CREATE TABLE t (id INT, name VARCHAR(100));
       
      DELIMITER $$;
      CREATE PACKAGE pkgb AS TYPE r IS RECORD (f_name t.name%TYPE); END;
      $$
      CREATE PROCEDURE pr2 AS v pkgb.r;
      BEGIN v.f_name := 'hello'; SELECT v.f_name AS val, LENGTH(v.f_name) AS len; END;   # Result set val='', len=0 
      $$
      DELIMITER ;$$
      CALL pr2;
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 3d
                  3d
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 0.5h Time Not Required
                  0.5h

                  Git Integration

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