diff --git a/.bzrignore b/.bzrignore index 2c5833b8912..cecf83d2daf 100644 --- a/.bzrignore +++ b/.bzrignore @@ -368,3 +368,4 @@ libmysqld/hash_filo.cc libmysqld/sql_unions.cc libmysqld/stacktrace.c sql/share/mysql +locked diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 0ab255a9532..7959b67ee9c 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -7,7 +7,7 @@ eval select $BIG_TEST as using_big_test; 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 t2(id2 int not null, t char(12)); create table t3(id3 int not null, t char(12), index(id3)); let $1 = 10000; while ($1) diff --git a/mysys/my_compress.c b/mysys/my_compress.c index d1e32234135..9d94a400f48 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -15,7 +15,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -/* Written by Sinisa Milivojevic */ +/* Written by Sinisa Milivojevic */ #include #ifdef HAVE_COMPRESS diff --git a/sql/filesort.cc b/sql/filesort.cc index fe06d3eb9b6..3b59a0c09bb 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -685,7 +685,6 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, uchar *strpos; BUFFPEK *buffpek,**refpek; QUEUE queue; - volatile bool *killed= ¤t_thd->killed; qsort2_cmp cmp; DBUG_ENTER("merge_buffers"); @@ -739,10 +738,6 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, while (queue.elements > 1) { - if (*killed) - { - error=1; goto err; /* purecov: inspected */ - } for (;;) { buffpek=(BUFFPEK*) queue_top(&queue); diff --git a/sql/sql_class.h b/sql/sql_class.h index 1aa9e65fa74..14055a1444c 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -410,6 +410,8 @@ public: ** This is used to get result from a select */ +class JOIN; + class select_result :public Sql_alloc { protected: THD *thd; @@ -419,6 +421,7 @@ public: virtual int prepare(List &list) { return 0; } virtual bool send_fields(List &list,uint flag)=0; virtual bool send_data(List &items)=0; + virtual void initialize_tables (JOIN *join=0) {}; virtual void send_error(uint errcode,const char *err)=0; virtual bool send_eof()=0; virtual void abort() {} @@ -621,6 +624,7 @@ public: bool send_fields(List &list, uint flag) { return 0; } bool send_data(List &items); + void initialize_tables (JOIN *join); void send_error(uint errcode,const char *err); int do_deletes (bool from_send_error); bool send_eof(); diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index b690ef4b327..16b81ce25ff 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB & Sinisa This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,6 +19,7 @@ #include "mysql_priv.h" #include "ha_innobase.h" +#include "sql_select.h" /* Optimize delete of all rows by doing a full generate of the table @@ -319,12 +320,14 @@ multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt, #endif (void) dt->table->file->extra(HA_EXTRA_NO_READCHECK); + (void) dt->table->file->extra(HA_EXTRA_NO_KEYREAD); /* Don't use key read with MULTI-TABLE-DELETE */ dt->table->used_keys=0; for (dt=dt->next ; dt ; dt=dt->next,counter++) { TABLE *table=dt->table; - (void) table->file->extra(HA_EXTRA_NO_READCHECK); + (void) dt->table->file->extra(HA_EXTRA_NO_READCHECK); + (void) dt->table->file->extra(HA_EXTRA_NO_KEYREAD); #ifdef SINISAS_STRIP tempfiles[counter]=(IO_CACHE *) sql_alloc(sizeof(IO_CACHE)); if (open_cached_file(tempfiles[counter], mysql_tmpdir,TEMP_PREFIX, @@ -367,6 +370,39 @@ multi_delete::prepare(List &values) DBUG_RETURN(0); } +inline static void +link_in_list(SQL_LIST *list,byte *element,byte **next) +{ + list->elements++; + (*list->next)=element; + list->next=next; + *next=0; +} + +void +multi_delete::initialize_tables(JOIN *join) +{ + SQL_LIST *new_list=(SQL_LIST *) sql_alloc(sizeof(SQL_LIST)); + new_list->elements=0; new_list->first=0; + new_list->next= (byte**) &(new_list->first); + for (JOIN_TAB *tab=join->join_tab, *end=join->join_tab+join->tables; + tab < end; + tab++) + { + TABLE_LIST *walk; + for (walk=(TABLE_LIST*) delete_tables ; walk ; walk=walk->next) + if (!strcmp(tab->table->path,walk->table->path)) + break; + if (walk) // Table need not be the one to be deleted + { + register TABLE_LIST *ptr = (TABLE_LIST *) sql_alloc(sizeof(TABLE_LIST)); + memcpy(ptr,walk,sizeof(TABLE_LIST)); ptr->next=0; + link_in_list(new_list,(byte*) ptr,(byte**) &ptr->next); + } + } + delete_tables=(TABLE_LIST *)new_list->first; + return; +} multi_delete::~multi_delete() { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bb1e72d943f..22c9047d220 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -385,6 +385,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, thd->fatal_error) goto err; thd->proc_info="preparing"; + result->initialize_tables(&join); if ((tmp=join_read_const_tables(&join)) > 0) goto err; if (tmp && !(select_options & SELECT_DESCRIBE))