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

Assertion failure in Column_definition::check_vcol_for_key upon adding FK

    XMLWordPrintable

Details

    Description

      --source include/have_innodb.inc
       
      CREATE TABLE t (a INT, b INT, c INT GENERATED ALWAYS AS (a), KEY(b), KEY(c)) ENGINE=InnoDB;
      --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
      ALTER TABLE t ADD FOREIGN KEY (a) REFERENCES t (b) ON UPDATE SET NULL, ALGORITHM=NOCOPY;
      ALTER TABLE t ADD FOREIGN KEY (a) REFERENCES t (b);
       
      # Cleanup
      DROP TABLE t;
      

      10.5 10eff9c8

      mariadbd: /data/src/10.5/sql/field.cc:11042: bool Column_definition::check_vcol_for_key(THD*) const: Assertion `thd->is_error()' failed.
      230805 17:41:41 [ERROR] mysqld got signal 6 ;
       
      #9  0x00007f7415253df2 in __GI___assert_fail (assertion=0x55fb2f038ee0 "thd->is_error()", file=0x55fb2f038800 "/data/src/10.5/sql/field.cc", line=11042, function=0x55fb2f043900 "bool Column_definition::check_vcol_for_key(THD*) const") at ./assert/assert.c:101
      #10 0x000055fb2d327031 in Column_definition::check_vcol_for_key (this=0x62b0000863e0, thd=0x62b00007e218) at /data/src/10.5/sql/field.cc:11042
      #11 0x000055fb2cdded67 in mysql_prepare_create_table (thd=0x62b00007e218, create_info=0x7f740736b450, alter_info=0x7f740736b320, db_options=0x7f7407367920, file=0x62b000086700, key_info_buffer=0x7f7407368bd0, key_count=0x7f7407368bb0, create_table_mode=-2) at /data/src/10.5/sql/sql_table.cc:4164
      #12 0x000055fb2cde7031 in mysql_create_frm_image (thd=0x62b00007e218, create_info=0x7f740736b450, alter_info=0x7f740736b320, create_table_mode=-2, key_info=0x7f7407368bd0, key_count=0x7f7407368bb0, frm=0x7f7407368c70) at /data/src/10.5/sql/sql_table.cc:5069
      #13 0x000055fb2cde8c89 in create_table_impl (thd=0x62b00007e218, orig_db=..., orig_table_name=..., db=..., table_name=..., path=0x7f740736aeee "./test/#sql-alter-180048-4", options=..., create_info=0x7f740736b450, alter_info=0x7f740736b320, create_table_mode=-2, is_trans=0x0, key_info=0x7f7407368bd0, key_count=0x7f7407368bb0, frm=0x7f7407368c70) at /data/src/10.5/sql/sql_table.cc:5349
      #14 0x000055fb2ce1088e in mysql_alter_table (thd=0x62b00007e218, new_db=0x62b000082ca8, new_name=0x62b0000830f8, create_info=0x7f740736b450, table_list=0x62b000085378, recreate_info=0x7f740736b280, alter_info=0x7f740736b320, order_num=0, order=0x0, ignore=false, if_exists=false) at /data/src/10.5/sql/sql_table.cc:10753
      #15 0x000055fb2cfb4470 in Sql_cmd_alter_table::execute (this=0x62b000085d18, thd=0x62b00007e218) at /data/src/10.5/sql/sql_alter.cc:591
      #16 0x000055fb2cb68f4a in mysql_execute_command (thd=0x62b00007e218) at /data/src/10.5/sql/sql_parse.cc:6083
      #17 0x000055fb2cb76485 in mysql_parse (thd=0x62b00007e218, rawbuf=0x62b000085238 "ALTER TABLE t ADD FOREIGN KEY (a) REFERENCES t (b)", length=50, parser_state=0x7f740736cc10, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:8118
      #18 0x000055fb2cb4be26 in dispatch_command (command=COM_QUERY, thd=0x62b00007e218, packet=0x629000280219 "ALTER TABLE t ADD FOREIGN KEY (a) REFERENCES t (b)", packet_length=50, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1891
      #19 0x000055fb2cb487b9 in do_command (thd=0x62b00007e218) at /data/src/10.5/sql/sql_parse.cc:1375
      #20 0x000055fb2cf9781f in do_handle_one_connection (connect=0x6080000039b8, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1416
      #21 0x000055fb2cf971e7 in handle_one_connection (arg=0x608000003938) at /data/src/10.5/sql/sql_connect.cc:1318
      #22 0x000055fb2dbe3cc2 in pfs_spawn_thread (arg=0x61500000c898) at /data/src/10.5/storage/perfschema/pfs.cc:2201
      #23 0x00007f74152a7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #24 0x00007f74153285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      The failure started happening after this commit in 10.5:

      commit da09ae05a9a744f184715e1eb35f2755681bd6b5
      Author:     Sergei Golubchik
      AuthorDate: Thu Jul 13 10:59:39 2023 +0200
      CommitDate: Wed Aug 2 14:45:31 2023 +0200
       
          MDEV-18114 Foreign Key Constraint actions don't affect Virtual Column
      

      Attachments

        Activity

          People

            serg Sergei Golubchik
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.