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

create table ... as select ... results in ghost tdc if opening the table fails

Details

    Description

      If

      create table ... as select ...

      fails at opening the table, then it does not clear the table from the
      table cache, and a subsequent create table with the same name would
      fail with 1050 ER_TABLE_EXISTS_ERROR, while a subsequent drop table
      with the same name would fail with 1051 ER_BAD_TABLE_ERROR.

      Here's an example with spider at 11.4
      4c9fd4f45b2be8f446777bf470e9352cd3e7c092, but presumably any table
      creation failing at opening the table in any version should suffice:

      install soname 'ha_spider';
      set spider_same_server_link= 1;
      evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
      OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
      --error 1205
      create table t (c int) engine=spider comment='srv "srv"' as select 1;
      # fails with error 1050 ER_TABLE_EXISTS_ERROR
      # create table t (c int);
      # fails with error 1051 ER_BAD_TABLE_ERROR
      # drop table t;
      # also fails with error 1051 ER_BAD_TABLE_ERROR
      # create or replace table t (c int);
      

      Attachments

        Issue Links

          Activity

            ycp Yuchen Pei added a comment -

            Turns out the relevant if branch is not covered in testing:

            modified   sql/sql_insert.cc
            @@ -4738,6 +4738,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
                   */
                   if (open_table(thd, table_list, &ot_ctx))
                   {
            +        abort();
                     quick_rm_table(thd, create_info->db_type, &table_list->db,
                                    table_case_name(create_info, &table_list->table_name),
                                    0);

            See https://buildbot.mariadb.org/#grid?branch=bb-11.4-mdev-35783-debug 4037ed0164f44c546d0705b9adfd607b8f788222. It does get triggered in the testcase in the description as expected.

            ycp Yuchen Pei added a comment - Turns out the relevant if branch is not covered in testing: modified sql/sql_insert.cc @@ -4738,6 +4738,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items, */ if (open_table(thd, table_list, &ot_ctx)) { + abort(); quick_rm_table(thd, create_info->db_type, &table_list->db, table_case_name(create_info, &table_list->table_name), 0); See https://buildbot.mariadb.org/#grid?branch=bb-11.4-mdev-35783-debug 4037ed0164f44c546d0705b9adfd607b8f788222. It does get triggered in the testcase in the description as expected.

            People

              ycp Yuchen Pei
              ycp Yuchen Pei
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.