[MDEV-15553] Assertion `col_nr < table->n_def' failed in dict_table_get_col_name Created: 2018-03-13  Updated: 2018-04-05  Resolved: 2018-04-05

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB, Virtual Columns
Affects Version/s: 10.2, 10.3
Fix Version/s: 10.2.15, 10.3.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: None


 Description   

10.2 a05018977

mysqld: /data/src/10.2/storage/innobase/dict/dict0dict.cc:631: const char* dict_table_get_col_name(const dict_table_t*, ulint): Assertion `col_nr < table->n_def' failed.
180313  3:00:25 [ERROR] mysqld got signal 6 ;
 
#7  0x00007feb6bafdee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x000055e119eeb4c0 in dict_table_get_col_name (table=0x7feb1c00bf08, col_nr=7) at /data/src/10.2/storage/innobase/dict/dict0dict.cc:631
#9  0x000055e119efb41c in dict_foreign_qualify_index (table=0x7feb1c00bf08, col_names=0x0, columns=0x7feb64167930, n_cols=1, index=0x7feb1c034f98, types_idx=0x0, check_charsets=true, check_null=0, error=0x7feb64166700, err_col_no=0x7feb64166710, err_index=0x7feb64166708) at /data/src/10.2/storage/innobase/dict/dict0dict.cc:6987
#10 0x000055e119ef27bb in dict_foreign_find_index (table=0x7feb1c00bf08, col_names=0x0, columns=0x7feb64167930, n_cols=1, types_idx=0x0, check_charsets=true, check_null=0, error=0x7feb64166700, err_col_no=0x7feb64166710, err_index=0x7feb64166708) at /data/src/10.2/storage/innobase/dict/dict0dict.cc:3451
#11 0x000055e119ef5602 in dict_create_foreign_constraints_low (trx=0x7feb65a6e868, heap=0x7feb1c038310, cs=0x55e11ab26b00 <my_charset_latin1>, sql_string=0x7feb1c00c180 "ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing)", name=0x7feb64169da0 "test/#sql-67ea_9", reject_fks=0) at /data/src/10.2/storage/innobase/dict/dict0dict.cc:4830
#12 0x000055e119ef7010 in dict_create_foreign_constraints (trx=0x7feb65a6e868, sql_string=0x7feb1c0124f8 "ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing)", sql_length=84, name=0x7feb64169da0 "test/#sql-67ea_9", reject_fks=0) at /data/src/10.2/storage/innobase/dict/dict0dict.cc:5361
#13 0x000055e119d756b7 in row_table_add_foreign_constraints (trx=0x7feb65a6e868, sql_string=0x7feb1c0124f8 "ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing)", sql_length=84, name=0x7feb64169da0 "test/#sql-67ea_9", reject_fks=0) at /data/src/10.2/storage/innobase/row/row0mysql.cc:2559
#14 0x000055e119c40d4d in create_table_info_t::create_table (this=0x7feb64169d50) at /data/src/10.2/storage/innobase/handler/ha_innodb.cc:13038
#15 0x000055e119c4143c in ha_innobase::create (this=0x7feb1c07b588, name=0x7feb6416caec "./test/#sql-67ea_9", form=0x7feb6416a270, create_info=0x7feb6416ce50) at /data/src/10.2/storage/innobase/handler/ha_innodb.cc:13240
#16 0x000055e11992a5be in handler::ha_create (this=0x7feb1c07b588, name=0x7feb6416caec "./test/#sql-67ea_9", form=0x7feb6416a270, info_arg=0x7feb6416ce50) at /data/src/10.2/sql/handler.cc:4371
#17 0x000055e11992b4e6 in ha_create_table (thd=0x7feb1c000b00, path=0x7feb6416caec "./test/#sql-67ea_9", db=0x7feb1c012c60 "test", table_name=0x7feb6416c280 "#sql-67ea_9", create_info=0x7feb6416ce50, frm=0x7feb6416b5e0) at /data/src/10.2/sql/handler.cc:4742
#18 0x000055e119783092 in mysql_alter_table (thd=0x7feb1c000b00, new_db=0x7feb1c012c60 "test", new_name=0x0, create_info=0x7feb6416ce50, table_list=0x7feb1c012650, alter_info=0x7feb6416cda0, order_num=0, order=0x0, ignore=false) at /data/src/10.2/sql/sql_table.cc:9408
#19 0x000055e1197fc954 in Sql_cmd_alter_table::execute (this=0x7feb1c012e70, thd=0x7feb1c000b00) at /data/src/10.2/sql/sql_alter.cc:324
#20 0x000055e1196b7c57 in mysql_execute_command (thd=0x7feb1c000b00) at /data/src/10.2/sql/sql_parse.cc:6208
#21 0x000055e1196bc5d1 in mysql_parse (thd=0x7feb1c000b00, rawbuf=0x7feb1c0124f8 "ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing)", length=84, parser_state=0x7feb6416e200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7902
#22 0x000055e1196aa4f1 in dispatch_command (command=COM_QUERY, thd=0x7feb1c000b00, packet=0x7feb1c08d0d1 "ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing)", packet_length=84, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1806
#23 0x000055e1196a8e54 in do_command (thd=0x7feb1c000b00) at /data/src/10.2/sql/sql_parse.cc:1360
#24 0x000055e1197f7646 in do_handle_one_connection (connect=0x55e11c091e80) at /data/src/10.2/sql/sql_connect.cc:1335
#25 0x000055e1197f73d3 in handle_one_connection (arg=0x55e11c091e80) at /data/src/10.2/sql/sql_connect.cc:1241
#26 0x000055e119c171f8 in pfs_spawn_thread (arg=0x55e11bff57c0) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#27 0x00007feb6d7d4494 in start_thread (arg=0x7feb6416f700) at pthread_create.c:333
#28 0x00007feb6bbba93f in clone () from /lib/x86_64-linux-gnu/libc.so.6

--source include/have_innodb.inc
 
CREATE TABLE t1 ( 
  c1 TIMESTAMP,
  c2 YEAR,
  c3 TIME,
  c4 CHAR(10),
  v1 TIMESTAMP AS (c1) VIRTUAL,
  v2 YEAR AS (c2) VIRTUAL,
  v3 TIME AS (c3) VIRTUAL,
  v4 CHAR(10) AS (c4) VIRTUAL
) ENGINE=InnoDB;
 
--error ER_CANT_CREATE_TABLE
ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing);
 
# Cleanup
DROP TABLE t1;

10.3 variation:

10.3 556a920

mysqld: /data/src/10.3/storage/innobase/include/dict0dict.ic:488: dict_col_t* dict_table_get_nth_col(const dict_table_t*, ulint): Assertion `pos < table->n_def' failed.
180331  3:40:35 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f5f9b4d4ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000558446ad8a60 in dict_table_get_nth_col (table=0x7f5f4c175a68, pos=7) at /data/src/10.3/storage/innobase/include/dict0dict.ic:488
#9  0x0000558446b0375b in dict_table_get_col_name (table=0x7f5f4c175a68, col_nr=7) at /data/src/10.3/storage/innobase/include/dict0dict.h:893
#10 0x0000558446dd9732 in dict_foreign_qualify_index (table=0x7f5f4c175a68, col_names=0x0, columns=0x7f5f948134a0, n_cols=1, index=0x7f5f4c176da8, types_idx=0x0, check_charsets=true, check_null=0, error=0x7f5f94812270, err_col_no=0x7f5f94812280, err_index=0x7f5f94812278) at /data/src/10.3/storage/innobase/dict/dict0dict.cc:6902
#11 0x0000558446dd05ce in dict_foreign_find_index (table=0x7f5f4c175a68, col_names=0x0, columns=0x7f5f948134a0, n_cols=1, types_idx=0x0, check_charsets=true, check_null=0, error=0x7f5f94812270, err_col_no=0x7f5f94812280, err_index=0x7f5f94812278) at /data/src/10.3/storage/innobase/dict/dict0dict.cc:3392
#12 0x0000558446dd34a9 in dict_create_foreign_constraints_low (trx=0x7f5f953108c8, heap=0x7f5f4c0390d0, cs=0x558447b0d780 <my_charset_latin1>, sql_string=0x7f5f4c00f120 "ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing)", name=0x7f5f94815910 "test/#sql-4c1d_9", reject_fks=0) at /data/src/10.3/storage/innobase/dict/dict0dict.cc:4771
#13 0x0000558446dd4ebc in dict_create_foreign_constraints (trx=0x7f5f953108c8, sql_string=0x7f5f4c014d58 "ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing)", sql_length=84, name=0x7f5f94815910 "test/#sql-4c1d_9", reject_fks=0) at /data/src/10.3/storage/innobase/dict/dict0dict.cc:5302
#14 0x0000558446c40f70 in row_table_add_foreign_constraints (trx=0x7f5f953108c8, sql_string=0x7f5f4c014d58 "ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing)", sql_length=84, name=0x7f5f94815910 "test/#sql-4c1d_9", reject_fks=0) at /data/src/10.3/storage/innobase/row/row0mysql.cc:2660
#15 0x0000558446af164f in create_table_info_t::create_table (this=0x7f5f948158c0) at /data/src/10.3/storage/innobase/handler/ha_innodb.cc:12500
#16 0x0000558446af1e82 in ha_innobase::create (this=0x7f5f4c171cd8, name=0x7f5f948188cd "./test/#sql-4c1d_9", form=0x7f5f94815de0, create_info=0x7f5f94818c50) at /data/src/10.3/storage/innobase/handler/ha_innodb.cc:12690
#17 0x00005584467d420e in handler::ha_create (this=0x7f5f4c171cd8, name=0x7f5f948188cd "./test/#sql-4c1d_9", form=0x7f5f94815de0, info_arg=0x7f5f94818c50) at /data/src/10.3/sql/handler.cc:4556
#18 0x00005584467d525c in ha_create_table (thd=0x7f5f4c000b00, path=0x7f5f948188cd "./test/#sql-4c1d_9", db=0x7f5f4c015500 "test", table_name=0x7f5f9481840a "#sql-4c1d_9", create_info=0x7f5f94818c50, frm=0x7f5f948171f0) at /data/src/10.3/sql/handler.cc:4928
#19 0x00005584465c1006 in mysql_alter_table (thd=0x7f5f4c000b00, new_db=0x7f5f4c005158, new_name=0x7f5f4c005508, create_info=0x7f5f94818c50, table_list=0x7f5f4c014eb0, alter_info=0x7f5f94818b90, order_num=0, order=0x0, ignore=false) at /data/src/10.3/sql/sql_table.cc:9889
#20 0x0000558446646392 in Sql_cmd_alter_table::execute (this=0x7f5f4c015720, thd=0x7f5f4c000b00) at /data/src/10.3/sql/sql_alter.cc:334
#21 0x00005584464eb7bd in mysql_execute_command (thd=0x7f5f4c000b00) at /data/src/10.3/sql/sql_parse.cc:6284
#22 0x00005584464f0390 in mysql_parse (thd=0x7f5f4c000b00, rawbuf=0x7f5f4c014d58 "ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing)", length=84, parser_state=0x7f5f9481a5d0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:8013
#23 0x00005584464dda43 in dispatch_command (command=COM_QUERY, thd=0x7f5f4c000b00, packet=0x7f5f4c125fd1 "ALTER TABLE t1 ADD CONSTRAINT FOREIGN KEY (v4) REFERENCES non_existing(non_existing)", packet_length=84, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1842
#24 0x00005584464dc482 in do_command (thd=0x7f5f4c000b00) at /data/src/10.3/sql/sql_parse.cc:1387
#25 0x0000558446640d85 in do_handle_one_connection (connect=0x558449080cc0) at /data/src/10.3/sql/sql_connect.cc:1402
#26 0x0000558446640b12 in handle_one_connection (arg=0x558449080cc0) at /data/src/10.3/sql/sql_connect.cc:1308
#27 0x0000558446ac7979 in pfs_spawn_thread (arg=0x558449088f30) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#28 0x00007f5f9d1ab494 in start_thread (arg=0x7f5f9481b700) at pthread_create.c:333
#29 0x00007f5f9b59193f in clone () from /lib/x86_64-linux-gnu/libc.so.6



 Comments   
Comment by Marko Mäkelä [ 2018-04-05 ]

The problem is that the MySQL 5.7 implementation of virtual columns in InnoDB is artificially separating virtual and stored column names. The function dict_table_get_col_name() must not be called on virtual columns.

Generated at Thu Feb 08 08:22:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.