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

MDEV-35731 Assertion `(mem_root->flags & 4) == 0' failed upon 2nd execution of UPDATE with FK

Details

    Description

      The assertion fails upon 2nd execution of UPDATE, when a foreign key relation is added by ALTER TABLE in between the two executions:

      --source include/have_innodb.inc
       
      create table t1 (x int, key(x)) engine=innodb;
      insert t1 values(0), (1);
      create table t2 (x int, v int as (x+1), key(v)) engine=innodb;
      insert t2(x) values(1);
       
      prepare stmt from 'update t1 set x = x + 1';
      execute stmt;
      alter table t2 add foreign key (x) references t1(x) on update cascade;
      execute stmt;
      select v from t2 use index(v);
      deallocate prepare stmt;
      drop table t2, t1;
      

      The second execution results in:

      10.5

      mariadbd: /home/nik/work/mariadb/mysys/my_alloc.c:212: void *alloc_root(MEM_ROOT *, size_t): Assertion `(mem_root->flags & 4) == 0' failed.
       
      mysys/my_alloc.c:212(alloc_root)[0x55568533adbe]
      sql/sql_class.h:4031(THD::make_clex_string(char const*, unsigned long))[0x555682d88a76]
      sql/sql_class.cc:1175(thd_make_lex_string)[0x555683569917]
      handler/ha_innodb.cc:15245(get_foreign_key_info(THD*, dict_foreign_t*))[0x5556847139c8]
      handler/ha_innodb.cc:15435(ha_innobase::get_parent_foreign_key_list(THD*, List<st_foreign_key_info>*))[0x5556847151a4]
      sql/sql_base.cc:4660(prepare_fk_prelocking_list(THD*, Query_tables_list*, TABLE_LIST*, bool*, unsigned char))[0x555683528f1f]
      sql/sql_base.cc:4745(DML_prelocking_strategy::handle_table(THD*, Query_tables_list*, TABLE_LIST*, bool*))[0x5556834ff13f]
      sql/sql_base.cc:3581(extend_table_list(THD*, TABLE_LIST*, Prelocking_strategy*, bool))[0x5556834f7ff5]
      sql/sql_base.cc:3879(open_and_process_table(THD*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*))[0x5556834fcdd7]
      sql/sql_base.cc:4303(open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*))[0x5556834f9524]
      sql/sql_base.h:479(open_tables(THD*, TABLE_LIST**, unsigned int*, unsigned int))[0x5556834dabe1]
      sql/sql_update.cc:415(mysql_update(THD*, TABLE_LIST*, List<Item>&, List<Item>&, Item*, unsigned int, st_order*, unsigned long long, bool, unsigned long long*, unsigned long long*))[0x555683c960f4]
      sql/sql_parse.cc:4507(mysql_execute_command(THD*))[0x5556838a02f3]
      sql/sql_prepare.cc:5141(Prepared_statement::execute(String*, bool))[0x5556839664cb]
      sql/sql_prepare.cc:4563(Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*))[0x55568395a7c0]
      sql/sql_prepare.cc:3604(mysql_sql_stmt_execute(THD*))[0x555683959b50]
      sql/sql_parse.cc:4059(mysql_execute_command(THD*))[0x55568389d33d]
      sql/sql_parse.cc:8251(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55568388b628]
      

      sql/sql_class.h:1287(Query_arena::strmake(char const*, unsigned long) const)[0x59fe6c45e4ce]
      sql/sql_class.cc:1211(thd_strmake)[0x59fe6cc11289]
      sql/lex_string.h:136(Lex_cstring::set_dup(THD const*, char const*, unsigned long))[0x59fe6df10d31]
      sql/lex_string.h:143(Lex_cstring::set_dup(THD const*, char const*))[0x59fe6df10cf9]
      handler/ha_innodb.cc:15435(get_foreign_key_info(THD*, dict_foreign_t*))[0x59fe6deb83f2]
      handler/ha_innodb.cc:15605(ha_innobase::get_parent_foreign_key_list(THD*, List<st_foreign_key_info>*))[0x59fe6deb9bd4]
      sql/sql_base.cc:5059(prepare_fk_parent_prelocking_list(THD*, Query_tables_list*, TABLE_LIST*, Prelocking_strategy const*, bool*, unsigned char))[0x59fe6cbd080a]
      sql/sql_base.cc:5159(DML_prelocking_strategy::handle_table(THD*, Query_tables_list*, TABLE_LIST*, bool*))[0x59fe6cba28da]
      sql/sql_base.cc:3930(extend_table_list(THD*, TABLE_LIST*, Prelocking_strategy*, bool))[0x59fe6cb9b3f6]
      sql/sql_base.cc:4236(open_and_process_table(THD*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*))[0x59fe6cba052a]
      sql/sql_base.cc:4662(open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*))[0x59fe6cb9c924]
      sql/sql_base.h:273(open_tables(THD*, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*))[0x59fe6cba8f67]
      sql/sql_base.cc:5821(open_tables_for_query(THD*, TABLE_LIST*, unsigned int*, unsigned int, DML_prelocking_strategy*))[0x59fe6cba9763]
      sql/sql_select.cc:34220(Sql_cmd_dml::prepare(THD*))[0x59fe6d19d127]
      sql/sql_select.cc:34282(Sql_cmd_dml::execute(THD*))[0x59fe6d19d669]
      sql/sql_parse.cc:4415(mysql_execute_command(THD*, bool))[0x59fe6cf545e5]
      sql/sql_prepare.cc:5051(Prepared_statement::execute(String*, bool))[0x59fe6d023572]
      sql/sql_prepare.cc:4428(Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*))[0x59fe6d017232]
      sql/sql_prepare.cc:3447(mysql_sql_stmt_execute(THD*))[0x59fe6d0166a0]
      sql/sql_parse.cc:3982(mysql_execute_command(THD*, bool))[0x59fe6cf51970]
      sql/sql_parse.cc:7901(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x59fe6cf404bc]
      

      Attachments

        Issue Links

          Activity

            There are no comments yet on this issue.

            People

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