Commit ae4323e0 authored by unknown's avatar unknown

After merge fixes

Added THD to add_to_xxx_list() functions for faster parsing.


heap/_check.c:
  After merge fix
mysql-test/r/distinct.result:
  After merge fix
mysql-test/r/multi_update.result:
  Make timestamp test portable
mysql-test/t/multi_update.test:
  Make timestamp test portable
sql/field.cc:
  After merge fix
sql/item_sum.cc:
  After merge fix
sql/log_event.cc:
  Remove compiler warning
sql/mysql_priv.h:
  Added THD to add_to_list (Faster parsing)
sql/sql_derived.cc:
  Fixed parameters to create_tmp_table()
sql/sql_lex.cc:
  Added THD to add_to_list (Faster parsing)
sql/sql_lex.h:
  Added THD to add_to_list (Faster parsing)
sql/sql_parse.cc:
  Added THD to add_to_list (Faster parsing)
sql/sql_select.cc:
  After merge fixes
  Fixed return values from JOIN::optimize()
  Replaced test_function_query with '!tables_list'
  Optimized arguments to create_tmp_table()
sql/sql_select.h:
  Removed test_function_query variable
  Updated prototypes
sql/sql_union.cc:
  Updated argument lists.
sql/sql_update.cc:
  After merge fixes
sql/sql_yacc.yy:
  Added THD to all add_xxx_to_list() functions
sql/table.h:
  After merge fix
parent 6d33f734
...@@ -75,7 +75,7 @@ int heap_check_heap(HP_INFO *info, my_bool print_status) ...@@ -75,7 +75,7 @@ int heap_check_heap(HP_INFO *info, my_bool print_status)
break; /* End of file */ break; /* End of file */
} }
} }
_hp_find_record(info,pos); hp_find_record(info,pos);
if (!info->current_ptr[share->reclength]) if (!info->current_ptr[share->reclength])
deleted++; deleted++;
......
...@@ -199,29 +199,29 @@ select distinct 1 from t1,t3 where t1.a=t3.a; ...@@ -199,29 +199,29 @@ select distinct 1 from t1,t3 where t1.a=t3.a;
1 1
1 1
explain SELECT distinct t1.a from t1; explain SELECT distinct t1.a from t1;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t1 index NULL PRIMARY 4 NULL 2 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
explain SELECT distinct t1.a from t1 order by a desc; explain SELECT distinct t1.a from t1 order by a desc;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t1 index NULL PRIMARY 4 NULL 2 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
explain SELECT t1.a from t1 group by a order by a desc; explain SELECT t1.a from t1 group by a order by a desc;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t1 index NULL PRIMARY 4 NULL 2 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
explain SELECT distinct t1.a from t1 order by a desc limit 1; explain SELECT distinct t1.a from t1 order by a desc limit 1;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t1 index NULL PRIMARY 4 NULL 2 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
explain SELECT distinct a from t3 order by a desc limit 2; explain SELECT distinct a from t3 order by a desc limit 2;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t3 index NULL a 5 NULL 204 Using index 1 SIMPLE t3 index NULL a 5 NULL 204 Using index
explain SELECT distinct a,b from t3 order by a+1; explain SELECT distinct a,b from t3 order by a+1;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort 1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
explain SELECT distinct a,b from t3 order by a limit 10; explain SELECT distinct a,b from t3 order by a limit 10;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t3 index NULL a 5 NULL 204 Using temporary 1 SIMPLE t3 index NULL a 5 NULL 204 Using temporary
explain SELECT a,b from t3 group by a,b order by a+1; explain SELECT a,b from t3 group by a,b order by a+1;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort 1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
drop table t1,t2,t3,t4; drop table t1,t2,t3,t4;
CREATE TABLE t1 (name varchar(255)); CREATE TABLE t1 (name varchar(255));
INSERT INTO t1 VALUES ('aa'),('ab'),('ac'),('ad'),('ae'); INSERT INTO t1 VALUES ('aa'),('ab'),('ac'),('ad'),('ae');
......
...@@ -182,13 +182,13 @@ insert into t1 values(1,1,NULL); ...@@ -182,13 +182,13 @@ insert into t1 values(1,1,NULL);
insert into t2 values(1,10,NULL),(2,20,NULL); insert into t2 values(1,10,NULL),(2,20,NULL);
set timestamp=1038000000; set timestamp=1038000000;
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n; UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
select * from t1; select n,d,unix_timestamp(t) from t1;
n d t n d unix_timestamp(t)
1 10 20021123002000 1 10 1038000000
select * from t2; select n,d,unix_timestamp(t) from t2;
n d t n d unix_timestamp(t)
1 10 20021127154957 1 10 1038401397
2 20 20021127154957 2 20 1038401397
UPDATE t1,t2 SET 1=2 WHERE t1.n=t2.n; UPDATE t1,t2 SET 1=2 WHERE t1.n=t2.n;
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1=2 WHERE t1.n=t2.n' at line 1 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1=2 WHERE t1.n=t2.n' at line 1
drop table t1,t2; drop table t1,t2;
......
...@@ -183,8 +183,8 @@ insert into t1 values(1,1,NULL); ...@@ -183,8 +183,8 @@ insert into t1 values(1,1,NULL);
insert into t2 values(1,10,NULL),(2,20,NULL); insert into t2 values(1,10,NULL),(2,20,NULL);
set timestamp=1038000000; set timestamp=1038000000;
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n; UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
select * from t1; select n,d,unix_timestamp(t) from t1;
select * from t2; select n,d,unix_timestamp(t) from t2;
--error 1064 --error 1064
UPDATE t1,t2 SET 1=2 WHERE t1.n=t2.n; UPDATE t1,t2 SET 1=2 WHERE t1.n=t2.n;
drop table t1,t2; drop table t1,t2;
......
...@@ -1577,12 +1577,12 @@ void Field_medium::sql_type(String &res) const ...@@ -1577,12 +1577,12 @@ void Field_medium::sql_type(String &res) const
int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
char *end; char *end;
while (len && my_isspace(system_charset_info,*from)) while (len && my_isspace(cs,*from))
{ {
len--; from++; len--; from++;
} }
long tmp; long tmp;
String tmp_str(from,len); String tmp_str(from, len, cs);
from= tmp_str.c_ptr(); // Add end null if needed from= tmp_str.c_ptr(); // Add end null if needed
int error= 0; int error= 0;
errno=0; errno=0;
...@@ -1602,6 +1602,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) ...@@ -1602,6 +1602,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
if (errno || if (errno ||
(from+len != end && current_thd->count_cuted_fields && (from+len != end && current_thd->count_cuted_fields &&
!test_if_int(from,len))) !test_if_int(from,len)))
{
current_thd->cuted_fields++; current_thd->cuted_fields++;
error= 1; error= 1;
} }
...@@ -1826,12 +1827,12 @@ void Field_long::sql_type(String &res) const ...@@ -1826,12 +1827,12 @@ void Field_long::sql_type(String &res) const
int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs) int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
char *end; char *end;
while (len && my_isspace(system_charset_info,*from)) while (len && my_isspace(cs,*from))
{ // For easy error check { // For easy error check
len--; from++; len--; from++;
} }
longlong tmp; longlong tmp;
String tmp_str(from,len); String tmp_str(from, len, cs);
from= tmp_str.c_ptr(); // Add end null if needed from= tmp_str.c_ptr(); // Add end null if needed
int error= 0; int error= 0;
errno=0; errno=0;
......
...@@ -43,7 +43,8 @@ Item_sum::Item_sum(List<Item> &list) ...@@ -43,7 +43,8 @@ Item_sum::Item_sum(List<Item> &list)
void Item_sum::mark_as_sum_func() void Item_sum::mark_as_sum_func()
{ {
current_thd->lex.current_select->with_sum_func= with_sum_func= 1; current_thd->lex.current_select->with_sum_func=1;
with_sum_func= 1;
} }
void Item_sum::make_field(Send_field *tmp_field) void Item_sum::make_field(Send_field *tmp_field)
...@@ -991,9 +992,9 @@ bool Item_sum_count_distinct::setup(THD *thd) ...@@ -991,9 +992,9 @@ bool Item_sum_count_distinct::setup(THD *thd)
tmp_table_param->cleanup(); tmp_table_param->cleanup();
} }
if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1, if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1,
0, 0, 0,
select_lex->options | thd->options, select_lex->options | thd->options,
select_lex->master_unit()))) HA_POS_ERROR)))
return 1; return 1;
table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows
table->no_rows=1; table->no_rows=1;
...@@ -1091,7 +1092,7 @@ bool Item_sum_count_distinct::setup(THD *thd) ...@@ -1091,7 +1092,7 @@ bool Item_sum_count_distinct::setup(THD *thd)
int Item_sum_count_distinct::tree_to_myisam() int Item_sum_count_distinct::tree_to_myisam()
{ {
if (create_myisam_from_heap(table, tmp_table_param, if (create_myisam_from_heap(current_thd, table, tmp_table_param,
HA_ERR_RECORD_FILE_FULL, 1) || HA_ERR_RECORD_FILE_FULL, 1) ||
tree_walk(&tree, (tree_walk_action)&dump_leaf, (void*)this, tree_walk(&tree, (tree_walk_action)&dump_leaf, (void*)this,
left_root_right)) left_root_right))
...@@ -1137,7 +1138,8 @@ bool Item_sum_count_distinct::add() ...@@ -1137,7 +1138,8 @@ bool Item_sum_count_distinct::add()
if (tree_to_myisam()) if (tree_to_myisam())
return 1; return 1;
} }
else if (!tree_insert(&tree, table->record[0] + rec_offset, 0, tree.custom_arg)) else if (!tree_insert(&tree, table->record[0] + rec_offset, 0,
tree.custom_arg))
return 1; return 1;
} }
else if ((error=table->file->write_row(table->record[0]))) else if ((error=table->file->write_row(table->record[0])))
...@@ -1145,13 +1147,15 @@ bool Item_sum_count_distinct::add() ...@@ -1145,13 +1147,15 @@ bool Item_sum_count_distinct::add()
if (error != HA_ERR_FOUND_DUPP_KEY && if (error != HA_ERR_FOUND_DUPP_KEY &&
error != HA_ERR_FOUND_DUPP_UNIQUE) error != HA_ERR_FOUND_DUPP_UNIQUE)
{ {
if (create_myisam_from_heap(table, tmp_table_param, error,1)) if (create_myisam_from_heap(current_thd, table, tmp_table_param, error,
1))
return 1; // Not a table_is_full error return 1; // Not a table_is_full error
} }
} }
return 0; return 0;
} }
longlong Item_sum_count_distinct::val_int() longlong Item_sum_count_distinct::val_int()
{ {
if (!table) // Empty query if (!table) // Empty query
......
...@@ -1194,9 +1194,15 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex, ...@@ -1194,9 +1194,15 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
sql_ex.empty_flags = 0; sql_ex.empty_flags = 0;
switch (handle_dup) { switch (handle_dup) {
case DUP_IGNORE: sql_ex.opt_flags |= IGNORE_FLAG; break; case DUP_IGNORE:
case DUP_REPLACE: sql_ex.opt_flags |= REPLACE_FLAG; break; sql_ex.opt_flags |= IGNORE_FLAG;
case DUP_ERROR: break; break;
case DUP_REPLACE:
sql_ex.opt_flags |= REPLACE_FLAG;
break;
case DUP_UPDATE: // Impossible here
case DUP_ERROR:
break;
} }
if (!ex->field_term->length()) if (!ex->field_term->length())
......
...@@ -460,7 +460,8 @@ int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields, ...@@ -460,7 +460,8 @@ int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
int mysql_multi_update(THD *thd, TABLE_LIST *table_list, int mysql_multi_update(THD *thd, TABLE_LIST *table_list,
List<Item> *fields, List<Item> *values, List<Item> *fields, List<Item> *values,
COND *conds, ulong options, COND *conds, ulong options,
enum enum_duplicates handle_duplicates); enum enum_duplicates handle_duplicates,
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
int mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields, int mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields,
List<List_item> &values, List<Item> &update_fields, List<List_item> &values, List<Item> &update_fields,
List<Item> &update_values, enum_duplicates flag); List<Item> &update_values, enum_duplicates flag);
...@@ -554,13 +555,13 @@ int mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *, ...@@ -554,13 +555,13 @@ int mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *,
/* sql_base.cc */ /* sql_base.cc */
void set_item_name(Item *item,char *pos,uint length); void set_item_name(Item *item,char *pos,uint length);
bool add_field_to_list(char *field_name, enum enum_field_types type, bool add_field_to_list(THD *thd, char *field_name, enum enum_field_types type,
char *length, char *decimal, char *length, char *decimal,
uint type_modifier, uint type_modifier,
Item *default_value, Item *comment, Item *default_value, Item *comment,
char *change, TYPELIB *interval,CHARSET_INFO *cs); char *change, TYPELIB *interval,CHARSET_INFO *cs);
void store_position_for_column(const char *name); void store_position_for_column(const char *name);
bool add_to_list(SQL_LIST &list,Item *group,bool asc=0); bool add_to_list(THD *thd, SQL_LIST &list,Item *group,bool asc=0);
void add_join_on(TABLE_LIST *b,Item *expr); void add_join_on(TABLE_LIST *b,Item *expr);
void add_join_natural(TABLE_LIST *a,TABLE_LIST *b); void add_join_natural(TABLE_LIST *a,TABLE_LIST *b);
bool add_proc_to_list(THD *thd, Item *item); bool add_proc_to_list(THD *thd, Item *item);
...@@ -871,22 +872,26 @@ Item *get_system_var(enum_var_type var_type, const char *var_name, uint length, ...@@ -871,22 +872,26 @@ Item *get_system_var(enum_var_type var_type, const char *var_name, uint length,
/* Some inline functions for more speed */ /* Some inline functions for more speed */
inline bool add_item_to_list(Item *item) inline bool add_item_to_list(THD *thd, Item *item)
{ {
return current_lex->current_select->add_item_to_list(item); return thd->lex.current_select->add_item_to_list(thd, item);
} }
inline bool add_value_to_list(Item *value)
inline bool add_value_to_list(THD *thd, Item *value)
{ {
return current_lex->value_list.push_back(value); return thd->lex.value_list.push_back(value);
} }
inline bool add_order_to_list(Item *item, bool asc)
inline bool add_order_to_list(THD *thd, Item *item, bool asc)
{ {
return current_lex->current_select->add_order_to_list(item, asc); return thd->lex.current_select->add_order_to_list(thd, item, asc);
} }
inline bool add_group_to_list(Item *item, bool asc)
inline bool add_group_to_list(THD *thd, Item *item, bool asc)
{ {
return current_lex->current_select->add_group_to_list(item, asc); return thd->lex.current_select->add_group_to_list(thd, item, asc);
} }
inline void mark_as_null_row(TABLE *table) inline void mark_as_null_row(TABLE *table)
{ {
table->null_row=1; table->null_row=1;
......
...@@ -66,10 +66,10 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t) ...@@ -66,10 +66,10 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); bzero((char*) &tmp_table_param,sizeof(tmp_table_param));
tmp_table_param.field_count=item_list.elements; tmp_table_param.field_count=item_list.elements;
if (!(table=create_tmp_table(thd, &tmp_table_param, item_list, if (!(table=create_tmp_table(thd, &tmp_table_param, item_list,
(ORDER*) 0, 0, 1, 0, (ORDER*) 0, 0, 1,
(sl->options | thd->options | (sl->options | thd->options |
TMP_TABLE_ALL_COLUMNS), TMP_TABLE_ALL_COLUMNS),
unit))) HA_POS_ERROR)))
{ {
res=-1; res=-1;
goto exit; goto exit;
......
...@@ -1098,19 +1098,19 @@ st_select_lex* st_select_lex_node::select_lex() ...@@ -1098,19 +1098,19 @@ st_select_lex* st_select_lex_node::select_lex()
DBUG_RETURN(0); DBUG_RETURN(0);
} }
bool st_select_lex_node::add_item_to_list(Item *item) bool st_select_lex_node::add_item_to_list(THD *thd, Item *item)
{ {
return 1; return 1;
} }
bool st_select_lex_node::add_group_to_list(Item *item, bool asc) bool st_select_lex_node::add_group_to_list(THD *thd, Item *item, bool asc)
{ {
return 1; return 1;
} }
bool st_select_lex_node::add_order_to_list(Item *item, bool asc) bool st_select_lex_node::add_order_to_list(THD *thd, Item *item, bool asc)
{ {
return add_to_list(order_list,item,asc); return add_to_list(thd, order_list,item,asc);
} }
bool st_select_lex_node::add_ftfunc_to_list(Item_func_match *func) bool st_select_lex_node::add_ftfunc_to_list(Item_func_match *func)
...@@ -1166,7 +1166,7 @@ TABLE_LIST* st_select_lex_node::get_table_list() { return 0; } ...@@ -1166,7 +1166,7 @@ TABLE_LIST* st_select_lex_node::get_table_list() { return 0; }
List<Item>* st_select_lex_node::get_item_list() { return 0; } List<Item>* st_select_lex_node::get_item_list() { return 0; }
List<String>* st_select_lex_node::get_use_index() { return 0; } List<String>* st_select_lex_node::get_use_index() { return 0; }
List<String>* st_select_lex_node::get_ignore_index() { return 0; } List<String>* st_select_lex_node::get_ignore_index() { return 0; }
TABLE_LIST *st_select_lex_node::add_table_to_list(Table_ident *table, TABLE_LIST *st_select_lex_node::add_table_to_list(THD *thd, Table_ident *table,
LEX_STRING *alias, LEX_STRING *alias,
bool updating, bool updating,
thr_lock_type flags, thr_lock_type flags,
...@@ -1269,14 +1269,14 @@ st_select_lex* st_select_lex::select_lex() ...@@ -1269,14 +1269,14 @@ st_select_lex* st_select_lex::select_lex()
return this; return this;
} }
bool st_select_lex::add_item_to_list(Item *item) bool st_select_lex::add_item_to_list(THD *thd, Item *item)
{ {
return item_list.push_back(item); return item_list.push_back(item);
} }
bool st_select_lex::add_group_to_list(Item *item, bool asc) bool st_select_lex::add_group_to_list(THD *thd, Item *item, bool asc)
{ {
return add_to_list(group_list, item, asc); return add_to_list(thd, group_list, item, asc);
} }
bool st_select_lex::add_ftfunc_to_list(Item_func_match *func) bool st_select_lex::add_ftfunc_to_list(Item_func_match *func)
......
...@@ -227,9 +227,9 @@ class st_select_lex_node { ...@@ -227,9 +227,9 @@ class st_select_lex_node {
void exclude(); void exclude();
virtual st_select_lex* select_lex(); virtual st_select_lex* select_lex();
virtual bool add_item_to_list(Item *item); virtual bool add_item_to_list(THD *thd, Item *item);
bool add_order_to_list(Item *item, bool asc); bool add_order_to_list(THD *thd, Item *item, bool asc);
virtual bool add_group_to_list(Item *item, bool asc); virtual bool add_group_to_list(THD *thd, Item *item, bool asc);
virtual bool add_ftfunc_to_list(Item_func_match *func); virtual bool add_ftfunc_to_list(Item_func_match *func);
virtual st_select_lex_unit* master_unit()= 0; virtual st_select_lex_unit* master_unit()= 0;
...@@ -242,7 +242,7 @@ class st_select_lex_node { ...@@ -242,7 +242,7 @@ class st_select_lex_node {
virtual List<Item>* get_item_list(); virtual List<Item>* get_item_list();
virtual List<String>* get_use_index(); virtual List<String>* get_use_index();
virtual List<String>* get_ignore_index(); virtual List<String>* get_ignore_index();
virtual TABLE_LIST *add_table_to_list(Table_ident *table, virtual TABLE_LIST *add_table_to_list(THD *thd, Table_ident *table,
LEX_STRING *alias, LEX_STRING *alias,
bool updating, bool updating,
thr_lock_type flags= TL_UNLOCK, thr_lock_type flags= TL_UNLOCK,
...@@ -363,15 +363,15 @@ class st_select_lex: public st_select_lex_node ...@@ -363,15 +363,15 @@ class st_select_lex: public st_select_lex_node
uint get_in_sum_expr(); uint get_in_sum_expr();
st_select_lex* select_lex(); st_select_lex* select_lex();
bool add_item_to_list(Item *item); bool add_item_to_list(THD *thd, Item *item);
bool add_group_to_list(Item *item, bool asc); bool add_group_to_list(THD *thd, Item *item, bool asc);
bool add_ftfunc_to_list(Item_func_match *func); bool add_ftfunc_to_list(Item_func_match *func);
TABLE_LIST* get_table_list(); TABLE_LIST* get_table_list();
List<Item>* get_item_list(); List<Item>* get_item_list();
List<String>* get_use_index(); List<String>* get_use_index();
List<String>* get_ignore_index(); List<String>* get_ignore_index();
TABLE_LIST* add_table_to_list(Table_ident *table, TABLE_LIST* add_table_to_list(THD *thd, Table_ident *table,
LEX_STRING *alias, LEX_STRING *alias,
bool updating, bool updating,
thr_lock_type flags= TL_UNLOCK, thr_lock_type flags= TL_UNLOCK,
......
...@@ -2070,7 +2070,7 @@ mysql_execute_command(THD *thd) ...@@ -2070,7 +2070,7 @@ mysql_execute_command(THD *thd)
walk->lock_type= auxi->lock_type; walk->lock_type= auxi->lock_type;
auxi->table_list= walk; // Remember corresponding table auxi->table_list= walk; // Remember corresponding table
} }
if (add_item_to_list(new Item_null())) if (add_item_to_list(thd, new Item_null()))
{ {
res= -1; res= -1;
break; break;
...@@ -2927,7 +2927,7 @@ void create_select_for_variable(const char *var_name) ...@@ -2927,7 +2927,7 @@ void create_select_for_variable(const char *var_name)
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
tmp.str= (char*) var_name; tmp.str= (char*) var_name;
tmp.length=strlen(var_name); tmp.length=strlen(var_name);
add_item_to_list(get_system_var(OPT_SESSION, tmp)); add_item_to_list(lex->thd, get_system_var(OPT_SESSION, tmp));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -2992,14 +2992,13 @@ mysql_parse(THD *thd, char *inBuf, uint length) ...@@ -2992,14 +2992,13 @@ mysql_parse(THD *thd, char *inBuf, uint length)
** Return 0 if ok ** Return 0 if ok
******************************************************************************/ ******************************************************************************/
bool add_field_to_list(char *field_name, enum_field_types type, bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
char *length, char *decimals, char *length, char *decimals,
uint type_modifier, uint type_modifier,
Item *default_value, Item *comment, Item *default_value, Item *comment,
char *change, TYPELIB *interval, CHARSET_INFO *cs) char *change, TYPELIB *interval, CHARSET_INFO *cs)
{ {
register create_field *new_field; register create_field *new_field;
THD *thd=current_thd;
LEX *lex= &thd->lex; LEX *lex= &thd->lex;
uint allowed_type_modifier=0; uint allowed_type_modifier=0;
char warn_buff[MYSQL_ERRMSG_SIZE]; char warn_buff[MYSQL_ERRMSG_SIZE];
...@@ -3304,7 +3303,7 @@ add_proc_to_list(THD* thd, Item *item) ...@@ -3304,7 +3303,7 @@ add_proc_to_list(THD* thd, Item *item)
ORDER *order; ORDER *order;
Item **item_ptr; Item **item_ptr;
if (!(order = (ORDER *) sql_alloc(sizeof(ORDER)+sizeof(Item*)))) if (!(order = (ORDER *) thd->alloc(sizeof(ORDER)+sizeof(Item*))))
return 1; return 1;
item_ptr = (Item**) (order+1); item_ptr = (Item**) (order+1);
*item_ptr= item; *item_ptr= item;
...@@ -3351,12 +3350,12 @@ static void remove_escape(char *name) ...@@ -3351,12 +3350,12 @@ static void remove_escape(char *name)
****************************************************************************/ ****************************************************************************/
bool add_to_list(SQL_LIST &list,Item *item,bool asc) bool add_to_list(THD *thd, SQL_LIST &list,Item *item,bool asc)
{ {
ORDER *order; ORDER *order;
Item **item_ptr; Item **item_ptr;
DBUG_ENTER("add_to_list"); DBUG_ENTER("add_to_list");
if (!(order = (ORDER *) sql_alloc(sizeof(ORDER)+sizeof(Item*)))) if (!(order = (ORDER *) thd->alloc(sizeof(ORDER)+sizeof(Item*))))
DBUG_RETURN(1); DBUG_RETURN(1);
item_ptr = (Item**) (order+1); item_ptr = (Item**) (order+1);
*item_ptr=item; *item_ptr=item;
...@@ -3369,7 +3368,8 @@ bool add_to_list(SQL_LIST &list,Item *item,bool asc) ...@@ -3369,7 +3368,8 @@ bool add_to_list(SQL_LIST &list,Item *item,bool asc)
} }
TABLE_LIST *st_select_lex::add_table_to_list(Table_ident *table, TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
Table_ident *table,
LEX_STRING *alias, LEX_STRING *alias,
bool updating, bool updating,
thr_lock_type flags, thr_lock_type flags,
...@@ -3377,7 +3377,6 @@ TABLE_LIST *st_select_lex::add_table_to_list(Table_ident *table, ...@@ -3377,7 +3377,6 @@ TABLE_LIST *st_select_lex::add_table_to_list(Table_ident *table,
List<String> *ignore_index) List<String> *ignore_index)
{ {
register TABLE_LIST *ptr; register TABLE_LIST *ptr;
THD *thd=current_thd;
char *alias_str; char *alias_str;
DBUG_ENTER("add_table_to_list"); DBUG_ENTER("add_table_to_list");
......
...@@ -377,7 +377,6 @@ JOIN::prepare(TABLE_LIST *tables_init, ...@@ -377,7 +377,6 @@ JOIN::prepare(TABLE_LIST *tables_init,
int int
JOIN::optimize() JOIN::optimize()
{ {
ha_rows select_limit;
DBUG_ENTER("JOIN::optimize"); DBUG_ENTER("JOIN::optimize");
#ifdef HAVE_REF_TO_FIELDS // Not done yet #ifdef HAVE_REF_TO_FIELDS // Not done yet
...@@ -400,19 +399,17 @@ JOIN::optimize() ...@@ -400,19 +399,17 @@ JOIN::optimize()
#endif #endif
conds= optimize_cond(conds,&cond_value); conds= optimize_cond(conds,&cond_value);
if (thd->fatal_error) if (thd->fatal_error || thd->net.report_error)
{ {
// quick abort // quick abort
delete procedure; delete procedure;
error= 0; error= thd->net.report_error ? -1 : 1;
DBUG_RETURN(1); DBUG_RETURN(-1); // Return without cleanup
} else if (thd->net.report_error) }
// normal error processing & cleanup
DBUG_RETURN(-1);
if (cond_value == Item::COND_FALSE || if (cond_value == Item::COND_FALSE ||
(!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS))) (!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS)))
{ /* Impossible cond */ { /* Impossible cond */
zero_result_cause= "Impossible WHERE"; zero_result_cause= "Impossible WHERE";
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -429,24 +426,21 @@ JOIN::optimize() ...@@ -429,24 +426,21 @@ JOIN::optimize()
DBUG_RETURN(0); DBUG_RETURN(0);
} }
zero_result_cause= "Select tables optimized away"; zero_result_cause= "Select tables optimized away";
tables_list= 0; // All tables resolved tables_list= 0; // All tables resolved
} }
} }
if (!tables_list) if (!tables_list)
{
test_function_query= 1;
DBUG_RETURN(0); DBUG_RETURN(0);
}
error= -1; error= -1; // Error is sent to client
sort_by_table= get_sort_by_table(order, group_list, tables_list); sort_by_table= get_sort_by_table(order, group_list, tables_list);
/* Calculate how to do the join */ /* Calculate how to do the join */
thd->proc_info= "statistics"; thd->proc_info= "statistics";
if (make_join_statistics(this, tables_list, conds, &keyuse) || if (make_join_statistics(this, tables_list, conds, &keyuse) ||
thd->fatal_error) thd->fatal_error)
DBUG_RETURN(-1); DBUG_RETURN(1);
if (select_lex->dependent) if (select_lex->dependent)
{ {
...@@ -460,7 +454,9 @@ JOIN::optimize() ...@@ -460,7 +454,9 @@ JOIN::optimize()
} }
thd->proc_info= "preparing"; thd->proc_info= "preparing";
if (result->initialize_tables(this)) if (result->initialize_tables(this))
DBUG_RETURN(-1); {
DBUG_RETURN(1); // error = -1
}
if (const_table_map != found_const_table_map && if (const_table_map != found_const_table_map &&
!(select_options & SELECT_DESCRIBE)) !(select_options & SELECT_DESCRIBE))
{ {
...@@ -474,7 +470,7 @@ JOIN::optimize() ...@@ -474,7 +470,7 @@ JOIN::optimize()
{ /* purecov: inspected */ { /* purecov: inspected */
my_message(ER_TOO_BIG_SELECT, ER(ER_TOO_BIG_SELECT), MYF(0)); my_message(ER_TOO_BIG_SELECT, ER(ER_TOO_BIG_SELECT), MYF(0));
error= 1; /* purecov: inspected */ error= 1; /* purecov: inspected */
DBUG_RETURN(-1); DBUG_RETURN(1);
} }
if (const_tables && !thd->locked_tables && if (const_tables && !thd->locked_tables &&
!(select_options & SELECT_NO_UNLOCK)) !(select_options & SELECT_NO_UNLOCK))
...@@ -502,9 +498,9 @@ JOIN::optimize() ...@@ -502,9 +498,9 @@ JOIN::optimize()
select=make_select(*table, const_table_map, select=make_select(*table, const_table_map,
const_table_map, conds, &error); const_table_map, conds, &error);
if (error) if (error)
{ /* purecov: inspected */ { /* purecov: inspected */
error= -1; /* purecov: inspected */ error= -1; /* purecov: inspected */
DBUG_RETURN(-1); DBUG_RETURN(1);
} }
if (make_join_select(this, select, conds)) if (make_join_select(this, select, conds))
{ {
...@@ -543,11 +539,11 @@ JOIN::optimize() ...@@ -543,11 +539,11 @@ JOIN::optimize()
bool all_order_fields_used; bool all_order_fields_used;
if (order) if (order)
skip_sort_order= test_if_skip_sort_order(tab, order, select_limit, 1); skip_sort_order= test_if_skip_sort_order(tab, order, select_limit, 1);
if ((group=create_distinct_group(thd, order, fields_list, if ((group_list=create_distinct_group(thd, order, fields_list,
&all_order_fields_used))) &all_order_fields_used)))
{ {
bool skip_group= (skip_sort_order && bool skip_group= (skip_sort_order &&
test_if_skip_sort_order(tab, group, select_limit, test_if_skip_sort_order(tab, group_list, select_limit,
1) != 0); 1) != 0);
if ((skip_group && all_order_fields_used) || if ((skip_group && all_order_fields_used) ||
select_limit == HA_POS_ERROR || select_limit == HA_POS_ERROR ||
...@@ -561,10 +557,10 @@ JOIN::optimize() ...@@ -561,10 +557,10 @@ JOIN::optimize()
group=1; // For end_write_group group=1; // For end_write_group
} }
else else
group= 0; group_list= 0;
} }
else if (thd->fatal_error) // End of memory else if (thd->fatal_error) // End of memory
DBUG_RETURN(-1); DBUG_RETURN(1);
} }
group_list= remove_const(this, group_list, conds, &simple_group); group_list= remove_const(this, group_list, conds, &simple_group);
if (!group_list && group) if (!group_list && group)
...@@ -648,7 +644,7 @@ JOIN::optimize() ...@@ -648,7 +644,7 @@ JOIN::optimize()
(order && simple_order || group_list && simple_group)) (order && simple_order || group_list && simple_group))
{ {
if (add_ref_to_table_cond(thd,&join_tab[const_tables])) if (add_ref_to_table_cond(thd,&join_tab[const_tables]))
DBUG_RETURN(-1); DBUG_RETURN(1);
} }
if (!(select_options & SELECT_BIG_RESULT) && if (!(select_options & SELECT_BIG_RESULT) &&
...@@ -712,7 +708,7 @@ JOIN::exec() ...@@ -712,7 +708,7 @@ JOIN::exec()
DBUG_ENTER("JOIN::exec"); DBUG_ENTER("JOIN::exec");
if (test_function_query) if (!tables_list)
{ // Only test of functions { // Only test of functions
error=0; error=0;
if (select_options & SELECT_DESCRIBE) if (select_options & SELECT_DESCRIBE)
...@@ -790,9 +786,9 @@ JOIN::exec() ...@@ -790,9 +786,9 @@ JOIN::exec()
group_list : (ORDER*) 0), group_list : (ORDER*) 0),
group_list ? 0 : select_distinct, group_list ? 0 : select_distinct,
group_list && simple_group, group_list && simple_group,
(order == 0 || skip_sort_order) && select_options,
select_limit != HA_POS_ERROR, (order == 0 || skip_sort_order) ? select_limit :
select_options, unit))) HA_POS_ERROR)))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
if (having_list && if (having_list &&
...@@ -917,9 +913,8 @@ JOIN::exec() ...@@ -917,9 +913,8 @@ JOIN::exec()
if (!(tmp_table2 = create_tmp_table(thd, &tmp_table_param, all_fields, if (!(tmp_table2 = create_tmp_table(thd, &tmp_table_param, all_fields,
(ORDER*) 0, (ORDER*) 0,
select_distinct && !group_list, select_distinct && !group_list,
1, 0, 1, select_options, HA_POS_ERROR)))
select_options, unit))) DBUG_VOID_RETURN;
DBUG_VOID_RETURN;
if (group_list) if (group_list)
{ {
thd->proc_info="Creating sort index"; thd->proc_info="Creating sort index";
...@@ -1122,9 +1117,10 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds, ...@@ -1122,9 +1117,10 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex, SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex,
bool fake_select_lex) bool fake_select_lex)
{ {
int err;
bool free_join= 1;
DBUG_ENTER("mysql_select"); DBUG_ENTER("mysql_select");
bool free_join= 1;
JOIN *join; JOIN *join;
if (!fake_select_lex && select_lex->join != 0) if (!fake_select_lex && select_lex->join != 0)
{ {
...@@ -1168,13 +1164,13 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds, ...@@ -1168,13 +1164,13 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
} }
} }
switch (join->optimize()) if ((err= join->optimize()))
{ {
case 1: if (err == -1)
DBUG_RETURN(join->error); DBUG_RETURN(join->error);
case -1: DBUG_ASSERT(err == 1);
goto err; goto err; // 1
} }
if (thd->net.report_error || (free_join && join->global_optimize())) if (thd->net.report_error || (free_join && join->global_optimize()))
goto err; goto err;
...@@ -1187,13 +1183,13 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds, ...@@ -1187,13 +1183,13 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
thd->limit_found_rows = join->send_records; thd->limit_found_rows = join->send_records;
thd->examined_row_count = join->examined_rows; thd->examined_row_count = join->examined_rows;
thd->proc_info="end"; thd->proc_info="end";
int error= (fake_select_lex?join->error:join->cleanup(thd)) || err= (fake_select_lex ? join->error : join->cleanup(thd));
thd->net.report_error; if (thd->net.report_error)
err= -1;
delete join; delete join;
DBUG_RETURN(error); DBUG_RETURN(err);
} }
else DBUG_RETURN(join->error);
DBUG_RETURN(join->error);
} }
/***************************************************************************** /*****************************************************************************
...@@ -3887,8 +3883,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, ...@@ -3887,8 +3883,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
TABLE * TABLE *
create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
ORDER *group, bool distinct, bool save_sum_fields, ORDER *group, bool distinct, bool save_sum_fields,
bool allow_distinct_limit, ulong select_options, ulong select_options, ha_rows rows_limit)
SELECT_LEX_UNIT *unit)
{ {
TABLE *table; TABLE *table;
uint i,field_count,reclength,null_count,null_pack_length, uint i,field_count,reclength,null_count,null_pack_length,
...@@ -3908,9 +3903,9 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -3908,9 +3903,9 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
uint temp_pool_slot=MY_BIT_NONE; uint temp_pool_slot=MY_BIT_NONE;
DBUG_ENTER("create_tmp_table"); DBUG_ENTER("create_tmp_table");
DBUG_PRINT("enter",("distinct: %d save_sum_fields: %d allow_distinct_limit: %d group: %d", DBUG_PRINT("enter",("distinct: %d save_sum_fields: %d rows_limit: %lu group: %d",
(int) distinct, (int) save_sum_fields, (int) distinct, (int) save_sum_fields,
(int) allow_distinct_limit,test(group))); (ulong) rows_limit,test(group)));
statistic_increment(created_tmp_tables, &LOCK_status); statistic_increment(created_tmp_tables, &LOCK_status);
...@@ -4286,13 +4281,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -4286,13 +4281,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
null_pack_length-=hidden_null_pack_length; null_pack_length-=hidden_null_pack_length;
keyinfo->key_parts= ((field_count-param->hidden_field_count)+ keyinfo->key_parts= ((field_count-param->hidden_field_count)+
test(null_pack_length)); test(null_pack_length));
if (allow_distinct_limit) set_if_smaller(table->max_rows, rows_limit);
{ param->end_write_records= rows_limit;
set_if_smaller(table->max_rows, unit->select_limit_cnt);
param->end_write_records= unit->select_limit_cnt;
}
else
param->end_write_records= HA_POS_ERROR;
table->distinct=1; table->distinct=1;
table->keys=1; table->keys=1;
if (blob_count) if (blob_count)
...@@ -5679,7 +5669,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -5679,7 +5669,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
{ {
if ((error=table->file->write_row(table->record[0]))) if ((error=table->file->write_row(table->record[0])))
{ {
if (create_myisam_from_heap(join.thd, table, if (create_myisam_from_heap(join->thd, table,
&join->tmp_table_param, &join->tmp_table_param,
error, 0)) error, 0))
DBUG_RETURN(-1); // Not a table_is_full error DBUG_RETURN(-1); // Not a table_is_full error
...@@ -6060,12 +6050,32 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, ...@@ -6060,12 +6050,32 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
} }
/***************************************************************************** /*
If not selecting by given key, create an index how records should be read If not selecting by given key, create an index how records should be read
return: 0 ok
-1 some fatal error SYNOPSIS
1 no records create_sort_index()
*****************************************************************************/ thd Thread handler
tab Table to sort (in join structure)
order How table should be sorted
filesort_limit Max number of rows that needs to be sorted
select_limit Max number of rows in final output
Used to decide if we should use index or not
IMPLEMENTATION
- If there is an index that can be used, 'tab' is modified to use
this index.
- If no index, create with filesort() an index file that can be used to
retrieve rows in order (should be done with 'read_record').
The sorted data is stored in tab->table and will be freed when calling
free_io_cache(tab->table).
RETURN VALUES
0 ok
-1 Some fatal error
1 No records
*/
static int static int
create_sort_index(THD *thd, JOIN_TAB *tab, ORDER *order, create_sort_index(THD *thd, JOIN_TAB *tab, ORDER *order,
......
...@@ -160,7 +160,7 @@ class JOIN :public Sql_alloc ...@@ -160,7 +160,7 @@ class JOIN :public Sql_alloc
bool sort_and_group,first_record,full_join,group, no_field_update; bool sort_and_group,first_record,full_join,group, no_field_update;
bool do_send_rows; bool do_send_rows;
table_map const_table_map,found_const_table_map,outer_join; table_map const_table_map,found_const_table_map,outer_join;
ha_rows send_records,found_records,examined_rows,row_limit; ha_rows send_records,found_records,examined_rows,row_limit, select_limit;
POSITION positions[MAX_TABLES+1],best_positions[MAX_TABLES+1]; POSITION positions[MAX_TABLES+1],best_positions[MAX_TABLES+1];
double best_read; double best_read;
List<Item> *fields; List<Item> *fields;
...@@ -196,7 +196,6 @@ class JOIN :public Sql_alloc ...@@ -196,7 +196,6 @@ class JOIN :public Sql_alloc
SQL_SELECT *select; //created in optimisation phase SQL_SELECT *select; //created in optimisation phase
TABLE *exec_tmp_table; //used in 'exec' to hold temporary TABLE *exec_tmp_table; //used in 'exec' to hold temporary
my_bool test_function_query; // need to return select items 1 row
const char *zero_result_cause; // not 0 if exec must return zero result const char *zero_result_cause; // not 0 if exec must return zero result
my_bool union_part; // this subselect is part of union my_bool union_part; // this subselect is part of union
...@@ -228,7 +227,6 @@ class JOIN :public Sql_alloc ...@@ -228,7 +227,6 @@ class JOIN :public Sql_alloc
error(0), error(0),
select(0), select(0),
exec_tmp_table(0), exec_tmp_table(0),
test_function_query(0),
zero_result_cause(0) zero_result_cause(0)
{ {
fields_list = fields; fields_list = fields;
...@@ -261,16 +259,15 @@ void TEST_join(JOIN *join); ...@@ -261,16 +259,15 @@ void TEST_join(JOIN *join);
bool store_val_in_field(Field *field,Item *val); bool store_val_in_field(Field *field,Item *val);
TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
ORDER *group, bool distinct, bool save_sum_fields, ORDER *group, bool distinct, bool save_sum_fields,
bool allow_distinct_limit, ulong select_options, ulong select_options, ha_rows rows_limit);
SELECT_LEX_UNIT *unit);
void free_tmp_table(THD *thd, TABLE *entry); void free_tmp_table(THD *thd, TABLE *entry);
void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields, void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
bool reset_with_sum_func); bool reset_with_sum_func);
bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,List<Item> &fields); bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,List<Item> &fields);
void copy_fields(TMP_TABLE_PARAM *param); void copy_fields(TMP_TABLE_PARAM *param);
void copy_funcs(Item_result_field **func_ptr); void copy_funcs(Item_result_field **func_ptr);
bool create_myisam_from_heap(TABLE *table, TMP_TABLE_PARAM *param, int error, bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
bool ignore_last_dupp_error); int error, bool ignore_last_dupp_error);
/* functions from opt_sum.cc */ /* functions from opt_sum.cc */
int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds); int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds);
......
...@@ -81,7 +81,8 @@ bool select_union::send_data(List<Item> &values) ...@@ -81,7 +81,8 @@ bool select_union::send_data(List<Item> &values)
if (thd->net.last_errno == ER_RECORD_FILE_FULL) if (thd->net.last_errno == ER_RECORD_FILE_FULL)
{ {
thd->clear_error(); // do not report user about table overflow thd->clear_error(); // do not report user about table overflow
if (create_myisam_from_heap(table, tmp_table_param, info.last_errno, 0)) if (create_myisam_from_heap(thd, table, tmp_table_param,
info.last_errno, 0))
return 1; return 1;
} }
else else
...@@ -150,10 +151,9 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result) ...@@ -150,10 +151,9 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result)
tmp_table_param.field_count=item_list.elements; tmp_table_param.field_count=item_list.elements;
if (!(table= create_tmp_table(thd, &tmp_table_param, item_list, if (!(table= create_tmp_table(thd, &tmp_table_param, item_list,
(ORDER*) 0, !union_option, (ORDER*) 0, !union_option,
1, 0, 1, (first_select()->options | thd->options |
(first_select()->options | thd->options | TMP_TABLE_ALL_COLUMNS),
TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR)))
this)))
goto err; goto err;
table->file->extra(HA_EXTRA_WRITE_CACHE); table->file->extra(HA_EXTRA_WRITE_CACHE);
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
......
...@@ -437,7 +437,7 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list, ...@@ -437,7 +437,7 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list,
Connect fields with tables and create list of tables that are updated Connect fields with tables and create list of tables that are updated
*/ */
int multi_update::prepare(List<Item> &not_used_values) int multi_update::prepare(List<Item> &not_used_values, SELECT_LEX_UNIT *unit)
{ {
TABLE_LIST *table_ref; TABLE_LIST *table_ref;
SQL_LIST update; SQL_LIST update;
...@@ -531,7 +531,6 @@ int multi_update::prepare(List<Item> &not_used_values) ...@@ -531,7 +531,6 @@ int multi_update::prepare(List<Item> &not_used_values)
for (i=0 ; i < table_count ; i++) for (i=0 ; i < table_count ; i++)
set_if_bigger(max_fields, fields_for_table[i]->elements); set_if_bigger(max_fields, fields_for_table[i]->elements);
copy_field= new Copy_field[max_fields]; copy_field= new Copy_field[max_fields];
init_ftfuncs(thd,1);
DBUG_RETURN(thd->fatal_error != 0); DBUG_RETURN(thd->fatal_error != 0);
} }
...@@ -575,7 +574,7 @@ multi_update::initialize_tables(JOIN *join) ...@@ -575,7 +574,7 @@ multi_update::initialize_tables(JOIN *join)
/* ok to be on stack as this is not referenced outside of this func */ /* ok to be on stack as this is not referenced outside of this func */
Field_string offset(table->file->ref_length, 0, "offset", Field_string offset(table->file->ref_length, 0, "offset",
table, 1); table, my_charset_bin);
if (temp_fields.push_front(new Item_field(((Field *) &offset)))) if (temp_fields.push_front(new Item_field(((Field *) &offset))))
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -591,8 +590,9 @@ multi_update::initialize_tables(JOIN *join) ...@@ -591,8 +590,9 @@ multi_update::initialize_tables(JOIN *join)
if (!(tmp_tables[cnt]=create_tmp_table(thd, if (!(tmp_tables[cnt]=create_tmp_table(thd,
tmp_param, tmp_param,
temp_fields, temp_fields,
(ORDER*) &group, 0, 0, 0, (ORDER*) &group, 0, 0,
TMP_TABLE_ALL_COLUMNS))) TMP_TABLE_ALL_COLUMNS,
HA_POS_ERROR)))
DBUG_RETURN(1); DBUG_RETURN(1);
tmp_tables[cnt]->file->extra(HA_EXTRA_WRITE_CACHE); tmp_tables[cnt]->file->extra(HA_EXTRA_WRITE_CACHE);
} }
...@@ -682,7 +682,8 @@ bool multi_update::send_data(List<Item> &not_used_values) ...@@ -682,7 +682,8 @@ bool multi_update::send_data(List<Item> &not_used_values)
(error != HA_ERR_FOUND_DUPP_KEY && (error != HA_ERR_FOUND_DUPP_KEY &&
error != HA_ERR_FOUND_DUPP_UNIQUE)) error != HA_ERR_FOUND_DUPP_UNIQUE))
{ {
if (create_myisam_from_heap(table, tmp_table_param + offset, error, 1)) if (create_myisam_from_heap(thd, table, tmp_table_param + offset,
error, 1))
{ {
do_update=0; do_update=0;
DBUG_RETURN(1); // Not a table_is_full error DBUG_RETURN(1); // Not a table_is_full error
...@@ -697,7 +698,7 @@ bool multi_update::send_data(List<Item> &not_used_values) ...@@ -697,7 +698,7 @@ bool multi_update::send_data(List<Item> &not_used_values)
void multi_update::send_error(uint errcode,const char *err) void multi_update::send_error(uint errcode,const char *err)
{ {
/* First send error what ever it is ... */ /* First send error what ever it is ... */
::send_error(&thd->net,errcode,err); ::send_error(thd,errcode,err);
/* If nothing updated return */ /* If nothing updated return */
if (!updated) if (!updated)
...@@ -869,7 +870,7 @@ bool multi_update::send_eof() ...@@ -869,7 +870,7 @@ bool multi_update::send_eof()
/* Safety: If we haven't got an error before (should not happen) */ /* Safety: If we haven't got an error before (should not happen) */
my_message(ER_UNKNOWN_ERROR, "An error occured in multi-table update", my_message(ER_UNKNOWN_ERROR, "An error occured in multi-table update",
MYF(0)); MYF(0));
::send_error(&thd->net); ::send_error(thd);
return 1; return 1;
} }
...@@ -880,7 +881,7 @@ bool multi_update::send_eof() ...@@ -880,7 +881,7 @@ bool multi_update::send_eof()
{ {
query_cache_invalidate3(thd, update_tables, 1); query_cache_invalidate3(thd, update_tables, 1);
} }
::send_ok(&thd->net, ::send_ok(thd,
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated, (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
thd->insert_id_used ? thd->insert_id() : 0L,buff); thd->insert_id_used ? thd->insert_id() : 0L,buff);
return 0; return 0;
......
This diff is collapsed.
...@@ -118,7 +118,8 @@ struct st_table { ...@@ -118,7 +118,8 @@ struct st_table {
table_map map; /* ID bit of table (1,2,4,8,16...) */ table_map map; /* ID bit of table (1,2,4,8,16...) */
ulong version,flush_version; ulong version,flush_version;
uchar *null_flags; uchar *null_flags;
IO_CACHE *io_cache; /* If sorted trough filebyte *record_pointers; /* If sorted in memory */ IO_CACHE *io_cache; /* If sorted trough filebyte */
byte *record_pointers; /* If sorted in memory */
ha_rows found_records; /* How many records in sort */ ha_rows found_records; /* How many records in sort */
ORDER *group; ORDER *group;
ha_rows quick_rows[MAX_KEY]; ha_rows quick_rows[MAX_KEY];
......
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