Commit 8ebadc5d authored by Sinisa@sinisa.nasamreza.org's avatar Sinisa@sinisa.nasamreza.org
Browse files

A fix for multi-table delete with tables optimised away.

Still not able to make a proper test case as this crashes on files 
where key and data pointers are 4 bytes each. Possibly a proper 
test case would require myisampack.
parent 2aecdd1a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ select count(*) from t3 where id3;
count(*)
0
drop table t1,t2,t3;
create table t1(id1 int not null auto_increment primary key, t varchar(100));
create table t2(id2 int not null, t varchar(100), index(id2));
delete t1, t2  from t2,t1 where t1.id1 = t2.id2 and t1.id1 > 100;
create table t1(id1 int not null  primary key, t varchar(100)) pack_keys = 1;
create table t2(id2 int not null, t varchar(100), index(id2)) pack_keys = 1;
delete t1  from t1,t2 where t1.id1 = t2.id2 and t1.id1 > 500;
drop table t1,t2;
+4 −4
Original line number Diff line number Diff line
@@ -62,14 +62,14 @@ select count(*) from t2 where id2;
select count(*) from t3 where id3;

drop table t1,t2,t3;
create table t1(id1 int not null auto_increment primary key, t varchar(100));
create table t2(id2 int not null, t varchar(100), index(id2));
create table t1(id1 int not null  primary key, t varchar(100)) pack_keys = 1;
create table t2(id2 int not null, t varchar(100), index(id2)) pack_keys = 1;
disable_query_log;
let $1 = 1000;
while ($1)
 {
  let $2 = 5;
  eval insert into t1(t) values ('aaaaaaaaaaaaaaaaaaaa'); 
  eval insert into t1 values ($1,'aaaaaaaaaaaaaaaaaaaa'); 
  while ($2)
   {
     eval insert into t2(id2,t) values ($1,'bbbbbbbbbbbbbbbbb'); 
@@ -78,5 +78,5 @@ while ($1)
  dec $1;
 }
enable_query_log;
delete t1, t2  from t2,t1 where t1.id1 = t2.id2 and t1.id1 > 100;
delete t1  from t1,t2 where t1.id1 = t2.id2 and t1.id1 > 500;
drop table t1,t2;
+4 −4
Original line number Diff line number Diff line
@@ -273,11 +273,11 @@ multi_delete::initialize_tables(JOIN *join)
    if (tab->table->map & tables_to_delete_from)
    {
      /* We are going to delete from this table */
      walk->table=tab->table;
      TABLE *tbl=walk->table=tab->table;
      tbl->no_keyread=1;
      tbl->used_keys=0;
      walk=walk->next;
      if (tab == join->join_tab)
	tab->table->no_keyread=1;
      if (!not_trans_safe && !tab->table->file->has_transactions())
      if (!not_trans_safe && !tbl->file->has_transactions())
	not_trans_safe=true;
    }
  }
+1 −0
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length)
  lex->yacc_yyss=lex->yacc_yyvs=0;
  lex->ignore_space=test(thd->sql_mode & MODE_IGNORE_SPACE);
  lex->slave_thd_opt=0;
  lex->sql_command=SQLCOM_END;
  bzero(&lex->mi,sizeof(lex->mi));
  return lex;
}
+5 −1
Original line number Diff line number Diff line
@@ -1960,7 +1960,11 @@ mysql_execute_command(void)
      }
      auxi->lock_type=walk->lock_type=TL_WRITE;
      auxi->table= (TABLE *) walk;		// Remember corresponding table
      (void)add_item_to_list(new Item_field(auxi->db,auxi->real_name,"*"));
    }
    if (add_item_to_list(new Item_null()))
    {
      res = -1;
      break;
    }
    tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege);
    thd->proc_info="init";