diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index a1ebc64504f..2b7c8587dc4 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -2,25 +2,34 @@ drop table if exists t1,t2,t3; create table t1(id1 int not null auto_increment primary key, t char(12)); create table t2(id2 int not null, t char(12), index(id2)); create table t3(id3 int not null, t char(12), index(id3)); -let $1 = 3; +let $1 = 10000; while ($1) { - let $2 = 3; + let $2 = 5; eval insert into t1(t) values ('$1'); while ($2) { eval insert into t2(id2,t) values ($1,'$2'); - eval insert into t3(id3,t) values ($1,'$2'); + let $3 = 10; + while ($3) + { + eval insert into t3(id3,t) values ($1,'$2'); + dec $3; + } dec $2; } dec $1; } -delete t1.*,t2.* from t1,t2 where t1.id1 = t2.id2 and t1.id1 = 3; -delete t3 from t3 left join t1 on (id1=id3) where t1.id1 is null; -delete t2 from t1,t2,t3 where id1=id2 and id2=id3 and id1=2; -select * from t1; -select * from t2; -select * from t3; -delete t1,t2 from t1,t2 where 1; -drop table t1,t2,t3; +delete t1.*, t2.*, t3.* from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 9500; + +check table t1, t2, t3; + +select * from t1 where id1 > 9500; +select * from t2 where id2 > 9500; +select * from t3 where id3 > 9500; + +delete t1, t2, t3 from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 500; +select * from t1 where id1 > 500; +select * from t2 where id2 > 500; +select * from t3 where id3 > 500; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 0376ef09ee1..dc07d81f8f2 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -383,7 +383,7 @@ multi_delete::~multi_delete() if (tempfiles[counter]) { #ifdef SINISAS_STRIP -// end_io_cache(tempfiles[counter]); + end_io_cache(tempfiles[counter]); #else delete tempfiles[counter]; #endif @@ -594,12 +594,15 @@ static IO_CACHE *strip_duplicates_from_temp (byte *memory_lane, IO_CACHE *ptr, u int read_error, write_error, how_many_to_read, total_to_read = *written, pieces_in_memory = 0, mem_count,written_rows; int offset = written_rows=*written=0; int mem_pool_size = MEM_STRIP_BUF_SIZE * MAX_REFLENGTH / ref_length; - IO_CACHE *tempptr = (IO_CACHE *) sql_alloc(sizeof(IO_CACHE)); byte dup_record[MAX_REFLENGTH]; memset(dup_record,'\xFF',MAX_REFLENGTH); if (reinit_io_cache(ptr,READ_CACHE,0L,0,0)) return ptr; + IO_CACHE *tempptr = (IO_CACHE *) my_malloc(sizeof(IO_CACHE), MYF(MY_FAE | MY_ZEROFILL)); if (open_cached_file(tempptr, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, MYF(MY_WME))) + { + my_free((gptr) tempptr, MYF (0)); return ptr; + } DYNAMIC_ARRAY written_blocks; VOID(init_dynamic_array(&written_blocks,sizeof(struct written_block),20,50)); for (;pieces_in_memory < total_to_read;) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6b71d7e3615..88d42cbbebb 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2438,6 +2438,12 @@ mysql_new_select(LEX *lex) SELECT_LEX *select_lex = (SELECT_LEX *)sql_calloc(sizeof(SELECT_LEX)); lex->select->next=select_lex; lex->select=select_lex; lex->select->select_number = ++select_no; + lex->select->item_list = lex->select_lex.item_list; + lex->select->item_list.empty(); + lex->select->table_list = lex->select_lex.table_list; + lex->select->table_list.elements=0; + lex->select->table_list.first=0; + lex->select->table_list.next= (byte**) &lex->select->table_list.first; } void