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

Creating table with certain generated column crashes server

    XMLWordPrintable

Details

    Description

      Consider the following table definition:

      CREATE TABLE crash_test_1 (
      DATA_VALUE CHAR(10) NULL,
      HAS_DATA BIT NOT NULL,
      TEST_COLUMN CHAR(10) AS (CASE WHEN HAS_DATA = 1 THEN DATA_VALUE ELSE NULL END) STORED
      );

      On creating or selecting from this table, I receive the following warning:

      Function or expression 'case when "HAS_DATA" = 1 then "DATA VALUE" else NULL end' cannot be used in the GENERATED ALWAYS AS clause of `TEST_COLUMN`
      Warning: Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH

      So, as per the documentation, I tried using RPAD:

      CREATE TABLE crash_test_2 (
      DATA_VALUE CHAR(10) NULL,
      HAS_DATA BIT NOT NULL,
      TEST_COLUMN CHAR(10) AS (RPAD(CASE WHEN HAS_DATA = 1 THEN DATA_VALUE ELSE NULL END, 10)) STORED
      );

      Here is the real problem. Attempting to create crash_test_2 causes the server to crash. Some info from the error log:

      [ERROR] mysqld got exception 0xc0000005 ;

      mysqld.exe!Item_func_rpad::value_depends_on_sql_mode()[item_strfunc.cc:3262]
      mysqld.exe!Field::check_vcol_sql_mode_dependency()[field.cc:1411]
      mysqld.exe!parse_vcol_defs()[table.cc:1185]
      mysqld.exe!open_table_from_share()[table.cc:3846]
      mysqld.exe!ha_create_table()[handler.cc:5237]
      mysqld.exe!create_table_impl()[sql_table.cc:5094]
      mysqld.exe!mysql_create_table_no_lock()[sql_table.cc:5182]
      mysqld.exe!mysql_create_table()[sql_table.cc:5274]
      mysqld.exe!Sql_cmd_create_table_like::execute()[sql_table.cc:11503]
      mysqld.exe!mysql_execute_command()[sql_parse.cc:6153]
      mysqld.exe!mysql_parse()[sql_parse.cc:7942]
      mysqld.exe!dispatch_command()[sql_parse.cc:1842]
      mysqld.exe!do_command()[sql_parse.cc:1357]
      mysqld.exe!threadpool_process_request()[threadpool_common.cc:374]
      mysqld.exe!tp_callback()[threadpool_common.cc:192]
      ntdll.dll!TpAllocPool()
      ntdll.dll!TpReleaseCleanupGroupMembers()
      KERNEL32.DLL!BaseThreadInitThunk()
      ntdll.dll!RtlUserThreadStart()

      Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on

      Attachments

        Activity

          People

            nikitamalyavin Nikita Malyavin
            novog Christopher Granahan
            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.