Commit 823586b2 authored by unknown's avatar unknown

Enhancing both multi-table delete and division of LEX


sql/filesort.cc:
  removing of some extra comments
sql/sql_class.h:
  Clear division between new and old stripping code
sql/sql_delete.cc:
  Stripping of unnecessary code and making it more efficient
sql/sql_parse.cc:
  Better split of LEX into two and enhancements in multi table delete
sql/sql_yacc.yy:
  More efficient division of LEX and optional syntax in multi - table delete
sql/uniques.cc:
  fixing some additional bugs
parent 4e886689
...@@ -739,7 +739,6 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, ...@@ -739,7 +739,6 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
buffpek=(BUFFPEK*) queue_top(&queue); buffpek=(BUFFPEK*) queue_top(&queue);
if (cmp) // Remove duplicates if (cmp) // Remove duplicates
{ {
// Was if (!cmp(&sort_length, param->unique_buff, (uchar**) buffpek->key))
if (!cmp(&sort_length, &(param->unique_buff), (uchar**) &buffpek->key)) if (!cmp(&sort_length, &(param->unique_buff), (uchar**) &buffpek->key))
goto skip_duplicate; goto skip_duplicate;
memcpy(param->unique_buff, (uchar*) buffpek->key,sort_length); memcpy(param->unique_buff, (uchar*) buffpek->key,sort_length);
......
...@@ -464,34 +464,6 @@ public: ...@@ -464,34 +464,6 @@ public:
void send_error(uint errcode,const char *err); void send_error(uint errcode,const char *err);
bool send_eof(); bool send_eof();
}; };
class multi_delete : public select_result {
TABLE_LIST *delete_tables, *table_being_deleted;
IO_CACHE **tempfiles;
thr_lock_type lock_option;
ulong deleted;
byte *dup_checking, wrong_record[MAX_REFLENGTH], *memory_lane;
int num_of_tables, error;
bool do_delete;
THD *thd;
public:
multi_delete(TABLE_LIST *dt, thr_lock_type o, uint n)
: delete_tables (dt), lock_option(o), deleted(0), num_of_tables(n), error(0)
{
memset(wrong_record,'\xFF',MAX_REFLENGTH);
thd = current_thd; do_delete = false;
}
~multi_delete();
int prepare(List<Item> &list);
bool send_fields(List<Item> &list,
uint flag) { return 0; }
bool send_data(List<Item> &items);
void send_error(uint errcode,const char *err);
int do_deletes (bool from_send_error);
bool send_eof();
};
class select_insert :public select_result { class select_insert :public select_result {
protected: protected:
TABLE *table; TABLE *table;
...@@ -619,3 +591,35 @@ public: ...@@ -619,3 +591,35 @@ public:
friend int unique_write_to_file(gptr key, element_count count, Unique *unique); friend int unique_write_to_file(gptr key, element_count count, Unique *unique);
friend int unique_write_to_ptrs(gptr key, element_count count, Unique *unique); friend int unique_write_to_ptrs(gptr key, element_count count, Unique *unique);
}; };
class multi_delete : public select_result {
TABLE_LIST *delete_tables, *table_being_deleted;
#ifdef SINISAS_STRIP
IO_CACHE **tempfiles;
byte *memory_lane;
#else
Unique **tempfiles;
#endif
byte * dup_checking;
THD *thd;
ha_rows deleted;
int num_of_tables, error;
thr_lock_type lock_option;
bool do_delete;
public:
multi_delete(TABLE_LIST *dt, thr_lock_type o, uint n)
: delete_tables (dt), lock_option(o), deleted(0), num_of_tables(n), error(0)
{
thd = current_thd; do_delete = false;
}
~multi_delete();
int prepare(List<Item> &list);
bool send_fields(List<Item> &list,
uint flag) { return 0; }
bool send_data(List<Item> &items);
void send_error(uint errcode,const char *err);
int do_deletes (bool from_send_error);
bool send_eof();
};
...@@ -150,7 +150,7 @@ int mysql_delete(THD *thd, ...@@ -150,7 +150,7 @@ int mysql_delete(THD *thd,
(OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))); (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN)));
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
/* We need to add code to not generate table based on the table type */ /* We need to add code to not generate table based on the table type */
if (!innobase_skip) if (!innodb_skip)
use_generate_table=0; // Innobase can't use re-generate table use_generate_table=0; // Innobase can't use re-generate table
#endif #endif
if (use_generate_table && ! thd->open_tables) if (use_generate_table && ! thd->open_tables)
...@@ -294,15 +294,27 @@ int mysql_delete(THD *thd, ...@@ -294,15 +294,27 @@ int mysql_delete(THD *thd,
#define MEM_STRIP_BUF_SIZE 2048 #define MEM_STRIP_BUF_SIZE 2048
#ifndef SINISAS_STRIP
int refposcmp2(void* arg, const void *a,const void *b)
{
return memcmp(a,b,(int)arg);
}
#endif
int int
multi_delete::prepare(List<Item> &values) multi_delete::prepare(List<Item> &values)
{ {
DBUG_ENTER("multi_delete::prepare"); DBUG_ENTER("multi_delete::prepare");
uint counter = 0;
#ifdef SINISAS_STRIP
tempfiles = (IO_CACHE **) sql_calloc(sizeof(IO_CACHE *)*(num_of_tables)); tempfiles = (IO_CACHE **) sql_calloc(sizeof(IO_CACHE *)*(num_of_tables));
memory_lane = (byte *)sql_alloc(MAX_REFLENGTH*MEM_STRIP_BUF_SIZE); uint counter = 0; memory_lane = (byte *)sql_alloc(MAX_REFLENGTH*MEM_STRIP_BUF_SIZE);
#else
tempfiles = (Unique **) sql_calloc(sizeof(Unique *) * (num_of_tables));
#endif
do_delete = true;
dup_checking = (byte *) sql_calloc(MAX_REFLENGTH * (num_of_tables + 1)); dup_checking = (byte *) sql_calloc(MAX_REFLENGTH * (num_of_tables + 1));
memset(dup_checking,'\xFF', MAX_REFLENGTH * (num_of_tables + 1)); do_delete = true; memset(dup_checking,'\xFF', MAX_REFLENGTH * (num_of_tables + 1));
for (table_being_deleted=delete_tables; table_being_deleted; table_being_deleted=table_being_deleted->next, counter++) for (table_being_deleted=delete_tables; table_being_deleted; table_being_deleted=table_being_deleted->next, counter++)
{ {
TABLE *table=table_being_deleted->table; TABLE *table=table_being_deleted->table;
...@@ -314,12 +326,16 @@ multi_delete::prepare(List<Item> &values) ...@@ -314,12 +326,16 @@ multi_delete::prepare(List<Item> &values)
(void) table->file->extra(HA_EXTRA_NO_READCHECK); (void) table->file->extra(HA_EXTRA_NO_READCHECK);
if (counter < num_of_tables) if (counter < num_of_tables)
{ {
#ifdef SINISAS_STRIP
tempfiles[counter]=(IO_CACHE *)sql_alloc(sizeof(IO_CACHE)); tempfiles[counter]=(IO_CACHE *)sql_alloc(sizeof(IO_CACHE));
if (open_cached_file(tempfiles[counter], mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, MYF(MY_WME))) if (open_cached_file(tempfiles[counter], mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, MYF(MY_WME)))
{ {
my_error(ER_CANT_OPEN_FILE,MYF(0),(tempfiles[counter])->file_name,errno); my_error(ER_CANT_OPEN_FILE,MYF(0),(tempfiles[counter])->file_name,errno);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
#else
tempfiles[counter] = new Unique (refposcmp2,(void *)table->file->ref_length,table->file->ref_length,MEM_STRIP_BUF_SIZE);
#endif
} }
} }
thd->proc_info="updating"; thd->proc_info="updating";
...@@ -330,7 +346,11 @@ multi_delete::~multi_delete() ...@@ -330,7 +346,11 @@ multi_delete::~multi_delete()
{ {
for (uint counter = 0; counter < num_of_tables; counter++) for (uint counter = 0; counter < num_of_tables; counter++)
if (tempfiles[counter]) if (tempfiles[counter])
end_io_cache(tempfiles[counter]); #ifdef SINISAS_STRIP
// end_io_cache(tempfiles[counter]);
#else
delete tempfiles[counter];
#endif
// Here it crashes ... // Here it crashes ...
} }
...@@ -342,7 +362,7 @@ bool multi_delete::send_data(List<Item> &values) ...@@ -342,7 +362,7 @@ bool multi_delete::send_data(List<Item> &values)
TABLE *table=table_being_deleted->table; TABLE *table=table_being_deleted->table;
table->file->position(table->record[0]); int rl = table->file->ref_length; table->file->position(table->record[0]); int rl = table->file->ref_length;
byte *dup_check = dup_checking + (secure_counter + 1)*MAX_REFLENGTH; byte *dup_check = dup_checking + (secure_counter + 1)*MAX_REFLENGTH;
if (!table->null_row && memcmp(dup_check,table->file->ref, rl) && memcmp(table->file->ref,wrong_record,rl)) if (!table->null_row && memcmp(dup_check,table->file->ref, rl))
{ {
memcpy(dup_check,table->file->ref,rl); memcpy(dup_check,table->file->ref,rl);
if (secure_counter == -1) if (secure_counter == -1)
...@@ -357,7 +377,11 @@ bool multi_delete::send_data(List<Item> &values) ...@@ -357,7 +377,11 @@ bool multi_delete::send_data(List<Item> &values)
} }
else else
{ {
#ifdef SINISAS_STRIP
if (my_b_write(tempfiles[secure_counter],table->file->ref,rl)) if (my_b_write(tempfiles[secure_counter],table->file->ref,rl))
#else
if (tempfiles[secure_counter]->unique_add(table->file->ref))
#endif
{ {
error=-1; error=-1;
return 1; return 1;
...@@ -687,11 +711,7 @@ static IO_CACHE *strip_duplicates_from_temp (byte *memory_lane, IO_CACHE *ptr, u ...@@ -687,11 +711,7 @@ static IO_CACHE *strip_duplicates_from_temp (byte *memory_lane, IO_CACHE *ptr, u
return tempptr; return tempptr;
} }
} }
#else
int refposcmp2(void* arg, const void *a,const void *b)
{
return memcmp(a,b,(int)arg);
}
#endif #endif
static bool some_table_is_not_transaction_safe (TABLE_LIST *tl) static bool some_table_is_not_transaction_safe (TABLE_LIST *tl)
...@@ -708,9 +728,14 @@ static bool some_table_is_not_transaction_safe (TABLE_LIST *tl) ...@@ -708,9 +728,14 @@ static bool some_table_is_not_transaction_safe (TABLE_LIST *tl)
void multi_delete::send_error(uint errcode,const char *err) void multi_delete::send_error(uint errcode,const char *err)
{ {
// First send error what ever it is ...
::send_error(&thd->net,errcode,err); ::send_error(&thd->net,errcode,err);
// If nothing deleted return
if (!deleted) return; if (!deleted) return;
// Below can happen when thread is killed ...
if (!table_being_deleted) table_being_deleted=delete_tables; if (!table_being_deleted) table_being_deleted=delete_tables;
// If rows from the first table only has been deleted and it is transactional, just do rollback
// The same if all tables are transactional, regardless of where we are. In all other cases do attempt deletes ...
if ((table_being_deleted->table->file->has_transactions() && table_being_deleted == delete_tables) || !some_table_is_not_transaction_safe(delete_tables)) if ((table_being_deleted->table->file->has_transactions() && table_being_deleted == delete_tables) || !some_table_is_not_transaction_safe(delete_tables))
ha_rollback(current_thd); ha_rollback(current_thd);
else if (do_delete) else if (do_delete)
...@@ -732,30 +757,16 @@ int multi_delete::do_deletes (bool from_send_error) ...@@ -732,30 +757,16 @@ int multi_delete::do_deletes (bool from_send_error)
for (table_being_deleted=table_being_deleted->next; table_being_deleted ; counter++, table_being_deleted=table_being_deleted->next) for (table_being_deleted=table_being_deleted->next; table_being_deleted ; counter++, table_being_deleted=table_being_deleted->next)
{ {
table = table_being_deleted->table; int rl = table->file->ref_length; table = table_being_deleted->table; int rl = table->file->ref_length;
#ifdef SINISAS_STRIP
int num_of_positions = (int)my_b_tell(tempfiles[counter])/rl; int num_of_positions = (int)my_b_tell(tempfiles[counter])/rl;
if (!num_of_positions) continue; if (!num_of_positions) continue;
#ifdef SINISAS_STRIP
tempfiles[counter] = strip_duplicates_from_temp(memory_lane, tempfiles[counter],rl,&num_of_positions); tempfiles[counter] = strip_duplicates_from_temp(memory_lane, tempfiles[counter],rl,&num_of_positions);
if (!num_of_positions) if (!num_of_positions)
{ {
error=1; break; error=1; break;
} }
#else #else
Unique strip_it(refposcmp2,(void *)rl,rl,MEM_STRIP_BUF_SIZE); tempfiles[counter]->get(table);
if (reinit_io_cache(tempfiles[counter],READ_CACHE,0L,0,0))
{
error=1; break;
}
for (count = 0; count < num_of_positions; count++)
{
byte tmp [MAX_REFLENGTH];
if (my_b_read(tempfiles[counter], tmp, rl) || strip_it.unique_add(tmp))
{
error = 1;
break;
}
}
strip_it.get(table);
#endif #endif
#if 0 #if 0
if (num_of_positions == table->file->records) // nice little optimization .... if (num_of_positions == table->file->records) // nice little optimization ....
...@@ -773,12 +784,17 @@ int multi_delete::do_deletes (bool from_send_error) ...@@ -773,12 +784,17 @@ int multi_delete::do_deletes (bool from_send_error)
else else
{ {
#endif #endif
READ_RECORD info; error=0;
#ifdef SINISAS_STRIP
SQL_SELECT *select= new SQL_SELECT; SQL_SELECT *select= new SQL_SELECT;
READ_RECORD info;
select->head=table; select->head=table;
select->file=*tempfiles[counter]; select->file=*tempfiles[counter];
init_read_record(&info,thd,table,select,0,0); error=0; init_read_record(&info,thd,table,select,0,0);
while (!(error=info.read_record(&info)) && (!thd->killed || from_send_error)) #else
init_read_record(&info,thd,table,NULL,0,0);
#endif
bool not_trans_safe = some_table_is_not_transaction_safe(delete_tables);
while (!(error=info.read_record(&info)) && (!thd->killed || from_send_error || not_trans_safe))
{ {
error=table->file->delete_row(table->record[0]); error=table->file->delete_row(table->record[0]);
if (error) if (error)
...@@ -789,8 +805,11 @@ int multi_delete::do_deletes (bool from_send_error) ...@@ -789,8 +805,11 @@ int multi_delete::do_deletes (bool from_send_error)
else else
deleted++; deleted++;
} }
end_read_record(&info); delete select; end_read_record(&info);
if (error = -1) error = 0; // Monty, that is what read_record returns on end of the file !! #ifdef SINISAS_STRIP
delete select;
#endif
if (error = -1) error = 0;
#if 0 #if 0
} }
#endif #endif
...@@ -822,11 +841,6 @@ bool multi_delete::send_eof() ...@@ -822,11 +841,6 @@ bool multi_delete::send_eof()
error=1; error=1;
VOID(ha_autocommit_or_rollback(thd,error >= 0)); VOID(ha_autocommit_or_rollback(thd,error >= 0));
} }
if (thd->lock)
{
mysql_unlock_tables(thd, thd->lock);
thd->lock=0;
}
::send_ok(&thd->net,deleted); ::send_ok(&thd->net,deleted);
return 0; return 0;
......
This diff is collapsed.
...@@ -542,7 +542,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -542,7 +542,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
opt_mi_check_type opt_to mi_check_types normal_join opt_mi_check_type opt_to mi_check_types normal_join
table_to_table_list table_to_table opt_table_list opt_as table_to_table_list table_to_table opt_table_list opt_as
handler_rkey_function handler_rkey_mode handler_read_or_scan handler_rkey_function handler_rkey_mode handler_read_or_scan
single_multi table_multi_delete table_sin_wild single_multi table_multi_delete table_sini_wild
END_OF_INPUT END_OF_INPUT
%type <NONE> %type <NONE>
...@@ -764,12 +764,12 @@ create_table_option: ...@@ -764,12 +764,12 @@ create_table_option:
{ {
/* Move the union list to the merge_list */ /* Move the union list to the merge_list */
LEX *lex=Lex; LEX *lex=Lex;
TABLE_LIST *table_list= (TABLE_LIST*) Select->table_list.first; TABLE_LIST *table_list= (TABLE_LIST*) lex->select->table_list.first;
lex->create_info.merge_list= Select->table_list; lex->create_info.merge_list= lex->select->table_list;
lex->create_info.merge_list.elements--; lex->create_info.merge_list.elements--;
lex->create_info.merge_list.first= (byte*) (table_list->next); lex->create_info.merge_list.first= (byte*) (table_list->next);
Select->table_list.elements=1; lex->select->table_list.elements=1;
Select->table_list.next= (byte**) &(table_list->next); lex->select->table_list.next= (byte**) &(table_list->next);
table_list->next=0; table_list->next=0;
lex->create_info.used_fields|= HA_CREATE_USED_UNION; lex->create_info.used_fields|= HA_CREATE_USED_UNION;
} }
...@@ -1064,10 +1064,10 @@ alter: ...@@ -1064,10 +1064,10 @@ alter:
lex->col_list.empty(); lex->col_list.empty();
lex->drop_list.empty(); lex->drop_list.empty();
lex->alter_list.empty(); lex->alter_list.empty();
Select->order_list.elements=0; lex->select->order_list.elements=0;
Select->order_list.first=0; lex->select->order_list.first=0;
Select->order_list.next= (byte**) &Select->order_list.first; lex->select->order_list.next= (byte**) &lex->select->order_list.first;
Select->db=lex->name=0; lex->select->db=lex->name=0;
bzero((char*) &lex->create_info,sizeof(lex->create_info)); bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.db_type= DB_TYPE_DEFAULT; lex->create_info.db_type= DB_TYPE_DEFAULT;
lex->alter_keys_onoff=LEAVE_AS_IS; lex->alter_keys_onoff=LEAVE_AS_IS;
...@@ -1118,7 +1118,10 @@ alter_list_item: ...@@ -1118,7 +1118,10 @@ alter_list_item:
| ALTER opt_column field_ident DROP DEFAULT | ALTER opt_column field_ident DROP DEFAULT
{ Lex->alter_list.push_back(new Alter_column($3.str,(Item*) 0)); Lex->simple_alter=0; } { Lex->alter_list.push_back(new Alter_column($3.str,(Item*) 0)); Lex->simple_alter=0; }
| RENAME opt_to table_alias table_ident | RENAME opt_to table_alias table_ident
{ Select->db=$4->db.str ; Lex->name= $4->table.str; Lex->simple_alter=0; } {
LEX *lex=Lex;
lex->select->db=$4->db.str ; lex->name= $4->table.str; lex->simple_alter=0;
}
| create_table_options { Lex->simple_alter=0; } | create_table_options { Lex->simple_alter=0; }
| order_clause { Lex->simple_alter=0; } | order_clause { Lex->simple_alter=0; }
...@@ -2197,9 +2200,9 @@ single_multi: ...@@ -2197,9 +2200,9 @@ single_multi:
| table_multi_delete | table_multi_delete
{ {
LEX *lex=Lex; LEX *lex=Lex;
Lex->sql_command = SQLCOM_MULTI_DELETE; lex->sql_command = SQLCOM_MULTI_DELETE;
mysql_init_select(lex); mysql_init_select(lex);
Select->select_limit=HA_POS_ERROR; lex->select->select_limit=HA_POS_ERROR;
lex->auxilliary_table_list.elements=0; lex->auxilliary_table_list.elements=0;
lex->auxilliary_table_list.first=0; lex->auxilliary_table_list.first=0;
lex->auxilliary_table_list.next= (byte**) &(lex->auxilliary_table_list.first); lex->auxilliary_table_list.next= (byte**) &(lex->auxilliary_table_list.first);
...@@ -2213,13 +2216,17 @@ single_multi: ...@@ -2213,13 +2216,17 @@ single_multi:
} join_table_list where_clause } join_table_list where_clause
table_multi_delete: table_multi_delete:
table_sin_wild {} table_sini_wild {}
| table_multi_delete ',' table_sin_wild {} | table_multi_delete ',' table_sini_wild {}
table_sin_wild: table_sini_wild:
ident '.' '*' { if (!add_table_to_list(new Table_ident($1),NULL,1,TL_WRITE)) YYABORT; } ident '.' '*' { if (!add_table_to_list(new Table_ident($1),NULL,1,TL_WRITE)) YYABORT; }
| ident '.' ident '.' '*' | ident '.' ident '.' '*'
{ if (!add_table_to_list(new Table_ident($1,$3,0),NULL,1,TL_WRITE)) YYABORT;} { if (!add_table_to_list(new Table_ident($1,$3,0),NULL,1,TL_WRITE)) YYABORT;}
| ident { if (!add_table_to_list(new Table_ident($1),NULL,1,TL_WRITE)) YYABORT; }
| ident '.' ident
{ if (!add_table_to_list(new Table_ident($1,$3,0),NULL,1,TL_WRITE)) YYABORT;}
opt_delete_options: opt_delete_options:
/* empty */ {} /* empty */ {}
......
...@@ -39,12 +39,12 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg, ...@@ -39,12 +39,12 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
uint size, ulong max_in_memory_size_arg) uint size, ulong max_in_memory_size_arg)
:max_in_memory_size(max_in_memory_size_arg),elements(0) :max_in_memory_size(max_in_memory_size_arg),elements(0)
{ {
my_b_clear(&file);
init_tree(&tree, max_in_memory_size / 16, size, comp_func, 0, 0); init_tree(&tree, max_in_memory_size / 16, size, comp_func, 0, 0);
tree.cmp_arg=comp_func_fixed_arg; tree.cmp_arg=comp_func_fixed_arg;
/* If the following fail's the next add will also fail */ /* If the following fail's the next add will also fail */
init_dynamic_array(&file_ptrs, sizeof(BUFFPEK), 16, 16); init_dynamic_array(&file_ptrs, sizeof(BUFFPEK), 16, 16);
max_elements= max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+size); max_elements= max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+size);
open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, MYF(MY_WME));
} }
...@@ -74,8 +74,6 @@ bool Unique::flush() ...@@ -74,8 +74,6 @@ bool Unique::flush()
int unique_write_to_file(gptr key, element_count count, Unique *unique) int unique_write_to_file(gptr key, element_count count, Unique *unique)
{ {
if (!my_b_inited(&unique->file) && open_cached_file(&unique->file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, MYF(MY_WME)))
return 1;
return my_b_write(&unique->file, key, unique->tree.size_of_element) ? 1 : 0; return my_b_write(&unique->file, key, unique->tree.size_of_element) ? 1 : 0;
} }
...@@ -114,7 +112,7 @@ bool Unique::get(TABLE *table) ...@@ -114,7 +112,7 @@ bool Unique::get(TABLE *table)
IO_CACHE *outfile=table->io_cache, tempfile; IO_CACHE *outfile=table->io_cache, tempfile;
BUFFPEK *file_ptr= (BUFFPEK*) file_ptrs.buffer; BUFFPEK *file_ptr= (BUFFPEK*) file_ptrs.buffer;
uint maxbuffer= file_ptrs.elements - 1; // I added -1 ..... uint maxbuffer= file_ptrs.elements - 1;
uchar *sort_buffer; uchar *sort_buffer;
my_off_t save_pos; my_off_t save_pos;
bool error=1; bool error=1;
...@@ -122,16 +120,15 @@ bool Unique::get(TABLE *table) ...@@ -122,16 +120,15 @@ bool Unique::get(TABLE *table)
my_b_clear(&tempfile); my_b_clear(&tempfile);
/* Open cached file if it isn't open */ /* Open cached file if it isn't open */
if (!outfile) outfile= (IO_CACHE *) sql_calloc(sizeof(IO_CACHE)); outfile=table->io_cache=(IO_CACHE*) my_malloc(sizeof(IO_CACHE),MYF(MY_ZEROFILL));
if (! my_b_inited(outfile) &&
if (!outfile || ! my_b_inited(outfile) &&
open_cached_file(outfile,mysql_tmpdir,TEMP_PREFIX,READ_RECORD_BUFFER, open_cached_file(outfile,mysql_tmpdir,TEMP_PREFIX,READ_RECORD_BUFFER,
MYF(MY_WME))) MYF(MY_WME)))
return 1; return 1;
reinit_io_cache(outfile,WRITE_CACHE,0L,0,0); reinit_io_cache(outfile,WRITE_CACHE,0L,0,0);
// sort_param.keys=elements;
sort_param.max_rows= elements; sort_param.max_rows= elements;
sort_param.examined_rows=0;
sort_param.sort_form=table; sort_param.sort_form=table;
sort_param.sort_length=sort_param.ref_length=tree.size_of_element; sort_param.sort_length=sort_param.ref_length=tree.size_of_element;
sort_param.keys= max_in_memory_size / sort_param.sort_length; sort_param.keys= max_in_memory_size / sort_param.sort_length;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment