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

Dump DDLs of tables/views does not work for multi-delete (n=3) if there is data to delete

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 12.1
    • 12.1.1
    • Optimizer
    • None
    • Unexpected results

    Description

      I got interesting behavior when doing multiple DELETE from three tables when there was data to delete: there was an empty ddl in information_schema.optimizer_trace, but if I use "explain delete ..." or conditions under which there was no data to delete , I got a normal table description.
      Testcase:

      set optimizer_trace=1;
      set optimizer_record_context=ON;
       
      create table t1(id1 int not null auto_increment primary key, t char(12));
      create table t2(id2 int not null, t char(12));
      create table t3(id3 int not null, t char(12));
      --disable_query_log
      begin;
      let $1 = 100;
      while ($1)
       {
        let $2 = 5;
        eval insert into t1(t) values ('$1');
        while ($2)
         {
           eval insert into t2(id2,t) values ($1,'$2');
           let $3 = 10;
           while ($3)
           {
             eval insert into t3(id3,t) values ($1,'$2');
             dec $3;
           }
           dec $2;
         }
        dec $1;
       }
      commit;
      --enable_query_log
       
      select count(*) from t1 where id1 > 95;
      select count(*) from t2 where id2 > 95;
      select count(*) from t3 where id3 > 95;
       
      delete t1.*, t2.*, t3.*  from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 95;
      set @ddls= (select json_detailed(json_extract(trace, '$**.ddl')) from information_schema.optimizer_trace);
      select ddl
      from json_table(@ddls, '$[*]' columns(ddl text path '$')) as jt;
       
      delete t1.*, t2.*, t3.*  from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 95;
      set @ddls= (select json_detailed(json_extract(trace, '$**.ddl')) from information_schema.optimizer_trace);
      select ddl
      from json_table(@ddls, '$[*]' columns(ddl text path '$')) as jt;
       
      drop table t1, t2, t3;
      

      Actual result:
      First call of DELETE - there is no data in the dll, the second - there is:

      delete t1.*, t2.*, t3.*  from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 95;
      set @ddls= (select json_detailed(json_extract(trace, '$**.ddl')) from information_schema.optimizer_trace);
      select ddl
      from json_table(@ddls, '$[*]' columns(ddl text path '$')) as jt;
      ddl
      delete t1.*, t2.*, t3.*  from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 95;
      set @ddls= (select json_detailed(json_extract(trace, '$**.ddl')) from information_schema.optimizer_trace);
      select ddl
      from json_table(@ddls, '$[*]' columns(ddl text path '$')) as jt;
      ddl
      CREATE TABLE `t3` (
        `id3` int(11) NOT NULL,
        `t` char(12) DEFAULT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
      CREATE TABLE `t2` (
        `id2` int(11) NOT NULL,
        `t` char(12) DEFAULT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
      CREATE TABLE `t1` (
        `id1` int(11) NOT NULL AUTO_INCREMENT,
        `t` char(12) DEFAULT NULL,
        PRIMARY KEY (`id1`)
      ) ENGINE=MyISAM AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
      

      Attachments

        Issue Links

          Activity

            People

              bsrikanth Srikanth Bondalapati
              lstartseva Lena Startseva
              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.