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

Server crashes when setting a column default value to oracle sql_mode

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      SET SESSION SQL_MODE=ORACLE;
      CREATE OR REPLACE TABLE t (a CHAR DEFAULT @@sql_mode);
      

      Leads to:

      CS 10.11.16 e309477815ee240c2c7fef559d16d869a5709cfd (Debug, Clang 18.1.3-11) Build 06/01/2026

      Core was generated by `/test/MD060126-mariadb-10.11.16-linux-x86_64-dbg/bin/mariadbd --no-defaults --m'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      Download failed: Invalid argument.  Continuing without source file ./string/../sysdeps/x86_64/multiarch/strlen-evex-base.S.
      #0  __strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex-base.S:81
       
      [Current thread is 1 (LWP 879170)]
      (gdb) bt
      #0  __strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex-base.S:81
      #1  0x00005a1d45499e5e in set_to_string (thd=0x7020cc000d58, result=0x7021c813fb80, set=1, lib=0x5a1d46c47940 <sql_mode_names>)at /test/10.11_dbg/sql/strfunc.cc:368
      #2  0x00005a1d45536ec0 in Sys_var_set::valptr (this=0x5a1d46e7a708 <Sys_sql_mode>, thd=0x7020cc000d58, val=43218165760)at /test/10.11_dbg/sql/sys_vars.inl:1491
      #3  0x00005a1d45536d4d in Sys_var_set::session_value_ptr (this=0x5a1d46e7a708 <Sys_sql_mode>, thd=0x7020cc000d58, base=0x7020cc0255d0) at /test/10.11_dbg/sql/sys_vars.inl:1493
      #4  0x00005a1d451f061a in sys_var::value_ptr (this=0x5a1d46e7a708 <Sys_sql_mode>, thd=0x7020cc000d58, type=SHOW_OPT_DEFAULT, base=0x7020cc0255d0)at /test/10.11_dbg/sql/set_var.cc:285
      #5  0x00005a1d457bb1f1 in Item_func_get_system_var::fix_length_and_dec (this=0x7020cc025518, thd=0x7020cc000d58)at /test/10.11_dbg/sql/item_func.cc:5976
      #6  0x00005a1d457a4e73 in Item_func::fix_fields (this=0x7020cc025518, thd=0x7020cc000d58, ref=0x7020cc025640)at /test/10.11_dbg/sql/item_func.cc:412
      #7  0x00005a1d454a7487 in Virtual_column_info::fix_expr (this=0x7020cc025628, thd=0x7020cc000d58) at /test/10.11_dbg/sql/table.cc:3651
      #8  0x00005a1d454a4612 in Virtual_column_info::fix_and_check_expr (this=0x7020cc025628, thd=0x7020cc000d58, table=0x7021c81436d8)at /test/10.11_dbg/sql/table.cc:3832
      #9  0x00005a1d454a43b3 in unpack_vcol_info_from_frm (thd=0x7020cc000d58, table=0x7021c81436d8, expr_str=0x7021c8142918, vcol_ptr=0x7020cc024d10, error_reported=0x7021c8142d9f) at /test/10.11_dbg/sql/table.cc:3972
      #10 0x00005a1d454a308c in parse_vcol_defs (thd=0x7020cc000d58, mem_root=0x7021c81439c8, table=0x7021c81436d8, error_reported=0x7021c8142d9f, mode=VCOL_INIT_DEPENDENCY_FAILURE_IS_ERROR)at /test/10.11_dbg/sql/table.cc:1247
      #11 0x00005a1d454a8b78 in open_table_from_share (thd=0x7020cc000d58, share=0x7021c8142ec0, alias=0x5a1d46abdbc0 <empty_clex_str>, db_stat=0, prgflag=1, ha_open_flags=0, outparam=0x7021c81436d8, is_create_table=true, partitions_to_open=0x0) at /test/10.11_dbg/sql/table.cc:4360
      #12 0x00005a1d4571b167 in ha_create_table (thd=0x7020cc000d58, path=0x7021c8144a50 "./test/t", db=0x7020cc013580 "test", table_name=0x7020cc013550 "t", create_info=0x7021c8145228, frm=0x7021c81449d0, skip_frm_file=false)at /test/10.11_dbg/sql/handler.cc:6146
      #13 0x00005a1d4544419c in create_table_impl (thd=0x7020cc000d58, ddl_log_state_create=0x7021c8144db8, ddl_log_state_rm=0x7021c8144d98, orig_db=@0x7020cc0135b0: {str = 0x7020cc013580 "test", length = 4}, orig_table_name=@0x7020cc0135c0: {str = 0x7020cc013550 "t", length = 1}, db=@0x7020cc0135b0: {str = 0x7020cc013580 "test", length = 4}, table_name=@0x7020cc0135c0: {str = 0x7020cc013550 "t", length = 1}, path=@0x7021c81449f0: {str = 0x7021c8144a50 "./test/t", length = 8}, options={m_options = DDL_options_st::OPT_OR_REPLACE}, create_info=0x7021c8145228, alter_info=0x7021c81450b8, create_table_mode=0, is_trans=0x7021c8144d8f, key_info=0x7021c8144a10, key_count=0x7021c8144a0c, frm=0x7021c81449d0)at /test/10.11_dbg/sql/sql_table.cc:4853
      #14 0x00005a1d45443228 in mysql_create_table_no_lock (thd=0x7020cc000d58, ddl_log_state_create=0x7021c8144db8, ddl_log_state_rm=0x7021c8144d98, create_info=0x7021c8145228, alter_info=0x7021c81450b8, is_trans=0x7021c8144d8f, create_table_mode=0, table_list=0x7020cc013590)at /test/10.11_dbg/sql/sql_table.cc:4955
      #15 0x00005a1d4545dbbe in mysql_create_table (thd=0x7020cc000d58, create_table=0x7020cc013590, create_info=0x7021c8145228, alter_info=0x7021c81450b8) at /test/10.11_dbg/sql/sql_table.cc:5202
      #16 0x00005a1d4545c1e5 in Sql_cmd_create_table_like::execute (this=0x7020cc013528, thd=0x7020cc000d58)at /test/10.11_dbg/sql/sql_table.cc:13159
      #17 0x00005a1d4533835f in mysql_execute_command (thd=0x7020cc000d58, is_called_from_prepared_stmt=false)at /test/10.11_dbg/sql/sql_parse.cc:6208
      #18 0x00005a1d45325f34 in mysql_parse (thd=0x7020cc000d58, rawbuf=0x7020cc013460 "CREATE OR REPLACE TABLE t (a CHAR DEFAULT @@sql_mode)", length=53, parser_state=0x7021c8146ae0)at /test/10.11_dbg/sql/sql_parse.cc:8230
      #19 0x00005a1d453233d9 in dispatch_command (command=COM_QUERY, thd=0x7020cc000d58, packet=0x7020cc00aee9 "CREATE OR REPLACE TABLE t (a CHAR DEFAULT @@sql_mode)", packet_length=53, blocking=true) at /test/10.11_dbg/sql/sql_parse.cc:1924
      #20 0x00005a1d45326ae3 in do_command (thd=0x7020cc000d58, blocking=true)at /test/10.11_dbg/sql/sql_parse.cc:1434
      #21 0x00005a1d45503ac9 in do_handle_one_connection (connect=0x5a1d7bc90fe8, put_in_cache=true) at /test/10.11_dbg/sql/sql_connect.cc:1475
      #22 0x00005a1d45503862 in handle_one_connection (arg=0x5a1d7bc96568)at /test/10.11_dbg/sql/sql_connect.cc:1387
      #23 0x00007021cbc9caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #24 0x00007021cbd29c6c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed             
      CS  10.6   dbg  171225  478802a8edb45886b0f105280ed613414f6a580c  No bug found                  
      CS  10.6   opt  171225  478802a8edb45886b0f105280ed613414f6a580c  No bug found                  
      CS  10.11  dbg  060126  e309477815ee240c2c7fef559d16d869a5709cfd  SIGSEGV|__strlen_evex|set_to_string|Sys_var_set::valptr|Sys_var_set::session_value_ptr
      CS  10.11  opt  060126  e309477815ee240c2c7fef559d16d869a5709cfd  No bug found                  
      CS  11.4   dbg  121225  4cff562f3f89d4df03e09233d835d0451bc37cc4  No bug found                  
      CS  11.4   opt  121225  4cff562f3f89d4df03e09233d835d0451bc37cc4  No bug found                  
      CS  11.8   dbg  060126  c1fcedf443aa21ef626cd409d62b448a69858c81  No bug found                  
      CS  11.8   opt  060126  c1fcedf443aa21ef626cd409d62b448a69858c81  No bug found                  
      CS  12.1   dbg  121225  70117463f032d59f8e328335e19b59157d34cf07  No bug found                  
      CS  12.1   opt  121225  70117463f032d59f8e328335e19b59157d34cf07  No bug found                  
      CS  12.2   dbg  121225  997d0c4dfc551ea54faa1e9b7d56f3a0ff2ca849  No bug found                  
      CS  12.2   opt  121225  997d0c4dfc551ea54faa1e9b7d56f3a0ff2ca849  No bug found                  
      CS  12.3   dbg  060126  5ed3668890390060526434b92271756392d77869  No bug found                  
      CS  12.3   opt  060126  5ed3668890390060526434b92271756392d77869  No bug found                  
      ES  10.6   dbg  151225  bc33b05c6a65de27dbe811a30bc37c207d60ee8e  No bug found 
      ES  10.6   opt  151225  bc33b05c6a65de27dbe811a30bc37c207d60ee8e  No bug found 
      ES  11.4   dbg  151225  714f2134597e00f4ff107886cf3a55eff48e4510  No bug found                  
      ES  11.4   opt  151225  714f2134597e00f4ff107886cf3a55eff48e4510  No bug found                  
      ES  11.8   dbg  151225  4008de1a5b06105a64821db7b851328f1b27d99e  No bug found                  
      ES  11.8   opt  151225  4008de1a5b06105a64821db7b851328f1b27d99e  No bug found                  
      

      The assertion is happening after this commit

      commit 10643cffe98a42ee28a9f16b70ad7dff90563a03
      Author: Aleksey Midenkov <midenok@gmail.com>
      Date:   Tue Dec 23 13:42:45 2025 +0300
       
          MDEV-37325 Incorrect results for INTERSECT ALL in ORACLE mode
          
          Oracle mode has no priority between set-operators but the current
          implementation with disable_index_if_needed() can not work with
          arbitrary mix of distinct/non-distinct set-operators as the algorithm
          is tied to the properly wrapped version of expression. Index can be
          disabled only once and cannot be reenabled afterwards.
          
          To adapt Oracle mode for the aforementioned implementation we
          prioritize each set operator with parens in the order of
          appearance. So the expression:
          
            S1 op1 S2 op2 S3 op3 S4
          
          will be rewritten like this:
      

      Attachments

        Activity

          People

            holyfoot Alexey Botchkov
            ramesh Ramesh Sivaraman
            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.