mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
After merge fixes
Added THD to add_to_xxx_list() functions for faster parsing.
This commit is contained in:
@ -75,7 +75,7 @@ int heap_check_heap(HP_INFO *info, my_bool print_status)
|
||||
break; /* End of file */
|
||||
}
|
||||
}
|
||||
_hp_find_record(info,pos);
|
||||
hp_find_record(info,pos);
|
||||
|
||||
if (!info->current_ptr[share->reclength])
|
||||
deleted++;
|
||||
|
@ -199,29 +199,29 @@ select distinct 1 from t1,t3 where t1.a=t3.a;
|
||||
1
|
||||
1
|
||||
explain SELECT distinct t1.a from t1;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 index NULL PRIMARY 4 NULL 2 Using index
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
|
||||
explain SELECT distinct t1.a from t1 order by a desc;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 index NULL PRIMARY 4 NULL 2 Using index
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
|
||||
explain SELECT t1.a from t1 group by a order by a desc;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 index NULL PRIMARY 4 NULL 2 Using index
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
|
||||
explain SELECT distinct t1.a from t1 order by a desc limit 1;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 index NULL PRIMARY 4 NULL 2 Using index
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
|
||||
explain SELECT distinct a from t3 order by a desc limit 2;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t3 index NULL a 5 NULL 204 Using index
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 index NULL a 5 NULL 204 Using index
|
||||
explain SELECT distinct a,b from t3 order by a+1;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
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;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t3 index NULL a 5 NULL 204 Using temporary
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
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;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
|
||||
drop table t1,t2,t3,t4;
|
||||
CREATE TABLE t1 (name varchar(255));
|
||||
INSERT INTO t1 VALUES ('aa'),('ab'),('ac'),('ad'),('ae');
|
||||
|
@ -182,13 +182,13 @@ insert into t1 values(1,1,NULL);
|
||||
insert into t2 values(1,10,NULL),(2,20,NULL);
|
||||
set timestamp=1038000000;
|
||||
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
|
||||
select * from t1;
|
||||
n d t
|
||||
1 10 20021123002000
|
||||
select * from t2;
|
||||
n d t
|
||||
1 10 20021127154957
|
||||
2 20 20021127154957
|
||||
select n,d,unix_timestamp(t) from t1;
|
||||
n d unix_timestamp(t)
|
||||
1 10 1038000000
|
||||
select n,d,unix_timestamp(t) from t2;
|
||||
n d unix_timestamp(t)
|
||||
1 10 1038401397
|
||||
2 20 1038401397
|
||||
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
|
||||
drop table t1,t2;
|
||||
|
@ -183,8 +183,8 @@ insert into t1 values(1,1,NULL);
|
||||
insert into t2 values(1,10,NULL),(2,20,NULL);
|
||||
set timestamp=1038000000;
|
||||
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
select n,d,unix_timestamp(t) from t1;
|
||||
select n,d,unix_timestamp(t) from t2;
|
||||
--error 1064
|
||||
UPDATE t1,t2 SET 1=2 WHERE t1.n=t2.n;
|
||||
drop table t1,t2;
|
||||
|
@ -1577,12 +1577,12 @@ void Field_medium::sql_type(String &res) const
|
||||
int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
char *end;
|
||||
while (len && my_isspace(system_charset_info,*from))
|
||||
while (len && my_isspace(cs,*from))
|
||||
{
|
||||
len--; from++;
|
||||
}
|
||||
long tmp;
|
||||
String tmp_str(from,len);
|
||||
String tmp_str(from, len, cs);
|
||||
from= tmp_str.c_ptr(); // Add end null if needed
|
||||
int error= 0;
|
||||
errno=0;
|
||||
@ -1602,6 +1602,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
if (errno ||
|
||||
(from+len != end && current_thd->count_cuted_fields &&
|
||||
!test_if_int(from,len)))
|
||||
{
|
||||
current_thd->cuted_fields++;
|
||||
error= 1;
|
||||
}
|
||||
@ -1826,12 +1827,12 @@ void Field_long::sql_type(String &res) const
|
||||
int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
char *end;
|
||||
while (len && my_isspace(system_charset_info,*from))
|
||||
while (len && my_isspace(cs,*from))
|
||||
{ // For easy error check
|
||||
len--; from++;
|
||||
}
|
||||
longlong tmp;
|
||||
String tmp_str(from,len);
|
||||
String tmp_str(from, len, cs);
|
||||
from= tmp_str.c_ptr(); // Add end null if needed
|
||||
int error= 0;
|
||||
errno=0;
|
||||
|
@ -43,7 +43,8 @@ Item_sum::Item_sum(List<Item> &list)
|
||||
|
||||
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)
|
||||
@ -991,9 +992,9 @@ bool Item_sum_count_distinct::setup(THD *thd)
|
||||
tmp_table_param->cleanup();
|
||||
}
|
||||
if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1,
|
||||
0, 0,
|
||||
0,
|
||||
select_lex->options | thd->options,
|
||||
select_lex->master_unit())))
|
||||
HA_POS_ERROR)))
|
||||
return 1;
|
||||
table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows
|
||||
table->no_rows=1;
|
||||
@ -1091,7 +1092,7 @@ bool Item_sum_count_distinct::setup(THD *thd)
|
||||
|
||||
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) ||
|
||||
tree_walk(&tree, (tree_walk_action)&dump_leaf, (void*)this,
|
||||
left_root_right))
|
||||
@ -1137,7 +1138,8 @@ bool Item_sum_count_distinct::add()
|
||||
if (tree_to_myisam())
|
||||
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;
|
||||
}
|
||||
else if ((error=table->file->write_row(table->record[0])))
|
||||
@ -1145,13 +1147,15 @@ bool Item_sum_count_distinct::add()
|
||||
if (error != HA_ERR_FOUND_DUPP_KEY &&
|
||||
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 0;
|
||||
}
|
||||
|
||||
|
||||
longlong Item_sum_count_distinct::val_int()
|
||||
{
|
||||
if (!table) // Empty query
|
||||
|
@ -1194,9 +1194,15 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
|
||||
sql_ex.empty_flags = 0;
|
||||
|
||||
switch (handle_dup) {
|
||||
case DUP_IGNORE: sql_ex.opt_flags |= IGNORE_FLAG; break;
|
||||
case DUP_REPLACE: sql_ex.opt_flags |= REPLACE_FLAG; break;
|
||||
case DUP_ERROR: break;
|
||||
case DUP_IGNORE:
|
||||
sql_ex.opt_flags |= IGNORE_FLAG;
|
||||
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())
|
||||
|
@ -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,
|
||||
List<Item> *fields, List<Item> *values,
|
||||
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,
|
||||
List<List_item> &values, List<Item> &update_fields,
|
||||
List<Item> &update_values, enum_duplicates flag);
|
||||
@ -554,13 +555,13 @@ int mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *,
|
||||
|
||||
/* sql_base.cc */
|
||||
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,
|
||||
uint type_modifier,
|
||||
Item *default_value, Item *comment,
|
||||
char *change, TYPELIB *interval,CHARSET_INFO *cs);
|
||||
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_natural(TABLE_LIST *a,TABLE_LIST *b);
|
||||
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,
|
||||
|
||||
/* 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)
|
||||
{
|
||||
table->null_row=1;
|
||||
|
@ -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));
|
||||
tmp_table_param.field_count=item_list.elements;
|
||||
if (!(table=create_tmp_table(thd, &tmp_table_param, item_list,
|
||||
(ORDER*) 0, 0, 1, 0,
|
||||
(ORDER*) 0, 0, 1,
|
||||
(sl->options | thd->options |
|
||||
TMP_TABLE_ALL_COLUMNS),
|
||||
unit)))
|
||||
HA_POS_ERROR)))
|
||||
{
|
||||
res=-1;
|
||||
goto exit;
|
||||
|
@ -1098,19 +1098,19 @@ st_select_lex* st_select_lex_node::select_lex()
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
@ -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<String>* st_select_lex_node::get_use_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,
|
||||
bool updating,
|
||||
thr_lock_type flags,
|
||||
@ -1269,14 +1269,14 @@ st_select_lex* st_select_lex::select_lex()
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -227,9 +227,9 @@ public:
|
||||
void exclude();
|
||||
|
||||
virtual st_select_lex* select_lex();
|
||||
virtual bool add_item_to_list(Item *item);
|
||||
bool add_order_to_list(Item *item, bool asc);
|
||||
virtual bool add_group_to_list(Item *item, bool asc);
|
||||
virtual bool add_item_to_list(THD *thd, Item *item);
|
||||
bool add_order_to_list(THD *thd, 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 st_select_lex_unit* master_unit()= 0;
|
||||
@ -242,7 +242,7 @@ public:
|
||||
virtual List<Item>* get_item_list();
|
||||
virtual List<String>* get_use_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,
|
||||
bool updating,
|
||||
thr_lock_type flags= TL_UNLOCK,
|
||||
@ -363,15 +363,15 @@ public:
|
||||
uint get_in_sum_expr();
|
||||
|
||||
st_select_lex* select_lex();
|
||||
bool add_item_to_list(Item *item);
|
||||
bool add_group_to_list(Item *item, bool asc);
|
||||
bool add_item_to_list(THD *thd, Item *item);
|
||||
bool add_group_to_list(THD *thd, Item *item, bool asc);
|
||||
bool add_ftfunc_to_list(Item_func_match *func);
|
||||
|
||||
TABLE_LIST* get_table_list();
|
||||
List<Item>* get_item_list();
|
||||
List<String>* get_use_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,
|
||||
bool updating,
|
||||
thr_lock_type flags= TL_UNLOCK,
|
||||
|
@ -2070,7 +2070,7 @@ mysql_execute_command(THD *thd)
|
||||
walk->lock_type= auxi->lock_type;
|
||||
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;
|
||||
break;
|
||||
@ -2927,7 +2927,7 @@ void create_select_for_variable(const char *var_name)
|
||||
lex->sql_command= SQLCOM_SELECT;
|
||||
tmp.str= (char*) 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;
|
||||
}
|
||||
|
||||
@ -2992,14 +2992,13 @@ mysql_parse(THD *thd, char *inBuf, uint length)
|
||||
** 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,
|
||||
uint type_modifier,
|
||||
Item *default_value, Item *comment,
|
||||
char *change, TYPELIB *interval, CHARSET_INFO *cs)
|
||||
{
|
||||
register create_field *new_field;
|
||||
THD *thd=current_thd;
|
||||
LEX *lex= &thd->lex;
|
||||
uint allowed_type_modifier=0;
|
||||
char warn_buff[MYSQL_ERRMSG_SIZE];
|
||||
@ -3304,7 +3303,7 @@ add_proc_to_list(THD* thd, Item *item)
|
||||
ORDER *order;
|
||||
Item **item_ptr;
|
||||
|
||||
if (!(order = (ORDER *) sql_alloc(sizeof(ORDER)+sizeof(Item*))))
|
||||
if (!(order = (ORDER *) thd->alloc(sizeof(ORDER)+sizeof(Item*))))
|
||||
return 1;
|
||||
item_ptr = (Item**) (order+1);
|
||||
*item_ptr= item;
|
||||
@ -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;
|
||||
Item **item_ptr;
|
||||
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);
|
||||
item_ptr = (Item**) (order+1);
|
||||
*item_ptr=item;
|
||||
@ -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,
|
||||
bool updating,
|
||||
thr_lock_type flags,
|
||||
@ -3377,7 +3377,6 @@ TABLE_LIST *st_select_lex::add_table_to_list(Table_ident *table,
|
||||
List<String> *ignore_index)
|
||||
{
|
||||
register TABLE_LIST *ptr;
|
||||
THD *thd=current_thd;
|
||||
char *alias_str;
|
||||
DBUG_ENTER("add_table_to_list");
|
||||
|
||||
|
@ -377,7 +377,6 @@ JOIN::prepare(TABLE_LIST *tables_init,
|
||||
int
|
||||
JOIN::optimize()
|
||||
{
|
||||
ha_rows select_limit;
|
||||
DBUG_ENTER("JOIN::optimize");
|
||||
|
||||
#ifdef HAVE_REF_TO_FIELDS // Not done yet
|
||||
@ -400,15 +399,13 @@ JOIN::optimize()
|
||||
#endif
|
||||
|
||||
conds= optimize_cond(conds,&cond_value);
|
||||
if (thd->fatal_error)
|
||||
if (thd->fatal_error || thd->net.report_error)
|
||||
{
|
||||
// quick abort
|
||||
delete procedure;
|
||||
error= 0;
|
||||
DBUG_RETURN(1);
|
||||
} else if (thd->net.report_error)
|
||||
// normal error processing & cleanup
|
||||
DBUG_RETURN(-1);
|
||||
error= thd->net.report_error ? -1 : 1;
|
||||
DBUG_RETURN(-1); // Return without cleanup
|
||||
}
|
||||
|
||||
if (cond_value == Item::COND_FALSE ||
|
||||
(!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS)))
|
||||
@ -434,19 +431,16 @@ JOIN::optimize()
|
||||
}
|
||||
|
||||
if (!tables_list)
|
||||
{
|
||||
test_function_query= 1;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
error= -1;
|
||||
error= -1; // Error is sent to client
|
||||
sort_by_table= get_sort_by_table(order, group_list, tables_list);
|
||||
|
||||
/* Calculate how to do the join */
|
||||
thd->proc_info= "statistics";
|
||||
if (make_join_statistics(this, tables_list, conds, &keyuse) ||
|
||||
thd->fatal_error)
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (select_lex->dependent)
|
||||
{
|
||||
@ -460,7 +454,9 @@ JOIN::optimize()
|
||||
}
|
||||
thd->proc_info= "preparing";
|
||||
if (result->initialize_tables(this))
|
||||
DBUG_RETURN(-1);
|
||||
{
|
||||
DBUG_RETURN(1); // error = -1
|
||||
}
|
||||
if (const_table_map != found_const_table_map &&
|
||||
!(select_options & SELECT_DESCRIBE))
|
||||
{
|
||||
@ -474,7 +470,7 @@ JOIN::optimize()
|
||||
{ /* purecov: inspected */
|
||||
my_message(ER_TOO_BIG_SELECT, ER(ER_TOO_BIG_SELECT), MYF(0));
|
||||
error= 1; /* purecov: inspected */
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (const_tables && !thd->locked_tables &&
|
||||
!(select_options & SELECT_NO_UNLOCK))
|
||||
@ -504,7 +500,7 @@ JOIN::optimize()
|
||||
if (error)
|
||||
{ /* purecov: inspected */
|
||||
error= -1; /* purecov: inspected */
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (make_join_select(this, select, conds))
|
||||
{
|
||||
@ -543,11 +539,11 @@ JOIN::optimize()
|
||||
bool all_order_fields_used;
|
||||
if (order)
|
||||
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)))
|
||||
{
|
||||
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);
|
||||
if ((skip_group && all_order_fields_used) ||
|
||||
select_limit == HA_POS_ERROR ||
|
||||
@ -561,10 +557,10 @@ JOIN::optimize()
|
||||
group=1; // For end_write_group
|
||||
}
|
||||
else
|
||||
group= 0;
|
||||
group_list= 0;
|
||||
}
|
||||
else if (thd->fatal_error) // End of memory
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
group_list= remove_const(this, group_list, conds, &simple_group);
|
||||
if (!group_list && group)
|
||||
@ -648,7 +644,7 @@ JOIN::optimize()
|
||||
(order && simple_order || group_list && simple_group))
|
||||
{
|
||||
if (add_ref_to_table_cond(thd,&join_tab[const_tables]))
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
if (!(select_options & SELECT_BIG_RESULT) &&
|
||||
@ -712,7 +708,7 @@ JOIN::exec()
|
||||
|
||||
DBUG_ENTER("JOIN::exec");
|
||||
|
||||
if (test_function_query)
|
||||
if (!tables_list)
|
||||
{ // Only test of functions
|
||||
error=0;
|
||||
if (select_options & SELECT_DESCRIBE)
|
||||
@ -790,9 +786,9 @@ JOIN::exec()
|
||||
group_list : (ORDER*) 0),
|
||||
group_list ? 0 : select_distinct,
|
||||
group_list && simple_group,
|
||||
(order == 0 || skip_sort_order) &&
|
||||
select_limit != HA_POS_ERROR,
|
||||
select_options, unit)))
|
||||
select_options,
|
||||
(order == 0 || skip_sort_order) ? select_limit :
|
||||
HA_POS_ERROR)))
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
if (having_list &&
|
||||
@ -917,8 +913,7 @@ JOIN::exec()
|
||||
if (!(tmp_table2 = create_tmp_table(thd, &tmp_table_param, all_fields,
|
||||
(ORDER*) 0,
|
||||
select_distinct && !group_list,
|
||||
1, 0,
|
||||
select_options, unit)))
|
||||
1, select_options, HA_POS_ERROR)))
|
||||
DBUG_VOID_RETURN;
|
||||
if (group_list)
|
||||
{
|
||||
@ -1122,9 +1117,10 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
|
||||
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex,
|
||||
bool fake_select_lex)
|
||||
{
|
||||
int err;
|
||||
bool free_join= 1;
|
||||
DBUG_ENTER("mysql_select");
|
||||
|
||||
bool free_join= 1;
|
||||
JOIN *join;
|
||||
if (!fake_select_lex && select_lex->join != 0)
|
||||
{
|
||||
@ -1168,12 +1164,12 @@ 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);
|
||||
case -1:
|
||||
goto err;
|
||||
DBUG_ASSERT(err == 1);
|
||||
goto err; // 1
|
||||
}
|
||||
|
||||
if (thd->net.report_error || (free_join && join->global_optimize()))
|
||||
@ -1187,12 +1183,12 @@ err:
|
||||
thd->limit_found_rows = join->send_records;
|
||||
thd->examined_row_count = join->examined_rows;
|
||||
thd->proc_info="end";
|
||||
int error= (fake_select_lex?join->error:join->cleanup(thd)) ||
|
||||
thd->net.report_error;
|
||||
err= (fake_select_lex ? join->error : join->cleanup(thd));
|
||||
if (thd->net.report_error)
|
||||
err= -1;
|
||||
delete join;
|
||||
DBUG_RETURN(error);
|
||||
DBUG_RETURN(err);
|
||||
}
|
||||
else
|
||||
DBUG_RETURN(join->error);
|
||||
}
|
||||
|
||||
@ -3887,8 +3883,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
|
||||
TABLE *
|
||||
create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
||||
ORDER *group, bool distinct, bool save_sum_fields,
|
||||
bool allow_distinct_limit, ulong select_options,
|
||||
SELECT_LEX_UNIT *unit)
|
||||
ulong select_options, ha_rows rows_limit)
|
||||
{
|
||||
TABLE *table;
|
||||
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,
|
||||
uint temp_pool_slot=MY_BIT_NONE;
|
||||
|
||||
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) allow_distinct_limit,test(group)));
|
||||
(ulong) rows_limit,test(group)));
|
||||
|
||||
statistic_increment(created_tmp_tables, &LOCK_status);
|
||||
|
||||
@ -4286,13 +4281,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
||||
null_pack_length-=hidden_null_pack_length;
|
||||
keyinfo->key_parts= ((field_count-param->hidden_field_count)+
|
||||
test(null_pack_length));
|
||||
if (allow_distinct_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;
|
||||
set_if_smaller(table->max_rows, rows_limit);
|
||||
param->end_write_records= rows_limit;
|
||||
table->distinct=1;
|
||||
table->keys=1;
|
||||
if (blob_count)
|
||||
@ -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 (create_myisam_from_heap(join.thd, table,
|
||||
if (create_myisam_from_heap(join->thd, table,
|
||||
&join->tmp_table_param,
|
||||
error, 0))
|
||||
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,
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
/*
|
||||
If not selecting by given key, create an index how records should be read
|
||||
return: 0 ok
|
||||
-1 some fatal error
|
||||
1 no records
|
||||
*****************************************************************************/
|
||||
|
||||
SYNOPSIS
|
||||
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
|
||||
create_sort_index(THD *thd, JOIN_TAB *tab, ORDER *order,
|
||||
|
@ -160,7 +160,7 @@ class JOIN :public Sql_alloc
|
||||
bool sort_and_group,first_record,full_join,group, no_field_update;
|
||||
bool do_send_rows;
|
||||
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];
|
||||
double best_read;
|
||||
List<Item> *fields;
|
||||
@ -196,7 +196,6 @@ class JOIN :public Sql_alloc
|
||||
SQL_SELECT *select; //created in optimisation phase
|
||||
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
|
||||
|
||||
my_bool union_part; // this subselect is part of union
|
||||
@ -228,7 +227,6 @@ class JOIN :public Sql_alloc
|
||||
error(0),
|
||||
select(0),
|
||||
exec_tmp_table(0),
|
||||
test_function_query(0),
|
||||
zero_result_cause(0)
|
||||
{
|
||||
fields_list = fields;
|
||||
@ -261,16 +259,15 @@ void TEST_join(JOIN *join);
|
||||
bool store_val_in_field(Field *field,Item *val);
|
||||
TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
||||
ORDER *group, bool distinct, bool save_sum_fields,
|
||||
bool allow_distinct_limit, ulong select_options,
|
||||
SELECT_LEX_UNIT *unit);
|
||||
ulong select_options, ha_rows rows_limit);
|
||||
void free_tmp_table(THD *thd, TABLE *entry);
|
||||
void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
|
||||
bool reset_with_sum_func);
|
||||
bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,List<Item> &fields);
|
||||
void copy_fields(TMP_TABLE_PARAM *param);
|
||||
void copy_funcs(Item_result_field **func_ptr);
|
||||
bool create_myisam_from_heap(TABLE *table, TMP_TABLE_PARAM *param, int error,
|
||||
bool ignore_last_dupp_error);
|
||||
bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
|
||||
int error, bool ignore_last_dupp_error);
|
||||
|
||||
/* functions from opt_sum.cc */
|
||||
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)
|
||||
if (thd->net.last_errno == ER_RECORD_FILE_FULL)
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
@ -150,10 +151,9 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result)
|
||||
tmp_table_param.field_count=item_list.elements;
|
||||
if (!(table= create_tmp_table(thd, &tmp_table_param, item_list,
|
||||
(ORDER*) 0, !union_option,
|
||||
1, 0,
|
||||
(first_select()->options | thd->options |
|
||||
1, (first_select()->options | thd->options |
|
||||
TMP_TABLE_ALL_COLUMNS),
|
||||
this)))
|
||||
HA_POS_ERROR)))
|
||||
goto err;
|
||||
table->file->extra(HA_EXTRA_WRITE_CACHE);
|
||||
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
int multi_update::prepare(List<Item> ¬_used_values)
|
||||
int multi_update::prepare(List<Item> ¬_used_values, SELECT_LEX_UNIT *unit)
|
||||
{
|
||||
TABLE_LIST *table_ref;
|
||||
SQL_LIST update;
|
||||
@ -531,7 +531,6 @@ int multi_update::prepare(List<Item> ¬_used_values)
|
||||
for (i=0 ; i < table_count ; i++)
|
||||
set_if_bigger(max_fields, fields_for_table[i]->elements);
|
||||
copy_field= new Copy_field[max_fields];
|
||||
init_ftfuncs(thd,1);
|
||||
DBUG_RETURN(thd->fatal_error != 0);
|
||||
}
|
||||
|
||||
@ -575,7 +574,7 @@ multi_update::initialize_tables(JOIN *join)
|
||||
|
||||
/* ok to be on stack as this is not referenced outside of this func */
|
||||
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))))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
@ -591,8 +590,9 @@ multi_update::initialize_tables(JOIN *join)
|
||||
if (!(tmp_tables[cnt]=create_tmp_table(thd,
|
||||
tmp_param,
|
||||
temp_fields,
|
||||
(ORDER*) &group, 0, 0, 0,
|
||||
TMP_TABLE_ALL_COLUMNS)))
|
||||
(ORDER*) &group, 0, 0,
|
||||
TMP_TABLE_ALL_COLUMNS,
|
||||
HA_POS_ERROR)))
|
||||
DBUG_RETURN(1);
|
||||
tmp_tables[cnt]->file->extra(HA_EXTRA_WRITE_CACHE);
|
||||
}
|
||||
@ -682,7 +682,8 @@ bool multi_update::send_data(List<Item> ¬_used_values)
|
||||
(error != HA_ERR_FOUND_DUPP_KEY &&
|
||||
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;
|
||||
DBUG_RETURN(1); // Not a table_is_full error
|
||||
@ -697,7 +698,7 @@ bool multi_update::send_data(List<Item> ¬_used_values)
|
||||
void multi_update::send_error(uint errcode,const char *err)
|
||||
{
|
||||
/* First send error what ever it is ... */
|
||||
::send_error(&thd->net,errcode,err);
|
||||
::send_error(thd,errcode,err);
|
||||
|
||||
/* If nothing updated return */
|
||||
if (!updated)
|
||||
@ -869,7 +870,7 @@ bool multi_update::send_eof()
|
||||
/* Safety: If we haven't got an error before (should not happen) */
|
||||
my_message(ER_UNKNOWN_ERROR, "An error occured in multi-table update",
|
||||
MYF(0));
|
||||
::send_error(&thd->net);
|
||||
::send_error(thd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -880,7 +881,7 @@ bool multi_update::send_eof()
|
||||
{
|
||||
query_cache_invalidate3(thd, update_tables, 1);
|
||||
}
|
||||
::send_ok(&thd->net,
|
||||
::send_ok(thd,
|
||||
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
|
||||
thd->insert_id_used ? thd->insert_id() : 0L,buff);
|
||||
return 0;
|
||||
|
@ -814,7 +814,7 @@ create:
|
||||
THD *thd= YYTHD;
|
||||
LEX *lex=Lex;
|
||||
lex->sql_command= SQLCOM_CREATE_TABLE;
|
||||
if (!lex->select_lex.add_table_to_list($5,
|
||||
if (!lex->select_lex.add_table_to_list(thd,$5,
|
||||
($2 &
|
||||
HA_LEX_CREATE_TMP_TABLE ?
|
||||
&tmp_table_alias :
|
||||
@ -838,7 +838,7 @@ create:
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
lex->sql_command= SQLCOM_CREATE_INDEX;
|
||||
if (!lex->current_select->add_table_to_list($7,NULL,1))
|
||||
if (!lex->current_select->add_table_to_list(lex->thd, $7,NULL,1))
|
||||
YYABORT;
|
||||
lex->create_list.empty();
|
||||
lex->key_list.empty();
|
||||
@ -1058,7 +1058,7 @@ field_spec:
|
||||
type opt_attribute
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
if (add_field_to_list($1.str,
|
||||
if (add_field_to_list(lex->thd, $1.str,
|
||||
(enum enum_field_types) $3,
|
||||
lex->length,lex->dec,lex->type,
|
||||
lex->default_value, lex->comment,
|
||||
@ -1368,7 +1368,7 @@ alter:
|
||||
LEX *lex=&thd->lex;
|
||||
lex->sql_command = SQLCOM_ALTER_TABLE;
|
||||
lex->name=0;
|
||||
if (!lex->select_lex.add_table_to_list($4, NULL,1))
|
||||
if (!lex->select_lex.add_table_to_list(thd, $4, NULL,1))
|
||||
YYABORT;
|
||||
lex->drop_primary=0;
|
||||
lex->create_list.empty();
|
||||
@ -1423,7 +1423,7 @@ alter_list_item:
|
||||
type opt_attribute
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
if (add_field_to_list($3.str,
|
||||
if (add_field_to_list(lex->thd,$3.str,
|
||||
(enum enum_field_types) $5,
|
||||
lex->length,lex->dec,lex->type,
|
||||
lex->default_value, lex->comment,
|
||||
@ -1634,9 +1634,10 @@ table_to_table_list:
|
||||
table_to_table:
|
||||
table_ident TO_SYM table_ident
|
||||
{
|
||||
SELECT_LEX_NODE *sl= Lex->current_select;
|
||||
if (!sl->add_table_to_list($1,NULL,1,TL_IGNORE) ||
|
||||
!sl->add_table_to_list($3,NULL,1,TL_IGNORE))
|
||||
LEX *lex=Lex;
|
||||
SELECT_LEX_NODE *sl= lex->current_select;
|
||||
if (!sl->add_table_to_list(lex->thd, $1,NULL,1,TL_IGNORE) ||
|
||||
!sl->add_table_to_list(lex->thd, $3,NULL,1,TL_IGNORE))
|
||||
YYABORT;
|
||||
};
|
||||
|
||||
@ -1760,7 +1761,7 @@ select_item_list:
|
||||
| select_item
|
||||
| '*'
|
||||
{
|
||||
if (add_item_to_list(new Item_field(NULL,NULL,"*")))
|
||||
if (add_item_to_list(YYTHD, new Item_field(NULL,NULL,"*")))
|
||||
YYABORT;
|
||||
};
|
||||
|
||||
@ -1768,7 +1769,7 @@ select_item_list:
|
||||
select_item:
|
||||
remember_name select_item2 remember_end select_alias
|
||||
{
|
||||
if (add_item_to_list($2))
|
||||
if (add_item_to_list(YYTHD, $2))
|
||||
YYABORT;
|
||||
if ($4.str)
|
||||
$2->set_name($4.str);
|
||||
@ -2475,7 +2476,8 @@ join_table:
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
SELECT_LEX_NODE *sel= lex->current_select;
|
||||
if (!($$= sel->add_table_to_list($2, $3, 0, lex->lock_option,
|
||||
if (!($$= sel->add_table_to_list(lex->thd, $2, $3, 0,
|
||||
lex->lock_option,
|
||||
sel->get_use_index(),
|
||||
sel->get_ignore_index())))
|
||||
YYABORT;
|
||||
@ -2488,7 +2490,7 @@ join_table:
|
||||
SELECT_LEX_UNIT *unit= lex->current_select->master_unit();
|
||||
lex->current_select= unit->outer_select();
|
||||
if (!($$= lex->current_select->
|
||||
add_table_to_list(new Table_ident(unit), $5, 0,
|
||||
add_table_to_list(lex->thd, new Table_ident(unit), $5, 0,
|
||||
lex->lock_option)))
|
||||
YYABORT;
|
||||
};
|
||||
@ -2623,9 +2625,9 @@ group_clause:
|
||||
|
||||
group_list:
|
||||
group_list ',' order_ident order_dir
|
||||
{ if (add_group_to_list($3,(bool) $4)) YYABORT; }
|
||||
{ if (add_group_to_list(YYTHD, $3,(bool) $4)) YYABORT; }
|
||||
| order_ident order_dir
|
||||
{ if (add_group_to_list($1,(bool) $2)) YYABORT; };
|
||||
{ if (add_group_to_list(YYTHD, $1,(bool) $2)) YYABORT; };
|
||||
|
||||
olap_opt:
|
||||
/* empty */ {}
|
||||
@ -2684,9 +2686,9 @@ order_clause:
|
||||
|
||||
order_list:
|
||||
order_list ',' order_ident order_dir
|
||||
{ if (add_order_to_list($3,(bool) $4)) YYABORT; }
|
||||
{ if (add_order_to_list(YYTHD, $3,(bool) $4)) YYABORT; }
|
||||
| order_ident order_dir
|
||||
{ if (add_order_to_list($1,(bool) $2)) YYABORT; };
|
||||
{ if (add_order_to_list(YYTHD, $1,(bool) $2)) YYABORT; };
|
||||
|
||||
order_dir:
|
||||
/* empty */ { $$ = 1; }
|
||||
@ -2881,7 +2883,7 @@ drop:
|
||||
lex->drop_list.empty();
|
||||
lex->drop_list.push_back(new Alter_drop(Alter_drop::KEY,
|
||||
$3.str));
|
||||
if (!lex->current_select->add_table_to_list($5,NULL, 1))
|
||||
if (!lex->current_select->add_table_to_list(lex->thd, $5,NULL, 1))
|
||||
YYABORT;
|
||||
}
|
||||
| DROP DATABASE if_exists ident
|
||||
@ -2905,7 +2907,7 @@ table_list:
|
||||
|
||||
table_name:
|
||||
table_ident
|
||||
{ if (!Select->add_table_to_list($1, NULL, 1)) YYABORT; };
|
||||
{ if (!Select->add_table_to_list(YYTHD, $1, NULL, 1)) YYABORT; };
|
||||
|
||||
if_exists:
|
||||
/* empty */ { $$= 0; }
|
||||
@ -3109,12 +3111,12 @@ update:
|
||||
update_list:
|
||||
update_list ',' simple_ident equal expr
|
||||
{
|
||||
if (add_item_to_list($3) || add_value_to_list($5))
|
||||
if (add_item_to_list(YYTHD, $3) || add_value_to_list(YYTHD, $5))
|
||||
YYABORT;
|
||||
}
|
||||
| simple_ident equal expr
|
||||
{
|
||||
if (add_item_to_list($1) || add_value_to_list($3))
|
||||
if (add_item_to_list(YYTHD, $1) || add_value_to_list(YYTHD, $3))
|
||||
YYABORT;
|
||||
};
|
||||
|
||||
@ -3139,7 +3141,7 @@ delete:
|
||||
single_multi:
|
||||
FROM table_ident
|
||||
{
|
||||
if (!Select->add_table_to_list($2, NULL, 1, Lex->lock_option))
|
||||
if (!Select->add_table_to_list(YYTHD, $2, NULL, 1, Lex->lock_option))
|
||||
YYABORT;
|
||||
}
|
||||
where_clause opt_order_clause
|
||||
@ -3160,14 +3162,14 @@ table_wild_list:
|
||||
table_wild_one:
|
||||
ident opt_wild
|
||||
{
|
||||
if (!Select->add_table_to_list(new Table_ident($1), NULL, 1,
|
||||
if (!Select->add_table_to_list(YYTHD, new Table_ident($1), NULL, 1,
|
||||
Lex->lock_option))
|
||||
YYABORT;
|
||||
}
|
||||
| ident '.' ident opt_wild
|
||||
{
|
||||
if (!Select->add_table_to_list(new Table_ident($1, $3, 0), NULL, 1,
|
||||
Lex->lock_option))
|
||||
if (!Select->add_table_to_list(YYTHD, new Table_ident($1, $3, 0),
|
||||
NULL, 1, Lex->lock_option))
|
||||
YYABORT;
|
||||
}
|
||||
;
|
||||
@ -3240,7 +3242,7 @@ show_param:
|
||||
Lex->sql_command= SQLCOM_SHOW_FIELDS;
|
||||
if ($5)
|
||||
$4->change_db($5);
|
||||
if (!Select->add_table_to_list($4, NULL, 0))
|
||||
if (!Select->add_table_to_list(YYTHD, $4, NULL, 0))
|
||||
YYABORT;
|
||||
}
|
||||
| NEW_SYM MASTER_SYM FOR_SYM SLAVE WITH MASTER_LOG_FILE_SYM EQ
|
||||
@ -3273,7 +3275,7 @@ show_param:
|
||||
Lex->sql_command= SQLCOM_SHOW_KEYS;
|
||||
if ($4)
|
||||
$3->change_db($4);
|
||||
if (!Select->add_table_to_list($3, NULL, 0))
|
||||
if (!Select->add_table_to_list(YYTHD, $3, NULL, 0))
|
||||
YYABORT;
|
||||
}
|
||||
| COLUMN_SYM TYPES_SYM
|
||||
@ -3331,7 +3333,7 @@ show_param:
|
||||
| CREATE TABLE_SYM table_ident
|
||||
{
|
||||
Lex->sql_command = SQLCOM_SHOW_CREATE;
|
||||
if(!Select->add_table_to_list($3, NULL,0))
|
||||
if(!Select->add_table_to_list(YYTHD, $3, NULL,0))
|
||||
YYABORT;
|
||||
}
|
||||
| MASTER_SYM STATUS_SYM
|
||||
@ -3376,7 +3378,7 @@ describe:
|
||||
lex->wild=0;
|
||||
lex->verbose=0;
|
||||
lex->sql_command=SQLCOM_SHOW_FIELDS;
|
||||
if (!Select->add_table_to_list($2, NULL,0))
|
||||
if (!Select->add_table_to_list(lex->thd, $2, NULL,0))
|
||||
YYABORT;
|
||||
}
|
||||
opt_describe_column {}
|
||||
@ -3500,14 +3502,14 @@ load: LOAD DATA_SYM load_data_lock opt_local INFILE TEXT_STRING
|
||||
opt_duplicate INTO TABLE_SYM table_ident opt_field_term opt_line_term
|
||||
opt_ignore_lines opt_field_spec
|
||||
{
|
||||
if (!Select->add_table_to_list($11, NULL, 1))
|
||||
if (!Select->add_table_to_list(YYTHD, $11, NULL, 1))
|
||||
YYABORT;
|
||||
}
|
||||
|
|
||||
LOAD TABLE_SYM table_ident FROM MASTER_SYM
|
||||
{
|
||||
Lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
|
||||
if (!Select->add_table_to_list($3, NULL, 1))
|
||||
if (!Select->add_table_to_list(YYTHD, $3, NULL, 1))
|
||||
YYABORT;
|
||||
|
||||
}
|
||||
@ -3683,13 +3685,15 @@ ident_or_text:
|
||||
user:
|
||||
ident_or_text
|
||||
{
|
||||
if (!($$=(LEX_USER*) sql_alloc(sizeof(st_lex_user))))
|
||||
THD *thd= YYTHD;
|
||||
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
|
||||
YYABORT;
|
||||
$$->user = $1; $$->host.str=NullS;
|
||||
}
|
||||
| ident_or_text '@' ident_or_text
|
||||
{
|
||||
if (!($$=(LEX_USER*) sql_alloc(sizeof(st_lex_user))))
|
||||
THD *thd= YYTHD;
|
||||
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
|
||||
YYABORT;
|
||||
$$->user = $1; $$->host=$3;
|
||||
};
|
||||
@ -3936,7 +3940,7 @@ option_value:
|
||||
{
|
||||
THD *thd=YYTHD;
|
||||
LEX_USER *user;
|
||||
if (!(user=(LEX_USER*) sql_alloc(sizeof(LEX_USER))))
|
||||
if (!(user=(LEX_USER*) thd->alloc(sizeof(LEX_USER))))
|
||||
YYABORT;
|
||||
user->host.str=0;
|
||||
user->user.str=thd->priv_user;
|
||||
@ -3973,7 +3977,7 @@ text_or_password:
|
||||
$$=$3.str;
|
||||
else
|
||||
{
|
||||
char *buff=(char*) sql_alloc(HASH_PASSWORD_LENGTH+1);
|
||||
char *buff=(char*) YYTHD->alloc(HASH_PASSWORD_LENGTH+1);
|
||||
make_scrambled_password(buff,$3.str);
|
||||
$$=buff;
|
||||
}
|
||||
@ -4011,7 +4015,7 @@ table_lock_list:
|
||||
table_lock:
|
||||
table_ident opt_table_alias lock_option
|
||||
{
|
||||
if (!Select->add_table_to_list($1, $2, 0, (thr_lock_type) $3))
|
||||
if (!Select->add_table_to_list(YYTHD, $1, $2, 0, (thr_lock_type) $3))
|
||||
YYABORT;
|
||||
}
|
||||
;
|
||||
@ -4037,14 +4041,14 @@ handler:
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
lex->sql_command = SQLCOM_HA_OPEN;
|
||||
if (!lex->current_select->add_table_to_list($2, $4, 0))
|
||||
if (!lex->current_select->add_table_to_list(lex->thd, $2, $4, 0))
|
||||
YYABORT;
|
||||
}
|
||||
| HANDLER_SYM table_ident CLOSE_SYM
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
lex->sql_command = SQLCOM_HA_CLOSE;
|
||||
if (!lex->current_select->add_table_to_list($2, 0, 0))
|
||||
if (!lex->current_select->add_table_to_list(lex->thd, $2, 0, 0))
|
||||
YYABORT;
|
||||
}
|
||||
| HANDLER_SYM table_ident READ_SYM
|
||||
@ -4054,7 +4058,7 @@ handler:
|
||||
lex->ha_rkey_mode= HA_READ_KEY_EXACT; /* Avoid purify warnings */
|
||||
lex->current_select->select_limit= 1;
|
||||
lex->current_select->offset_limit= 0L;
|
||||
if (!lex->current_select->add_table_to_list($2, 0, 0))
|
||||
if (!lex->current_select->add_table_to_list(lex->thd, $2, 0, 0))
|
||||
YYABORT;
|
||||
}
|
||||
handler_read_or_scan where_clause opt_limit_clause { }
|
||||
@ -4249,7 +4253,7 @@ opt_table:
|
||||
| table_ident
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
if (!lex->current_select->add_table_to_list($1,NULL,0))
|
||||
if (!lex->current_select->add_table_to_list(lex->thd, $1,NULL,0))
|
||||
YYABORT;
|
||||
if (lex->grant == GLOBAL_ACLS)
|
||||
lex->grant = TABLE_ACLS & ~GRANT_ACL;
|
||||
@ -4273,7 +4277,7 @@ grant_user:
|
||||
$$=$1; $1->password=$4;
|
||||
if ($4.length)
|
||||
{
|
||||
char *buff=(char*) sql_alloc(HASH_PASSWORD_LENGTH+1);
|
||||
char *buff=(char*) YYTHD->alloc(HASH_PASSWORD_LENGTH+1);
|
||||
if (buff)
|
||||
{
|
||||
make_scrambled_password(buff,$4.str);
|
||||
|
@ -118,7 +118,8 @@ struct st_table {
|
||||
table_map map; /* ID bit of table (1,2,4,8,16...) */
|
||||
ulong version,flush_version;
|
||||
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 */
|
||||
ORDER *group;
|
||||
ha_rows quick_rows[MAX_KEY];
|
||||
|
Reference in New Issue
Block a user