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

FK Reference issue in Aria (or InnoDB) + Assertion `!parse_error || lex.sphead == 0' failed in Table_triggers_list::check_n_load

    XMLWordPrintable

    Details

      Description

      Whereas this bug is very similar and likely related to MDEV-22883 and MDEV-18496 there is something very Aria-specific happening. In InnoDB:

      10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

      10.5.6>USE test;
      Database changed
      10.5.6>SET SQL_MODE='';
      Query OK, 0 rows affected (0.000 sec)
      10.5.6>CREATE TABLE t (C1 CHAR (1) PRIMARY KEY, FOREIGN KEY(C1) REFERENCES t (C1)) ENGINE=InnoDB;
      ERROR 1005 (HY000): Can't create table `test`.`t` (errno: 150 "Foreign key constraint is incorrectly formed")
      

      And in Aria:

      10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

      10.5.6>USE test;
      Database changed
      10.5.6>SET SQL_MODE='';
      Query OK, 0 rows affected (0.000 sec)
      10.5.6>CREATE TABLE t (C1 CHAR (1) PRIMARY KEY, FOREIGN KEY(C1) REFERENCES t (C1)) ENGINE=Aria;
      Query OK, 0 rows affected (0.011 sec)
      

      Note that no encryption is used, and Aria allowed the FK reference which InnoDB rejects.

      The surrounding issue is that a crash can be generated if encryption is enabled.

      USE test;
      SET SQL_MODE='';
      SET GLOBAL aria_encrypt_tables=ON;
      CREATE TABLE t (C1 CHAR (1) PRIMARY KEY, FOREIGN KEY(C1) REFERENCES t (C1)) ENGINE=Aria;
      CREATE TRIGGER tr1_bi BEFORE INSERT ON t FOR EACH ROW SET @a:=1;
      INSERT INTO t VALUES (str_to_date ('abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'));
      RENAME TABLE t TO t3,t TO t,t2 TO t;
      

      Leads to:

      10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

      mysqld: /test/10.5_dbg/sql/sql_trigger.cc:1460: static bool Table_triggers_list::check_n_load(THD*, const LEX_CSTRING*, const LEX_CSTRING*, TABLE*, bool): Assertion `!parse_error || lex.sphead == 0' failed.
      

      10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

      Core was generated by `/test/MD150920-mariadb-10.5.6-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
          at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      [Current thread is 1 (Thread 0x14fd8fd15700 (LWP 3550511))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      #1  0x000055e157f8985a in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:424
      #2  0x000055e1577503a9 in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:330
      #3  <signal handler called>
      #4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
      #5  0x000014fd8dfab8b1 in __GI_abort () at abort.c:79
      #6  0x000014fd8df9b42a in __assert_fail_base (fmt=0x14fd8e122a38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55e158127f60 "!parse_error || lex.sphead == 0", file=file@entry=0x55e158127bc0 "/test/10.5_dbg/sql/sql_trigger.cc", line=line@entry=1460, function=function@entry=0x55e1581288e0 <Table_triggers_list::check_n_load(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, TABLE*, bool)::__PRETTY_FUNCTION__> "static bool Table_triggers_list::check_n_load(THD*, const LEX_CSTRING*, const LEX_CSTRING*, TABLE*, bool)") at assert.c:92
      #7  0x000014fd8df9b4a2 in __GI___assert_fail (assertion=assertion@entry=0x55e158127f60 "!parse_error || lex.sphead == 0", file=file@entry=0x55e158127bc0 "/test/10.5_dbg/sql/sql_trigger.cc", line=line@entry=1460, function=function@entry=0x55e1581288e0 <Table_triggers_list::check_n_load(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, TABLE*, bool)::__PRETTY_FUNCTION__> "static bool Table_triggers_list::check_n_load(THD*, const LEX_CSTRING*, const LEX_CSTRING*, TABLE*, bool)") at assert.c:101
      #8  0x000055e157580e98 in Table_triggers_list::check_n_load (thd=thd@entry=0x14fd6bc15088, db=db@entry=0x14fd6bc741e0, table_name=table_name@entry=0x14fd6bc741f0, table=table@entry=0x14fd8fd134c0, names_only=names_only@entry=true) at /test/10.5_dbg/sql/sql_trigger.cc:1460
      #9  0x000055e157581eb6 in Table_triggers_list::change_table_name (thd=thd@entry=0x14fd6bc15088, db=db@entry=0x14fd6bc741e0, old_alias=old_alias@entry=0x14fd8fd13a00, old_table=old_table@entry=0x14fd6bc741f0, new_db=new_db@entry=0x14fd6bc748c0, new_table=new_table@entry=0x14fd8fd13a10) at /test/10.5_dbg/sql/sql_trigger.cc:2106
      #10 0x000055e1574c6a4f in do_rename (force_if_exists=0x14fd8fd13adf, if_exists=false, skip_error=false, new_table_alias=0x14fd6bc748f0, new_table_name=0x14fd6bc748d0, new_db=0x14fd6bc748c0, ren_table=0x14fd6bc741c8, thd=0x14fd6bc15088) at /test/10.5_dbg/sql/sql_rename.cc:345
      #11 rename_tables (thd=thd@entry=0x14fd6bc15088, table_list=table_list@entry=0x14fd6bc741c8, skip_error=skip_error@entry=false, if_exists=if_exists@entry=false, force_if_exists=force_if_exists@entry=0x14fd8fd13adf) at /test/10.5_dbg/sql/sql_rename.cc:421
      #12 0x000055e1574c6dbb in mysql_rename_tables (thd=thd@entry=0x14fd6bc15088, table_list=table_list@entry=0x14fd6bc741c8, silent=silent@entry=false, if_exists=<optimized out>) at /test/10.5_dbg/sql/sql_rename.cc:159
      #13 0x000055e15749e279 in mysql_execute_command (thd=thd@entry=0x14fd6bc15088) at /test/10.5_dbg/sql/sql_parse.cc:4314
      #14 0x000055e1574aa324 in mysql_parse (thd=thd@entry=0x14fd6bc15088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14fd8fd14350, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7994
      #15 0x000055e157496d54 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14fd6bc15088, packet=packet@entry=0x14fd6bc67089 "RENAME TABLE t TO t3,t TO t,t2 TO t", packet_length=packet_length@entry=35, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1867
      #16 0x000055e15749553e in do_command (thd=0x14fd6bc15088) at /test/10.5_dbg/sql/sql_parse.cc:1348
      #17 0x000055e1575f4893 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x14fd6f0d4808, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1410
      #18 0x000055e1575f4fb7 in handle_one_connection (arg=arg@entry=0x14fd6f0d4808) at /test/10.5_dbg/sql/sql_connect.cc:1312
      #19 0x000055e157a5f5c2 in pfs_spawn_thread (arg=0x14fd8c846508) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
      #20 0x000014fd8ec8e6db in start_thread (arg=0x14fd8fd15700) at pthread_create.c:463
      #21 0x000014fd8e08ca3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.1.47 (dbg), 10.2.34 (dbg), 10.3.25 (dbg), 10.4.15 (dbg), 10.5.6 (dbg), 10.6.0 (dbg)

      Bug confirmed not present in:
      MariaDB: 10.1.47 (opt), 10.2.34 (opt), 10.3.25 (opt), 10.4.15 (opt), 10.5.6 (opt), 10.6.0 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.49 (dbg), 5.6.49 (opt), 5.7.31 (dbg), 5.7.31 (opt), 8.0.21 (dbg), 8.0.21 (opt)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              monty Michael Widenius
              Reporter:
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: