Merge paul@bk-internal.mysql.com:/home/bk/mysql-4.1

into teton.kitebird.com:/home/paul/mysql-4.1
This commit is contained in:
paul@teton.kitebird.com 2003-12-19 16:20:59 -06:00
commit 84930f2d10
36 changed files with 494 additions and 259 deletions

View file

@ -65,14 +65,17 @@ Microsoft Visual C++ */
#define HAVE_PWRITE
#endif
/* Apparently in some old SCO Unixes the return type of sprintf is not
an integer as it should be according to the modern Posix standard. Because
of that we define sprintf inside InnoDB code as our own function ut_sprintf */
#undef sprintf
#define sprintf ut_sprintf
#endif /* #if (defined(WIN32) || ... */
/* On the 64-bit Windows we replace printf with ut_printf, etc. so that
we can use the %lu format string to print a 64-bit ulint */
#if defined(__WIN__) && (defined(WIN64) || defined(_WIN64))
#define printf ut_printf
#define sprintf ut_sprintf
#define fprintf ut_fprintf
#endif
/* DEBUG VERSION CONTROL
===================== */

View file

@ -19,14 +19,47 @@ typedef time_t ib_time_t;
/************************************************************
Uses vsprintf to emulate sprintf so that the function always returns
the printed length. Apparently in some old SCO Unixes sprintf did not
return the printed length but a pointer to the end of the printed string. */
On the 64-bit Windows we substitute the format string
%l -> %I64
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
and both the Microsoft and Intel C compilers require the format string
%I64 in that case instead of %l. */
ulint
int
ut_printf(
/*======*/
/* out: the number of characters written, or
negative in case of an error */
const char* format, /* in: format of prints */
...); /* in: arguments to be printed */
/************************************************************
On the 64-bit Windows we substitute the format string
%l -> %I64
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
and both the Microsoft and Intel C compilers require the format string
%I64 in that case instead of %l. */
int
ut_sprintf(
/*=======*/
char* buf, /* in/out: buffer where to print */
/* out: the number of characters written, or
negative in case of an error */
char* buf, /* in: buffer where to print */
const char* format, /* in: format of prints */
...); /* in: arguments to be printed */
/************************************************************
On the 64-bit Windows we substitute the format string
%l -> %I64
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
and both the Microsoft and Intel C compilers require the format string
%I64 in that case instead of %l. */
int
ut_fprintf(
/*=======*/
/* out: the number of characters written, or
negative in case of an error */
FILE* stream, /* in: stream where to print */
const char* format, /* in: format of prints */
...); /* in: arguments to be printed */
/************************************************************

View file

@ -20,26 +20,224 @@ Created 5/11/1994 Heikki Tuuri
ibool ut_always_false = FALSE;
/************************************************************
Uses vsprintf to emulate sprintf so that the function always returns
the printed length. Apparently in some old SCO Unixes sprintf did not
return the printed length but a pointer to the end of the printed string. */
On the 64-bit Windows we substitute the format string
%l -> %I64
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
and both the Microsoft and Intel C compilers require the format string
%I64 in that case instead of %l. */
ulint
ut_sprintf(
/*=======*/
char* buf, /* in/out: buffer where to print */
int
ut_printf(
/*======*/
/* out: the number of characters written, or
negative in case of an error */
const char* format, /* in: format of prints */
...) /* in: arguments to be printed */
{
va_list args;
va_list args;
ulint len;
char* format_end;
char* newformat;
char* ptr;
char* newptr;
int ret;
char format_buf_in_stack[500];
len = strlen(format);
if (len > 250) {
newformat = malloc(2 * len);
} else {
newformat = format_buf_in_stack;
}
format_end = (char*)format + len;
ptr = (char*)format;
newptr = newformat;
#if defined(__WIN__) && (defined(WIN64) || defined(_WIN64))
/* Replace %l with %I64 if it is not preceded with '\' */
while (ptr < format_end) {
if (*ptr == '%' && *(ptr + 1) == 'l'
&& (ptr == format || *(ptr - 1) != '\\')) {
memcpy(newptr, "%I64", 4);
ptr += 2;
newptr += 4;
} else {
*newptr = *ptr;
ptr++;
newptr++;
}
}
*newptr = '\0';
ut_a(newptr < newformat + 2 * len);
#else
strcpy(newformat, format);
#endif
va_start(args, format);
vsprintf(buf, format, args);
ret = vprintf((const char*)newformat, args);
va_end(args);
return((ulint)strlen(buf));
if (newformat != format_buf_in_stack) {
free(newformat);
}
return(ret);
}
/************************************************************
On the 64-bit Windows we substitute the format string
%l -> %I64
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
and both the Microsoft and Intel C compilers require the format string
%I64 in that case instead of %l. */
int
ut_sprintf(
/*=======*/
/* out: the number of characters written, or
negative in case of an error */
char* buf, /* in: buffer where to print */
const char* format, /* in: format of prints */
...) /* in: arguments to be printed */
{
va_list args;
ulint len;
char* format_end;
char* newformat;
char* ptr;
char* newptr;
int ret;
char format_buf_in_stack[500];
len = strlen(format);
if (len > 250) {
newformat = malloc(2 * len);
} else {
newformat = format_buf_in_stack;
}
format_end = (char*)format + len;
ptr = (char*)format;
newptr = newformat;
#if defined(__WIN__) && (defined(WIN64) || defined(_WIN64))
/* Replace %l with %I64 if it is not preceded with '\' */
while (ptr < format_end) {
if (*ptr == '%' && *(ptr + 1) == 'l'
&& (ptr == format || *(ptr - 1) != '\\')) {
memcpy(newptr, "%I64", 4);
ptr += 2;
newptr += 4;
} else {
*newptr = *ptr;
ptr++;
newptr++;
}
}
*newptr = '\0';
ut_a(newptr < newformat + 2 * len);
#else
strcpy(newformat, format);
#endif
va_start(args, format);
ret = vsprintf(buf, (const char*)newformat, args);
va_end(args);
if (newformat != format_buf_in_stack) {
free(newformat);
}
return(ret);
}
/************************************************************
On the 64-bit Windows we substitute the format string
%l -> %I64
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
and both the Microsoft and Intel C compilers require the format string
%I64 in that case instead of %l. */
int
ut_fprintf(
/*=======*/
/* out: the number of characters written, or
negative in case of an error */
FILE* stream, /* in: stream where to print */
const char* format, /* in: format of prints */
...) /* in: arguments to be printed */
{
va_list args;
ulint len;
char* format_end;
char* newformat;
char* ptr;
char* newptr;
int ret;
char format_buf_in_stack[500];
len = strlen(format);
if (len > 250) {
newformat = malloc(2 * len);
} else {
newformat = format_buf_in_stack;
}
format_end = (char*)format + len;
ptr = (char*)format;
newptr = newformat;
#if defined(__WIN__) && (defined(WIN64) || defined(_WIN64))
/* Replace %l with %I64 if it is not preceded with '\' */
while (ptr < format_end) {
if (*ptr == '%' && *(ptr + 1) == 'l'
&& (ptr == format || *(ptr - 1) != '\\')) {
memcpy(newptr, "%I64", 4);
ptr += 2;
newptr += 4;
} else {
*newptr = *ptr;
ptr++;
newptr++;
}
}
*newptr = '\0';
ut_a(newptr < newformat + 2 * len);
#else
strcpy(newformat, format);
#endif
va_start(args, format);
ret = vfprintf(stream, (const char*)newformat, args);
va_end(args);
if (newformat != format_buf_in_stack) {
free(newformat);
}
return(ret);
}
/************************************************************

View file

@ -746,7 +746,7 @@ bool Protocol::convert_str(const char *from, uint length)
bool setup_params_data(st_prep_stmt *stmt)
{
THD *thd= stmt->thd;
List<Item> &params= thd->lex.param_list;
List<Item> &params= thd->lex->param_list;
List_iterator<Item> param_iterator(params);
Item_param *param;
ulong param_no= 0;
@ -779,7 +779,7 @@ bool setup_params_data(st_prep_stmt *stmt)
bool setup_params_data_withlog(st_prep_stmt *stmt)
{
THD *thd= stmt->thd;
List<Item> &params= thd->lex.param_list;
List<Item> &params= thd->lex->param_list;
List_iterator<Item> param_iterator(params);
Item_param *param;
MYSQL_BIND *client_param= thd->client_params;

View file

@ -1128,7 +1128,7 @@ get_addon_fields(THD *thd, Field **ptabfield, uint sortlength, uint *plength)
The fact is the filter 'field->query_id != thd->query_id'
doesn't work for alter table
*/
if (thd->lex.sql_command != SQLCOM_SELECT)
if (thd->lex->sql_command != SQLCOM_SELECT)
return 0;
for (pfield= ptabfield; (field= *pfield) ; pfield++)
{

View file

@ -2253,8 +2253,8 @@ ha_innobase::write_row(
skip_auto_inc_decr = FALSE;
if (error == DB_DUPLICATE_KEY
&& (user_thd->lex.sql_command == SQLCOM_REPLACE
|| user_thd->lex.sql_command
&& (user_thd->lex->sql_command == SQLCOM_REPLACE
|| user_thd->lex->sql_command
== SQLCOM_REPLACE_SELECT)) {
skip_auto_inc_decr= TRUE;

View file

@ -390,7 +390,7 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
{
HA_CHECK_OPT tmp_check_opt;
char* backup_dir = thd->lex.backup_dir;
char* backup_dir= thd->lex->backup_dir;
char src_path[FN_REFLEN], dst_path[FN_REFLEN];
char* table_name = table->real_name;
int error;
@ -430,7 +430,7 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt)
{
char* backup_dir = thd->lex.backup_dir;
char* backup_dir= thd->lex->backup_dir;
char src_path[FN_REFLEN], dst_path[FN_REFLEN];
char* table_name = table->real_name;
int error;

View file

@ -53,16 +53,16 @@ Item::Item():
thd->free_list= this;
/*
Item constructor can be called during execution other then SQL_COM
command => we should check thd->lex.current_select on zero (thd->lex
command => we should check thd->lex->current_select on zero (thd->lex
can be uninitialised)
*/
if (thd->lex.current_select)
if (thd->lex->current_select)
{
SELECT_LEX_NODE::enum_parsing_place place=
thd->lex.current_select->parsing_place;
thd->lex->current_select->parsing_place;
if (place == SELECT_LEX_NODE::SELECT_LIST ||
place == SELECT_LEX_NODE::IN_HAVING)
thd->lex.current_select->select_n_having_items++;
thd->lex->current_select->select_n_having_items++;
}
}
@ -802,7 +802,7 @@ static void mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
// store pointer on SELECT_LEX from wich item is dependent
item->depended_from= last;
current->mark_as_dependent(last);
if (thd->lex.describe & DESCRIBE_EXTENDED)
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
sprintf(warn_buff, ER(ER_WARN_FIELD_RESOLVED),
@ -843,7 +843,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
Item **refer= (Item **)not_found_item;
uint counter;
// Prevent using outer fields in subselects, that is not supported now
SELECT_LEX *cursel=(SELECT_LEX *) thd->lex.current_select;
SELECT_LEX *cursel= (SELECT_LEX *) thd->lex->current_select;
if (cursel->master_unit()->first_select()->linkage != DERIVED_TABLE_TYPE)
{
SELECT_LEX_UNIT *prev_unit= cursel->master_unit();
@ -1439,7 +1439,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
{
TABLE_LIST *where= 0, *table_list;
bool upward_lookup= 0;
SELECT_LEX_UNIT *prev_unit= thd->lex.current_select->master_unit();
SELECT_LEX_UNIT *prev_unit= thd->lex->current_select->master_unit();
SELECT_LEX *sl= prev_unit->outer_select();
/*
Finding only in current select will be performed for selects that have
@ -1447,10 +1447,10 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
fields for now)
*/
if ((ref= find_item_in_list(this,
*(thd->lex.current_select->get_item_list()),
*(thd->lex->current_select->get_item_list()),
&counter,
((sl &&
thd->lex.current_select->master_unit()->
thd->lex->current_select->master_unit()->
first_select()->linkage !=
DERIVED_TABLE_TYPE) ?
REPORT_EXCEPT_NOT_FOUND :
@ -1526,7 +1526,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
{
// Call to report error
find_item_in_list(this,
*(thd->lex.current_select->get_item_list()),
*(thd->lex->current_select->get_item_list()),
&counter,
REPORT_ALL_ERRORS);
}
@ -1539,7 +1539,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
Item_field* fld;
if (!((*reference)= fld= new Item_field(tmp)))
return 1;
mark_as_dependent(thd, last, thd->lex.current_select, fld);
mark_as_dependent(thd, last, thd->lex->current_select, fld);
return 0;
}
else
@ -1550,7 +1550,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
"forward reference in item list");
return -1;
}
mark_as_dependent(thd, last, thd->lex.current_select,
mark_as_dependent(thd, last, thd->lex->current_select,
this);
ref= last->ref_pointer_array + counter;
}
@ -1565,7 +1565,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
"forward reference in item list");
return -1;
}
ref= thd->lex.current_select->ref_pointer_array + counter;
ref= thd->lex->current_select->ref_pointer_array + counter;
}
}
@ -1578,8 +1578,8 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
*/
if (((*ref)->with_sum_func && name &&
(depended_from ||
!(thd->lex.current_select->linkage != GLOBAL_OPTIONS_TYPE &&
thd->lex.current_select->having_fix_field))) ||
!(thd->lex->current_select->linkage != GLOBAL_OPTIONS_TYPE &&
thd->lex->current_select->having_fix_field))) ||
!(*ref)->fixed)
{
my_error(ER_ILLEGAL_REFERENCE, MYF(0), name,

View file

@ -1723,7 +1723,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if (item->maybe_null)
maybe_null=1;
}
thd->lex.current_select->cond_count+=list.elements;
thd->lex->current_select->cond_count+= list.elements;
fix_length_and_dec();
fixed= 1;
return 0;

View file

@ -76,7 +76,7 @@ Item *create_func_ceiling(Item* a)
Item *create_func_connection_id(void)
{
THD *thd=current_thd;
thd->lex.safe_to_cache_query=0;
thd->lex->safe_to_cache_query= 0;
return new Item_int(NullS,(longlong)
((thd->slave_thread) ?
thd->variables.pseudo_thread_id :
@ -148,7 +148,7 @@ Item *create_func_floor(Item* a)
Item *create_func_found_rows(void)
{
THD *thd=current_thd;
thd->lex.safe_to_cache_query=0;
thd->lex->safe_to_cache_query= 0;
return new Item_int(NullS,(longlong) thd->found_rows(),21);
}
@ -159,7 +159,7 @@ Item *create_func_from_days(Item* a)
Item *create_func_get_lock(Item* a, Item *b)
{
current_thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT);
current_thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
return new Item_func_get_lock(a, b);
}
@ -324,7 +324,7 @@ Item *create_func_radians(Item *a)
Item *create_func_release_lock(Item* a)
{
current_thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT);
current_thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
return new Item_func_release_lock(a);
}
@ -445,7 +445,7 @@ Item *create_func_year(Item* a)
Item *create_load_file(Item* a)
{
current_thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT);
current_thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
return new Item_load_file(a);
}
@ -472,13 +472,13 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len,
Item *create_func_is_free_lock(Item* a)
{
current_thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT);
current_thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
return new Item_func_is_free_lock(a);
}
Item *create_func_is_used_lock(Item* a)
{
current_thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT);
current_thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
return new Item_func_is_used_lock(a);
}

View file

@ -2481,7 +2481,7 @@ void Item_func_get_user_var::fix_length_and_dec()
if (!(var_entry= get_variable(&thd->user_vars, name, 0)))
null_value= 1;
if (!(opt_bin_log && is_update_query(thd->lex.sql_command)))
if (!(opt_bin_log && is_update_query(thd->lex->sql_command)))
return;
if (!var_entry)
@ -2950,7 +2950,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
}
if (!(item=var->item(thd, var_type, component_name)))
return 0; // Impossible
thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT);
thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
buff[0]='@';
buff[1]='@';
pos=buff+2;
@ -2990,7 +2990,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, const char *var_name,
DBUG_ASSERT(var != 0);
if (!(item=var->item(thd, var_type, &null_lex_string)))
return 0; // Impossible
thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT);
thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
item->set_name(item_name, 0, system_charset_info); // Will use original name
return item;
}

View file

@ -253,7 +253,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
{
have_to_be_excluded= 1;
if (join->thd->lex.describe)
if (join->thd->lex->describe)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number);
@ -608,14 +608,14 @@ Item_in_subselect::single_value_transformer(JOIN *join,
subs= new Item_maxmin_subselect(this, select_lex, func->l_op());
}
// left expression belong to outer select
SELECT_LEX *current= thd_tmp->lex.current_select, *up;
thd_tmp->lex.current_select= up= current->return_after_parsing();
SELECT_LEX *current= thd_tmp->lex->current_select, *up;
thd_tmp->lex->current_select= up= current->return_after_parsing();
if (left_expr->fix_fields(thd_tmp, up->get_table_list(), &left_expr))
{
thd_tmp->lex.current_select= current;
thd_tmp->lex->current_select= current;
DBUG_RETURN(RES_ERROR);
}
thd_tmp->lex.current_select= current;
thd_tmp->lex->current_select= current;
substitution= func->create(left_expr, subs);
DBUG_RETURN(RES_OK);
}
@ -626,16 +626,16 @@ Item_in_subselect::single_value_transformer(JOIN *join,
SELECT_LEX_UNIT *unit= select_lex->master_unit();
substitution= optimizer= new Item_in_optimizer(left_expr, this);
SELECT_LEX *current= thd_tmp->lex.current_select, *up;
SELECT_LEX *current= thd_tmp->lex->current_select, *up;
thd_tmp->lex.current_select= up= current->return_after_parsing();
thd_tmp->lex->current_select= up= current->return_after_parsing();
//optimizer never use Item **ref => we can pass 0 as parameter
if (!optimizer || optimizer->fix_left(thd_tmp, up->get_table_list(), 0))
{
thd_tmp->lex.current_select= current;
thd_tmp->lex->current_select= current;
DBUG_RETURN(RES_ERROR);
}
thd_tmp->lex.current_select= current;
thd_tmp->lex->current_select= current;
/*
As far as Item_ref_in_optimizer do not substitude itself on fix_fields
@ -726,7 +726,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
// fix_field of item will be done in time of substituting
substitution= item;
have_to_be_excluded= 1;
if (thd_tmp->lex.describe)
if (thd_tmp->lex->describe)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number);
@ -763,15 +763,15 @@ Item_in_subselect::row_value_transformer(JOIN *join)
SELECT_LEX_UNIT *unit= select_lex->master_unit();
substitution= optimizer= new Item_in_optimizer(left_expr, this);
SELECT_LEX *current= thd_tmp->lex.current_select, *up;
thd_tmp->lex.current_select= up= current->return_after_parsing();
SELECT_LEX *current= thd_tmp->lex->current_select, *up;
thd_tmp->lex->current_select= up= current->return_after_parsing();
//optimizer never use Item **ref => we can pass 0 as parameter
if (!optimizer || optimizer->fix_left(thd_tmp, up->get_table_list(), 0))
{
thd_tmp->lex.current_select= current;
thd_tmp->lex->current_select= current;
DBUG_RETURN(RES_ERROR);
}
thd_tmp->lex.current_select= current;
thd_tmp->lex->current_select= current;
unit->uncacheable|= UNCACHEABLE_DEPENDENT;
}
@ -913,8 +913,8 @@ int subselect_single_select_engine::prepare()
return 1;
}
prepared= 1;
SELECT_LEX *save_select= thd->lex.current_select;
thd->lex.current_select= select_lex;
SELECT_LEX *save_select= thd->lex->current_select;
thd->lex->current_select= select_lex;
if (join->prepare(&select_lex->ref_pointer_array,
(TABLE_LIST*) select_lex->table_list.first,
select_lex->with_wild,
@ -927,7 +927,7 @@ int subselect_single_select_engine::prepare()
(ORDER*) 0, select_lex,
select_lex->master_unit()))
return 1;
thd->lex.current_select= save_select;
thd->lex->current_select= save_select;
return 0;
}
@ -1000,8 +1000,8 @@ int subselect_single_select_engine::exec()
{
DBUG_ENTER("subselect_single_select_engine::exec");
char const *save_where= join->thd->where;
SELECT_LEX *save_select= join->thd->lex.current_select;
join->thd->lex.current_select= select_lex;
SELECT_LEX *save_select= join->thd->lex->current_select;
join->thd->lex->current_select= select_lex;
if (!optimized)
{
optimized=1;
@ -1009,7 +1009,7 @@ int subselect_single_select_engine::exec()
{
join->thd->where= save_where;
executed= 1;
join->thd->lex.current_select= save_select;
join->thd->lex->current_select= save_select;
DBUG_RETURN(join->error?join->error:1);
}
if (item->engine_changed)
@ -1022,7 +1022,7 @@ int subselect_single_select_engine::exec()
if (join->reinit())
{
join->thd->where= save_where;
join->thd->lex.current_select= save_select;
join->thd->lex->current_select= save_select;
DBUG_RETURN(1);
}
item->reset();
@ -1033,11 +1033,11 @@ int subselect_single_select_engine::exec()
join->exec();
executed= 1;
join->thd->where= save_where;
join->thd->lex.current_select= save_select;
join->thd->lex->current_select= save_select;
DBUG_RETURN(join->error||thd->is_fatal_error);
}
join->thd->where= save_where;
join->thd->lex.current_select= save_select;
join->thd->lex->current_select= save_select;
DBUG_RETURN(0);
}

View file

@ -57,7 +57,7 @@ Item_sum::Item_sum(THD *thd, Item_sum &item):
void Item_sum::mark_as_sum_func()
{
current_thd->lex.current_select->with_sum_func= 1;
current_thd->lex->current_select->with_sum_func= 1;
with_sum_func= 1;
}
@ -1120,7 +1120,7 @@ void Item_sum_count_distinct::make_unique()
bool Item_sum_count_distinct::setup(THD *thd)
{
List<Item> list;
SELECT_LEX *select_lex= thd->lex.current_select;
SELECT_LEX *select_lex= thd->lex->current_select;
if (select_lex->linkage == GLOBAL_OPTIONS_TYPE)
return 1;
@ -1802,7 +1802,7 @@ bool Item_func_group_concat::setup(THD *thd)
{
DBUG_ENTER("Item_func_group_concat::setup");
List<Item> list;
SELECT_LEX *select_lex= thd->lex.current_select;
SELECT_LEX *select_lex= thd->lex->current_select;
if (select_lex->linkage == GLOBAL_OPTIONS_TYPE)
DBUG_RETURN(1);

View file

@ -537,7 +537,7 @@ 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);
void kill_delayed_threads(void);
int mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, ORDER *order,
int mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, SQL_LIST *order,
ha_rows rows, ulong options);
int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok=0);
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update);
@ -1036,22 +1036,22 @@ SQL_CRYPT *get_crypt_for_frm(void);
inline bool add_item_to_list(THD *thd, Item *item)
{
return thd->lex.current_select->add_item_to_list(thd, item);
return thd->lex->current_select->add_item_to_list(thd, item);
}
inline bool add_value_to_list(THD *thd, Item *value)
{
return thd->lex.value_list.push_back(value);
return thd->lex->value_list.push_back(value);
}
inline bool add_order_to_list(THD *thd, Item *item, bool asc)
{
return thd->lex.current_select->add_order_to_list(thd, item, asc);
return thd->lex->current_select->add_order_to_list(thd, item, asc);
}
inline bool add_group_to_list(THD *thd, Item *item, bool asc)
{
return thd->lex.current_select->add_group_to_list(thd, item, asc);
return thd->lex->current_select->add_group_to_list(thd, item, asc);
}
inline void mark_as_null_row(TABLE *table)

View file

@ -1275,12 +1275,12 @@ static void server_init(void)
void yyerror(const char *s)
{
THD *thd=current_thd;
char *yytext=(char*) thd->lex.tok_start;
char *yytext= (char*) thd->lex->tok_start;
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
s=ER(ER_SYNTAX_ERROR);
net_printf(thd,ER_PARSE_ERROR, s, yytext ? (char*) yytext : "",
thd->lex.yylineno);
thd->lex->yylineno);
}
@ -1878,11 +1878,11 @@ extern "C" int my_message_sql(uint error, const char *str,
if ((thd= current_thd))
{
/*
thd->lex.current_select == 0 if lex structure is not inited
thd->lex->current_select == 0 if lex structure is not inited
(not query command (COM_QUERY))
*/
if (thd->lex.current_select &&
thd->lex.current_select->no_error && !thd->is_fatal_error)
if (thd->lex->current_select &&
thd->lex->current_select->no_error && !thd->is_fatal_error)
{
DBUG_PRINT("error", ("above error converted to warning"));
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str);

View file

@ -122,7 +122,7 @@ void send_error(THD *thd, uint sql_errno, const char *err)
thd->net.report_error= 0;
/* Abort multi-result sets */
thd->lex.found_colon= 0;
thd->lex->found_colon= 0;
thd->server_status= ~SERVER_MORE_RESULTS_EXISTS;
DBUG_VOID_RETURN;
}

View file

@ -441,7 +441,7 @@ int show_new_master(THD* thd)
DBUG_ENTER("show_new_master");
List<Item> field_list;
char errmsg[SLAVE_ERRMSG_SIZE];
LEX_MASTER_INFO* lex_mi = &thd->lex.mi;
LEX_MASTER_INFO* lex_mi= &thd->lex->mi;
errmsg[0]=0; // Safety
if (translate_master(thd, lex_mi, errmsg))

View file

@ -2739,7 +2739,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
thd->server_id = ev->server_id; // use the original server id for logging
thd->set_time(); // time the query
thd->lex.current_select= 0;
thd->lex->current_select= 0;
if (!ev->when)
ev->when = time(NULL);
ev->thd = thd;

View file

@ -1476,7 +1476,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
if (table->fields >= 31) /* From 4.0.0 we have more fields */
{
/* We write down SSL related ACL stuff */
switch (thd->lex.ssl_type) {
switch (thd->lex->ssl_type) {
case SSL_TYPE_ANY:
table->field[24]->store("ANY",3, &my_charset_latin1);
table->field[25]->store("", 0, &my_charset_latin1);
@ -1494,15 +1494,15 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
table->field[25]->store("", 0, &my_charset_latin1);
table->field[26]->store("", 0, &my_charset_latin1);
table->field[27]->store("", 0, &my_charset_latin1);
if (thd->lex.ssl_cipher)
table->field[25]->store(thd->lex.ssl_cipher,
strlen(thd->lex.ssl_cipher), &my_charset_latin1);
if (thd->lex.x509_issuer)
table->field[26]->store(thd->lex.x509_issuer,
strlen(thd->lex.x509_issuer), &my_charset_latin1);
if (thd->lex.x509_subject)
table->field[27]->store(thd->lex.x509_subject,
strlen(thd->lex.x509_subject), &my_charset_latin1);
if (thd->lex->ssl_cipher)
table->field[25]->store(thd->lex->ssl_cipher,
strlen(thd->lex->ssl_cipher), &my_charset_latin1);
if (thd->lex->x509_issuer)
table->field[26]->store(thd->lex->x509_issuer,
strlen(thd->lex->x509_issuer), &my_charset_latin1);
if (thd->lex->x509_subject)
table->field[27]->store(thd->lex->x509_subject,
strlen(thd->lex->x509_subject), &my_charset_latin1);
break;
case SSL_TYPE_NOT_SPECIFIED:
break;
@ -1514,7 +1514,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
break;
}
USER_RESOURCES mqh = thd->lex.mqh;
USER_RESOURCES mqh= thd->lex->mqh;
if (mqh.bits & 1)
table->field[28]->store((longlong) mqh.questions);
if (mqh.bits & 2)
@ -1555,19 +1555,19 @@ end:
acl_cache->clear(1); // Clear privilege cache
if (old_row_exists)
acl_update_user(combo.user.str, combo.host.str, password, password_len,
thd->lex.ssl_type,
thd->lex.ssl_cipher,
thd->lex.x509_issuer,
thd->lex.x509_subject,
&thd->lex.mqh,
thd->lex->ssl_type,
thd->lex->ssl_cipher,
thd->lex->x509_issuer,
thd->lex->x509_subject,
&thd->lex->mqh,
rights);
else
acl_insert_user(combo.user.str, combo.host.str, password, password_len,
thd->lex.ssl_type,
thd->lex.ssl_cipher,
thd->lex.x509_issuer,
thd->lex.x509_subject,
&thd->lex.mqh,
thd->lex->ssl_type,
thd->lex->ssl_cipher,
thd->lex->x509_issuer,
thd->lex->x509_subject,
&thd->lex->mqh,
rights);
}
table->file->index_end();

View file

@ -2198,7 +2198,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
DBUG_ENTER("setup_conds");
thd->set_query_id=1;
thd->lex.current_select->cond_count= 0;
thd->lex->current_select->cond_count= 0;
if (*conds)
{
thd->where="where clause";
@ -2217,7 +2217,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
if (table->on_expr->fix_fields(thd, tables, &table->on_expr) ||
table->on_expr->check_cols(1))
DBUG_RETURN(1);
thd->lex.current_select->cond_count++;
thd->lex->current_select->cond_count++;
/*
If it's a normal join or a LEFT JOIN which can be optimized away
@ -2269,7 +2269,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
}
}
cond_and->used_tables_cache= t1->map | t2->map;
thd->lex.current_select->cond_count+=cond_and->list.elements;
thd->lex->current_select->cond_count+= cond_and->list.elements;
if (!table->outer_join) // Not left join
{
if (!(*conds=and_conds(*conds, cond_and)))

View file

@ -289,7 +289,7 @@ TODO list:
if (thd->temp_tables || global_merge_table_count)
- Another option would be to set thd->lex.safe_to_cache_query to 0
- Another option would be to set thd->lex->safe_to_cache_query to 0
in 'get_lock_data' if any of the tables was a tmp table or a
MRG_ISAM table.
(This could be done with almost no speed penalty)
@ -761,7 +761,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
uint8 tables_type= 0;
if ((local_tables= is_cacheable(thd, thd->query_length,
thd->query, &thd->lex, tables_used,
thd->query, thd->lex, tables_used,
&tables_type)))
{
NET *net= &thd->net;
@ -913,7 +913,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
/* Check that we haven't forgot to reset the query cache variables */
DBUG_ASSERT(thd->net.query_cache_query == 0);
if (!thd->lex.safe_to_cache_query)
if (!thd->lex->safe_to_cache_query)
{
DBUG_PRINT("qcache", ("SELECT is non-cacheable"));
goto err;
@ -1018,7 +1018,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
table_list.db, table_list.alias));
refused++; // This is actually a hit
STRUCT_UNLOCK(&structure_guard_mutex);
thd->lex.safe_to_cache_query=0; // Don't try to cache this
thd->lex->safe_to_cache_query=0; // Don't try to cache this
BLOCK_UNLOCK_RD(query_block);
DBUG_RETURN(-1); // Privilege error
}
@ -1027,7 +1027,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
DBUG_PRINT("qcache", ("Need to check column privileges for %s.%s",
table_list.db, table_list.alias));
BLOCK_UNLOCK_RD(query_block);
thd->lex.safe_to_cache_query= 0; // Don't try to cache this
thd->lex->safe_to_cache_query= 0; // Don't try to cache this
goto err_unlock; // Parse query
}
#endif /*!NO_EMBEDDED_ACCESS_CHECKS*/
@ -1038,7 +1038,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
DBUG_PRINT("qcache", ("Handler does not allow caching for %s.%s",
table_list.db, table_list.alias));
BLOCK_UNLOCK_RD(query_block);
thd->lex.safe_to_cache_query= 0; // Don't try to cache this
thd->lex->safe_to_cache_query= 0; // Don't try to cache this
goto err_unlock; // Parse query
}
else
@ -2615,7 +2615,7 @@ my_bool Query_cache::ask_handler_allowance(THD *thd,
{
DBUG_PRINT("qcache", ("Handler does not allow caching for %s.%s",
tables_used->db, tables_used->alias));
thd->lex.safe_to_cache_query= 0; // Don't try to cache this
thd->lex->safe_to_cache_query= 0; // Don't try to cache this
DBUG_RETURN(1);
}
}

View file

@ -89,6 +89,7 @@ THD::THD():user_time(0), is_fatal_error(0),
global_read_lock(0), bootstrap(0)
{
host=user=priv_user=db=query=ip=0;
lex= &main_lex;
host_or_ip= "connecting host";
locked=killed=some_tables_deleted=no_errors=password= 0;
query_start_used= 0;
@ -103,7 +104,7 @@ THD::THD():user_time(0), is_fatal_error(0),
used_tables=0;
cuted_fields= sent_row_count= current_stmt_id= 0L;
// Must be reset to handle error with THD's created for init of mysqld
lex.current_select= 0;
lex->current_select= 0;
start_time=(time_t) 0;
current_linfo = 0;
slave_thread = 0;
@ -1186,7 +1187,7 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
{
ls= gl++;
Item_func_set_user_var *xx = new Item_func_set_user_var(*ls,item);
xx->fix_fields(thd,(TABLE_LIST*) thd->lex.select_lex.table_list.first,&item);
xx->fix_fields(thd,(TABLE_LIST*) thd->lex->select_lex.table_list.first,&item);
xx->fix_length_and_dec();
vars.push_back(xx);
}

View file

@ -446,7 +446,8 @@ public:
ulong extra_length;
#endif
NET net; // client connection descriptor
LEX lex; // parse tree descriptor
LEX main_lex;
LEX *lex; // parse tree descriptor
MEM_ROOT mem_root; // 1 command-life memory pool
MEM_ROOT con_root; // connection-life memory
MEM_ROOT warn_root; // For warnings and errors

View file

@ -27,7 +27,7 @@
#include "ha_innodb.h"
#include "sql_select.h"
int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order,
ha_rows limit, ulong options)
{
int error;
@ -38,18 +38,18 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
bool transactional_table, log_delayed, safe_update, const_cond;
ha_rows deleted;
TABLE_LIST *delete_table_list= (TABLE_LIST*)
thd->lex.select_lex.table_list.first;
thd->lex->select_lex.table_list.first;
DBUG_ENTER("mysql_delete");
if ((open_and_lock_tables(thd, table_list)))
DBUG_RETURN(-1);
fix_tables_pointers(thd->lex.all_selects_list);
fix_tables_pointers(thd->lex->all_selects_list);
table= table_list->table;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
thd->proc_info="init";
table->map=1;
if (setup_conds(thd, delete_table_list, &conds) ||
setup_ftfuncs(&thd->lex.select_lex))
setup_ftfuncs(&thd->lex->select_lex))
DBUG_RETURN(-1);
if (find_real_table_in_list(table_list->next,
table_list->db, table_list->real_name))
@ -66,8 +66,8 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
DBUG_RETURN(1);
}
if (thd->lex.duplicates == DUP_IGNORE)
thd->lex.select_lex.no_error= 1;
if (thd->lex->duplicates == DUP_IGNORE)
thd->lex->select_lex.no_error= 1;
/* Test if the user wants to delete all rows */
if (!using_limit && const_cond && (!conds || conds->val_int()) &&
@ -96,7 +96,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
if ((select && select->check_quick(thd, safe_update, limit)) || !limit)
{
delete select;
free_underlaid_joins(thd, &thd->lex.select_lex);
free_underlaid_joins(thd, &thd->lex->select_lex);
send_ok(thd,0L);
DBUG_RETURN(0); // Nothing to delete
}
@ -108,7 +108,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
if (safe_update && !using_limit)
{
delete select;
free_underlaid_joins(thd, &thd->lex.select_lex);
free_underlaid_joins(thd, &thd->lex->select_lex);
send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
DBUG_RETURN(1);
}
@ -116,7 +116,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
if (options & OPTION_QUICK)
(void) table->file->extra(HA_EXTRA_QUICK);
if (order)
if (order && order->elements)
{
uint length;
SORT_FIELD *sortorder;
@ -130,17 +130,16 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
table->sort.io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE),
MYF(MY_FAE | MY_ZEROFILL));
if (thd->lex.select_lex.setup_ref_array(thd, 0) ||
setup_order(thd, thd->lex.select_lex.ref_pointer_array, &tables,
fields, all_fields, order) ||
!(sortorder=make_unireg_sortorder(order, &length)) ||
if (thd->lex->select_lex.setup_ref_array(thd, order->elements) ||
fields, all_fields, (ORDER*) order->first) ||
!(sortorder=make_unireg_sortorder((ORDER*) order->first, &length)) ||
(table->sort.found_records = filesort(thd, table, sortorder, length,
select, HA_POS_ERROR,
&examined_rows))
== HA_POS_ERROR)
{
delete select;
free_underlaid_joins(thd, &thd->lex.select_lex);
free_underlaid_joins(thd, &thd->lex->select_lex);
DBUG_RETURN(-1); // This will force out message
}
/*
@ -153,7 +152,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
init_read_record(&info,thd,table,select,1,1);
deleted=0L;
init_ftfuncs(thd, &thd->lex.select_lex, 1);
init_ftfuncs(thd, &thd->lex->select_lex, 1);
thd->proc_info="updating";
while (!(error=info.read_record(&info)) && !thd->killed &&
!thd->net.report_error)
@ -233,7 +232,7 @@ cleanup:
thd->lock=0;
}
delete select;
free_underlaid_joins(thd, &thd->lex.select_lex);
free_underlaid_joins(thd, &thd->lex->select_lex);
if (error >= 0 || thd->net.report_error)
send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN: 0);
else
@ -323,7 +322,7 @@ multi_delete::initialize_tables(JOIN *join)
table->file->ref_length,
MEM_STRIP_BUF_SIZE);
}
init_ftfuncs(thd, thd->lex.current_select, 1);
init_ftfuncs(thd, thd->lex->current_select, 1);
DBUG_RETURN(thd->is_fatal_error != 0);
}
@ -613,7 +612,7 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
{
/* Probably InnoDB table */
table_list->lock_type= TL_WRITE;
DBUG_RETURN(mysql_delete(thd, table_list, (COND*) 0, (ORDER*) 0,
DBUG_RETURN(mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
HA_POS_ERROR, 0));
}
if (lock_and_wait_for_table_name(thd, table_list))

View file

@ -185,7 +185,7 @@ my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
DBUG_RETURN(1);
MYSQL_ERROR *err;
SELECT_LEX *sel= &thd->lex.select_lex;
SELECT_LEX *sel= &thd->lex->select_lex;
ha_rows offset= sel->offset_limit, limit= sel->select_limit;
Protocol *protocol=thd->protocol;

View file

@ -131,7 +131,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
char *query=thd->query;
thr_lock_type lock_type = table_list->lock_type;
TABLE_LIST *insert_table_list= (TABLE_LIST*)
thd->lex.select_lex.table_list.first;
thd->lex->select_lex.table_list.first;
DBUG_ENTER("mysql_insert");
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@ -188,7 +188,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
res= open_and_lock_tables(thd, table_list);
if (res)
DBUG_RETURN(-1);
fix_tables_pointers(thd->lex.all_selects_list);
fix_tables_pointers(thd->lex->all_selects_list);
table= table_list->table;
thd->proc_info="init";
@ -429,14 +429,14 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
(ulong) info.deleted, (ulong) thd->cuted_fields);
::send_ok(thd,info.copied+info.deleted,(ulonglong)id,buff);
}
free_underlaid_joins(thd, &thd->lex.select_lex);
free_underlaid_joins(thd, &thd->lex->select_lex);
table->insert_values=0;
DBUG_RETURN(0);
abort:
if (lock_type == TL_WRITE_DELAYED)
end_delayed_insert(thd);
free_underlaid_joins(thd, &thd->lex.select_lex);
free_underlaid_joins(thd, &thd->lex->select_lex);
table->insert_values=0;
DBUG_RETURN(-1);
}
@ -644,7 +644,7 @@ public:
thd.current_tablenr=0;
thd.version=refresh_version;
thd.command=COM_DELAYED_INSERT;
thd.lex.current_select= 0; /* for my_message_sql */
thd.lex->current_select= 0; /* for my_message_sql */
bzero((char*) &thd.net,sizeof(thd.net)); // Safety
thd.system_thread= SYSTEM_THREAD_DELAYED_INSERT;

View file

@ -115,7 +115,7 @@ void lex_free(void)
LEX *lex_start(THD *thd, uchar *buf,uint length)
{
LEX *lex= &thd->lex;
LEX *lex= thd->lex;
lex->thd= thd;
lex->next_state=MY_LEX_START;
lex->end_of_query=(lex->ptr=buf)+length;
@ -433,7 +433,7 @@ int yylex(void *arg, void *yythd)
int tokval, result_state;
uint length;
enum my_lex_states state;
LEX *lex= &(((THD *)yythd)->lex);
LEX *lex= ((THD *)yythd)->lex;
YYSTYPE *yylval=(YYSTYPE*) arg;
CHARSET_INFO *cs= ((THD *) yythd)->charset();
uchar *state_map= cs->state_map;

View file

@ -611,4 +611,4 @@ extern pthread_key(LEX*,THR_LEX);
extern LEX_STRING tmp_table_alias;
#define current_lex (&current_thd->lex)
#define current_lex (current_thd->lex)

View file

@ -1176,7 +1176,7 @@ bool do_command(THD *thd)
indicator of uninitialized lex => normal flow of errors handling
(see my_message_sql)
*/
thd->lex.current_select= 0;
thd->lex->current_select= 0;
packet=0;
old_timeout=net->read_timeout;
@ -1383,16 +1383,16 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
DBUG_PRINT("query",("%-.4096s",thd->query));
mysql_parse(thd,thd->query, thd->query_length);
while (!thd->killed && !thd->is_fatal_error && thd->lex.found_colon)
while (!thd->killed && !thd->is_fatal_error && thd->lex->found_colon)
{
char *packet= thd->lex.found_colon;
char *packet= thd->lex->found_colon;
/*
Multiple queries exits, execute them individually
*/
if (thd->lock || thd->open_tables || thd->derived_tables)
close_thread_tables(thd);
ulong length= thd->query_length-(ulong)(thd->lex.found_colon-thd->query);
ulong length= thd->query_length-(ulong)(thd->lex->found_colon-thd->query);
/* Remove garbage at start of query */
while (my_isspace(thd->charset(), *packet) && length > 0)
@ -1736,7 +1736,7 @@ void
mysql_execute_command(THD *thd)
{
int res= 0;
LEX *lex= &thd->lex;
LEX *lex= thd->lex;
TABLE_LIST *tables= (TABLE_LIST*) lex->select_lex.table_list.first;
SELECT_LEX *select_lex= &lex->select_lex;
SELECT_LEX_UNIT *unit= &lex->unit;
@ -1865,7 +1865,7 @@ mysql_execute_command(THD *thd)
else
thd->send_explain_fields(result);
fix_tables_pointers(lex->all_selects_list);
res= mysql_explain_union(thd, &thd->lex.unit, result);
res= mysql_explain_union(thd, &thd->lex->unit, result);
MYSQL_LOCK *save_lock= thd->lock;
thd->lock= (MYSQL_LOCK *)0;
if (lex->describe & DESCRIBE_EXTENDED)
@ -1873,7 +1873,7 @@ mysql_execute_command(THD *thd)
char buff[1024];
String str(buff,(uint32) sizeof(buff), system_charset_info);
str.length(0);
thd->lex.unit.print(&str);
thd->lex->unit.print(&str);
str.append('\0');
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_YES, str.ptr());
@ -2626,7 +2626,7 @@ mysql_execute_command(THD *thd)
// Set privilege for the WHERE clause
tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege);
res = mysql_delete(thd,tables, select_lex->where,
(ORDER*) select_lex->order_list.first,
&select_lex->order_list,
select_lex->select_limit, select_lex->options);
if (thd->net.report_error)
res= -1;
@ -2634,7 +2634,7 @@ mysql_execute_command(THD *thd)
}
case SQLCOM_DELETE_MULTI:
{
TABLE_LIST *aux_tables=(TABLE_LIST *)thd->lex.auxilliary_table_list.first;
TABLE_LIST *aux_tables= (TABLE_LIST *)thd->lex->auxilliary_table_list.first;
TABLE_LIST *auxi;
uint table_count=0;
multi_delete *result;
@ -3693,7 +3693,7 @@ void
mysql_init_query(THD *thd)
{
DBUG_ENTER("mysql_init_query");
LEX *lex=&thd->lex;
LEX *lex= thd->lex;
lex->unit.init_query();
lex->unit.init_select();
lex->unit.thd= thd;
@ -3821,7 +3821,7 @@ void create_select_for_variable(const char *var_name)
DBUG_ENTER("create_select_for_variable");
thd= current_thd;
lex= &thd->lex;
lex= thd->lex;
mysql_init_select(lex);
lex->sql_command= SQLCOM_SELECT;
tmp.str= (char*) var_name;
@ -3899,7 +3899,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
uint uint_geom_type)
{
register create_field *new_field;
LEX *lex= &thd->lex;
LEX *lex= thd->lex;
uint allowed_type_modifier=0;
char warn_buff[MYSQL_ERRMSG_SIZE];
DBUG_ENTER("add_field_to_list");
@ -4233,7 +4233,7 @@ add_proc_to_list(THD* thd, Item *item)
*item_ptr= item;
order->item=item_ptr;
order->free_me=0;
thd->lex.proc_list.link_in_list((byte*) order,(byte**) &order->next);
thd->lex->proc_list.link_in_list((byte*) order,(byte**) &order->next);
return 0;
}
@ -4715,11 +4715,11 @@ static bool append_file_to_dir(THD *thd, char **filename_ptr, char *table_name)
bool check_simple_select()
{
THD *thd= current_thd;
if (thd->lex.current_select != &thd->lex.select_lex)
if (thd->lex->current_select != &thd->lex->select_lex)
{
char command[80];
strmake(command, thd->lex.yylval->symbol.str,
min(thd->lex.yylval->symbol.length, sizeof(command)-1));
strmake(command, thd->lex->yylval->symbol.str,
min(thd->lex->yylval->symbol.length, sizeof(command)-1));
net_printf(thd, ER_CANT_USE_OPTION_HERE, command);
return 1;
}

View file

@ -421,7 +421,7 @@ void setup_param_functions(Item_param *param, uchar param_type)
static bool insert_params_withlog(PREP_STMT *stmt, uchar *pos, uchar *read_pos)
{
THD *thd= stmt->thd;
List<Item> &params= thd->lex.param_list;
List<Item> &params= thd->lex->param_list;
List_iterator<Item> param_iterator(params);
Item_param *param;
DBUG_ENTER("insert_params_withlog");
@ -467,7 +467,7 @@ static bool insert_params_withlog(PREP_STMT *stmt, uchar *pos, uchar *read_pos)
static bool insert_params(PREP_STMT *stmt, uchar *pos, uchar *read_pos)
{
THD *thd= stmt->thd;
List<Item> &params= thd->lex.param_list;
List<Item> &params= thd->lex->param_list;
List_iterator<Item> param_iterator(params);
Item_param *param;
DBUG_ENTER("insert_params");
@ -493,7 +493,7 @@ static bool insert_params(PREP_STMT *stmt, uchar *pos, uchar *read_pos)
static bool setup_params_data(PREP_STMT *stmt)
{
THD *thd= stmt->thd;
List<Item> &params= thd->lex.param_list;
List<Item> &params= thd->lex->param_list;
List_iterator<Item> param_iterator(params);
Item_param *param;
DBUG_ENTER("setup_params_data");
@ -538,8 +538,8 @@ static bool mysql_test_insert_fields(PREP_STMT *stmt,
DBUG_ENTER("mysql_test_insert_fields");
#ifndef NO_EMBEDDED_ACCESS_CHECKS
my_bool update=(thd->lex.value_list.elements ? UPDATE_ACL : 0);
ulong privilege= (thd->lex.duplicates == DUP_REPLACE ?
my_bool update=(thd->lex->value_list.elements ? UPDATE_ACL : 0);
ulong privilege= (thd->lex->duplicates == DUP_REPLACE ?
INSERT_ACL | DELETE_ACL : INSERT_ACL | update);
if (check_access(thd,privilege,table_list->db,
@ -640,8 +640,8 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables,
SELECT_LEX *select_lex)
{
THD *thd= stmt->thd;
LEX *lex= &thd->lex;
select_result *result= thd->lex.result;
LEX *lex= &thd->main_lex;
select_result *result= thd->lex->result;
DBUG_ENTER("mysql_test_select_fields");
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@ -668,7 +668,7 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables,
}
else
{
fix_tables_pointers(thd->lex.all_selects_list);
fix_tables_pointers(thd->lex->all_selects_list);
if (!result && !(result= new select_send()))
{
send_error(thd, ER_OUT_OF_RESOURCES);
@ -702,8 +702,8 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables,
static bool send_prepare_results(PREP_STMT *stmt)
{
THD *thd= stmt->thd;
LEX *lex= &thd->lex;
enum enum_sql_command sql_command= thd->lex.sql_command;
LEX *lex= &thd->main_lex;
enum enum_sql_command sql_command= thd->lex->sql_command;
DBUG_ENTER("send_prepare_results");
DBUG_PRINT("enter",("command: %d, param_count: %ld",
sql_command, lex->param_count));
@ -783,7 +783,7 @@ static bool parse_prepare_query(PREP_STMT *stmt,
mysql_init_query(thd);
LEX *lex=lex_start(thd, (uchar*) packet, length);
lex->safe_to_cache_query= 0;
thd->lex.param_count= 0;
thd->lex->param_count= 0;
if (!yyparse((void *)thd) && !thd->is_fatal_error)
error= send_prepare_results(stmt);
lex_end(lex);
@ -797,11 +797,11 @@ static bool parse_prepare_query(PREP_STMT *stmt,
static bool init_param_items(PREP_STMT *stmt)
{
THD *thd= stmt->thd;
List<Item> &params= thd->lex.param_list;
List<Item> &params= thd->lex->param_list;
Item_param **to;
uint32 length= thd->query_length;
stmt->lex= thd->lex;
stmt->lex= thd->main_lex;
if (mysql_bin_log.is_open() || mysql_update_log.is_open())
{
@ -850,7 +850,7 @@ static bool init_param_items(PREP_STMT *stmt)
static void init_stmt_execute(PREP_STMT *stmt)
{
THD *thd= stmt->thd;
TABLE_LIST *tables= (TABLE_LIST*) thd->lex.select_lex.table_list.first;
TABLE_LIST *tables= (TABLE_LIST*) thd->lex->select_lex.table_list.first;
/*
TODO: When the new table structure is ready, then have a status bit
@ -908,7 +908,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
my_pthread_setprio(pthread_self(),WAIT_PRIOR);
// save WHERE clause pointers to avoid damaging they by optimisation
for (sl= thd->lex.all_selects_list;
for (sl= thd->lex->all_selects_list;
sl;
sl= sl->next_select_in_list())
{
@ -961,8 +961,8 @@ void mysql_stmt_execute(THD *thd, char *packet)
DBUG_VOID_RETURN;
}
LEX thd_lex= thd->lex;
thd->lex= stmt->lex;
LEX thd_lex= thd->main_lex;
thd->main_lex= stmt->lex;
for (sl= stmt->lex.all_selects_list;
sl;
@ -1001,7 +1001,7 @@ void mysql_stmt_execute(THD *thd, char *packet)
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(), WAIT_PRIOR);
thd->lex= thd_lex;
thd->main_lex= thd_lex;
DBUG_VOID_RETURN;
}

View file

@ -678,8 +678,8 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
was running (as we don't wan't to touch the other thread), so set the
bit to 0 for the other thread
*/
if (thd->lex.slave_thd_opt)
thread_mask &= thd->lex.slave_thd_opt;
if (thd->lex->slave_thd_opt)
thread_mask&= thd->lex->slave_thd_opt;
if (thread_mask) //some threads are stopped, start them
{
if (init_master_info(mi,master_info_file,relay_log_info_file, 0))
@ -695,22 +695,22 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
{
pthread_mutex_lock(&mi->rli.data_lock);
if (thd->lex.mi.pos)
if (thd->lex->mi.pos)
{
mi->rli.until_condition= RELAY_LOG_INFO::UNTIL_MASTER_POS;
mi->rli.until_log_pos= thd->lex.mi.pos;
mi->rli.until_log_pos= thd->lex->mi.pos;
/*
We don't check thd->lex.mi.log_file_name for NULL here
We don't check thd->lex->mi.log_file_name for NULL here
since it is checked in sql_yacc.yy
*/
strmake(mi->rli.until_log_name, thd->lex.mi.log_file_name,
strmake(mi->rli.until_log_name, thd->lex->mi.log_file_name,
sizeof(mi->rli.until_log_name)-1);
}
else if (thd->lex.mi.relay_log_pos)
else if (thd->lex->mi.relay_log_pos)
{
mi->rli.until_condition= RELAY_LOG_INFO::UNTIL_RELAY_POS;
mi->rli.until_log_pos= thd->lex.mi.relay_log_pos;
strmake(mi->rli.until_log_name, thd->lex.mi.relay_log_name,
mi->rli.until_log_pos= thd->lex->mi.relay_log_pos;
strmake(mi->rli.until_log_name, thd->lex->mi.relay_log_name,
sizeof(mi->rli.until_log_name)-1);
}
else
@ -748,7 +748,7 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
pthread_mutex_unlock(&mi->rli.data_lock);
}
else if (thd->lex.mi.pos || thd->lex.mi.relay_log_pos)
else if (thd->lex->mi.pos || thd->lex->mi.relay_log_pos)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_UNTIL_COND_IGNORED,
ER(ER_UNTIL_COND_IGNORED));
@ -802,8 +802,8 @@ int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report )
was stopped (as we don't wan't to touch the other thread), so set the
bit to 0 for the other thread
*/
if (thd->lex.slave_thd_opt)
thread_mask &= thd->lex.slave_thd_opt;
if (thd->lex->slave_thd_opt)
thread_mask &= thd->lex->slave_thd_opt;
if (thread_mask)
{
@ -975,7 +975,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
}
thd->proc_info = "Changing master";
LEX_MASTER_INFO* lex_mi = &thd->lex.mi;
LEX_MASTER_INFO* lex_mi= &thd->lex->mi;
// TODO: see if needs re-write
if (init_master_info(mi, master_info_file, relay_log_info_file, 0))
{
@ -1204,7 +1204,7 @@ int show_binlog_events(THD* thd)
if (mysql_bin_log.is_open())
{
LEX_MASTER_INFO *lex_mi = &thd->lex.mi;
LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
ha_rows event_count, limit_start, limit_end;
my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
char search_file_name[FN_REFLEN], *name;
@ -1213,8 +1213,8 @@ int show_binlog_events(THD* thd)
LOG_INFO linfo;
Log_event* ev;
limit_start = thd->lex.current_select->offset_limit;
limit_end = thd->lex.current_select->select_limit + limit_start;
limit_start= thd->lex->current_select->offset_limit;
limit_end= thd->lex->current_select->select_limit + limit_start;
name= search_file_name;
if (log_file_name)

View file

@ -501,8 +501,8 @@ JOIN::optimize()
optimized= 1;
// Ignore errors of execution if option IGNORE present
if (thd->lex.duplicates == DUP_IGNORE)
thd->lex.current_select->no_error= 1;
if (thd->lex->duplicates == DUP_IGNORE)
thd->lex->current_select->no_error= 1;
#ifdef HAVE_REF_TO_FIELDS // Not done yet
/* Add HAVING to WHERE if possible */
if (having && !group_list && !sum_func_count)
@ -1602,7 +1602,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array,
goto err; // 1
}
if (thd->lex.describe & DESCRIBE_EXTENDED)
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
join->conds_history= join->conds;
join->having_history= (join->having?join->having:join->tmp_having);
@ -1613,7 +1613,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array,
join->exec();
if (thd->lex.describe & DESCRIBE_EXTENDED)
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
select_lex->where= join->conds_history;
select_lex->having= join->having_history;
@ -2459,7 +2459,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
if (!(key_fields=(KEY_FIELD*)
thd->alloc(sizeof(key_fields[0])*
(thd->lex.current_select->cond_count+1)*2)))
(thd->lex->current_select->cond_count+1)*2)))
return TRUE; /* purecov: inspected */
and_level= 0;
field= end= key_fields;
@ -3549,7 +3549,7 @@ static void
make_join_readinfo(JOIN *join, uint options)
{
uint i;
SELECT_LEX *select_lex = &(join->thd->lex.select_lex);
SELECT_LEX *select_lex= &join->thd->lex->select_lex;
DBUG_ENTER("make_join_readinfo");
for (i=join->const_tables ; i < join->tables ; i++)
@ -5461,7 +5461,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
thd->proc_info="converting HEAP to MyISAM";
if (create_myisam_tmp_table(&new_table,param,
thd->lex.select_lex.options | thd->options))
thd->lex->select_lex.options | thd->options))
goto err2;
if (open_tmp_table(&new_table))
goto err1;
@ -8942,7 +8942,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
List<Item> field_list;
List<Item> item_list;
THD *thd=join->thd;
SELECT_LEX *select_lex = &(join->thd->lex.select_lex);
SELECT_LEX *select_lex= &join->thd->lex->select_lex;
select_result *result=join->result;
Item *item_null= new Item_null();
CHARSET_INFO *cs= &my_charset_latin1;
@ -9129,8 +9129,8 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
sl= sl->next_select())
{
res= mysql_explain_select(thd, sl,
(((&thd->lex.select_lex)==sl)?
((thd->lex.all_selects_list != sl)?"PRIMARY":
(((&thd->lex->select_lex)==sl)?
((thd->lex->all_selects_list != sl)?"PRIMARY":
"SIMPLE"):
((sl == first)?
((sl->linkage == DERIVED_TABLE_TYPE) ?
@ -9160,7 +9160,7 @@ int mysql_explain_select(THD *thd, SELECT_LEX *select_lex, char const *type,
DBUG_ENTER("mysql_explain_select");
DBUG_PRINT("info", ("Select 0x%lx, type %s", (ulong)select_lex, type))
select_lex->type= type;
thd->lex.current_select= select_lex;
thd->lex->current_select= select_lex;
SELECT_LEX_UNIT *unit= select_lex->master_unit();
int res= mysql_select(thd, &select_lex->ref_pointer_array,
(TABLE_LIST*) select_lex->table_list.first,
@ -9171,7 +9171,7 @@ int mysql_explain_select(THD *thd, SELECT_LEX *select_lex, char const *type,
(ORDER*) select_lex->order_list.first,
(ORDER*) select_lex->group_list.first,
select_lex->having,
(ORDER*) thd->lex.proc_list.first,
(ORDER*) thd->lex->proc_list.first,
select_lex->options | thd->options | SELECT_DESCRIBE,
result, unit, select_lex);
DBUG_RETURN(res);
@ -9188,8 +9188,8 @@ void st_select_lex::print(THD *thd, String *str)
//options
if (options & SELECT_STRAIGHT_JOIN)
str->append("straight_join ", 14);
if ((thd->lex.lock_option & TL_READ_HIGH_PRIORITY) &&
(this == &thd->lex.select_lex))
if ((thd->lex->lock_option & TL_READ_HIGH_PRIORITY) &&
(this == &thd->lex->select_lex))
str->append("high_priority ", 14);
if (options & SELECT_DISTINCT)
str->append("distinct ", 9);
@ -9201,7 +9201,7 @@ void st_select_lex::print(THD *thd, String *str)
str->append("buffer_result ", 14);
if (options & OPTION_FOUND_ROWS)
str->append("calc_found_rows ", 16);
if (!thd->lex.safe_to_cache_query)
if (!thd->lex->safe_to_cache_query)
str->append("no_cache ", 9);
if (options & OPTION_TO_QUERY_CACHE)
str->append("cache ", 6);

View file

@ -1246,7 +1246,7 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table,
}
else
{
char* backup_dir = thd->lex.backup_dir;
char* backup_dir= thd->lex->backup_dir;
char src_path[FN_REFLEN], dst_path[FN_REFLEN];
char* table_name = table->real_name;
char* db = thd->db ? thd->db : table->db;
@ -2696,8 +2696,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
tables.db = from->table_cache_key;
error=1;
if (thd->lex.select_lex.setup_ref_array(thd, order_num) ||
setup_order(thd, thd->lex.select_lex.ref_pointer_array,
if (thd->lex->select_lex.setup_ref_array(thd, order_num) ||
setup_order(thd, thd->lex->select_lex.ref_pointer_array,
&tables, fields, all_fields, order) ||
!(sortorder=make_unireg_sortorder(order, &length)) ||
(from->sort.found_records = filesort(thd, from, sortorder, length,

View file

@ -108,7 +108,7 @@ bool select_union::flush()
int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result)
{
SELECT_LEX *lex_select_save= thd_arg->lex.current_select;
SELECT_LEX *lex_select_save= thd_arg->lex->current_select;
SELECT_LEX *sl, *first_select;
select_result *tmp_result;
DBUG_ENTER("st_select_lex_unit::prepare");
@ -124,7 +124,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result)
prepared= 1;
res= 0;
thd_arg->lex.current_select= sl= first_select= first_select_in_union();
thd_arg->lex->current_select= sl= first_select= first_select_in_union();
found_rows_for_union= first_select->options & OPTION_FOUND_ROWS;
/* Global option */
@ -148,7 +148,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result)
JOIN *join= new JOIN(thd_arg, sl->item_list,
sl->options | thd_arg->options | SELECT_NO_UNLOCK,
tmp_result);
thd_arg->lex.current_select= sl;
thd_arg->lex->current_select= sl;
offset_limit_cnt= sl->offset_limit;
select_limit_cnt= sl->select_limit+sl->offset_limit;
if (select_limit_cnt < sl->select_limit)
@ -221,7 +221,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result)
union_result->set_table(table);
item_list.empty();
thd_arg->lex.current_select= lex_select_save;
thd_arg->lex->current_select= lex_select_save;
{
Field **field;
for (field= table->field; *field; field++)
@ -234,19 +234,19 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result)
else
first_select->braces= 0; // remove our changes
thd_arg->lex.current_select= lex_select_save;
thd_arg->lex->current_select= lex_select_save;
DBUG_RETURN(res || thd_arg->is_fatal_error ? 1 : 0);
err:
thd_arg->lex.current_select= lex_select_save;
thd_arg->lex->current_select= lex_select_save;
DBUG_RETURN(-1);
}
int st_select_lex_unit::exec()
{
SELECT_LEX *lex_select_save= thd->lex.current_select;
SELECT_LEX *lex_select_save= thd->lex->current_select;
SELECT_LEX *select_cursor=first_select_in_union();
ulonglong add_rows=0;
DBUG_ENTER("st_select_lex_unit::exec");
@ -266,7 +266,7 @@ int st_select_lex_unit::exec()
for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select())
{
ha_rows records_at_start= 0;
thd->lex.current_select= sl;
thd->lex->current_select= sl;
if (optimized)
res= sl->join->reinit();
@ -338,13 +338,13 @@ int st_select_lex_unit::exec()
offset_limit_cnt= sl->offset_limit;
if (!res && union_result->flush())
{
thd->lex.current_select= lex_select_save;
thd->lex->current_select= lex_select_save;
DBUG_RETURN(1);
}
}
if (res)
{
thd->lex.current_select= lex_select_save;
thd->lex->current_select= lex_select_save;
DBUG_RETURN(res);
}
/* Needed for the following test and for records_at_start in next loop */
@ -375,7 +375,7 @@ int st_select_lex_unit::exec()
if (!thd->is_fatal_error) // Check if EOM
{
ulong options_tmp= thd->options;
thd->lex.current_select= fake_select_lex;
thd->lex->current_select= fake_select_lex;
offset_limit_cnt= global_parameters->offset_limit;
select_limit_cnt= global_parameters->select_limit +
global_parameters->offset_limit;
@ -384,7 +384,7 @@ int st_select_lex_unit::exec()
select_limit_cnt= HA_POS_ERROR; // no limit
if (select_limit_cnt == HA_POS_ERROR)
options_tmp&= ~OPTION_FOUND_ROWS;
else if (found_rows_for_union && !thd->lex.describe)
else if (found_rows_for_union && !thd->lex->describe)
options_tmp|= OPTION_FOUND_ROWS;
fake_select_lex->ftfunc_list= &empty_list;
fake_select_lex->table_list.link_in_list((byte *)&result_table_list,
@ -430,7 +430,7 @@ int st_select_lex_unit::exec()
*/
}
}
thd->lex.current_select= lex_select_save;
thd->lex->current_select= lex_select_save;
DBUG_RETURN(res);
}

View file

@ -68,7 +68,7 @@ int mysql_update(THD *thd,
SQL_SELECT *select;
READ_RECORD info;
TABLE_LIST *update_table_list= ((TABLE_LIST*)
thd->lex.select_lex.table_list.first);
thd->lex->select_lex.table_list.first);
TABLE_LIST tables;
List<Item> all_fields;
DBUG_ENTER("mysql_update");
@ -79,7 +79,7 @@ int mysql_update(THD *thd,
if ((open_and_lock_tables(thd, table_list)))
DBUG_RETURN(-1);
thd->proc_info="init";
fix_tables_pointers(thd->lex.all_selects_list);
fix_tables_pointers(thd->lex->all_selects_list);
table= table_list->table;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
@ -97,10 +97,10 @@ int mysql_update(THD *thd,
if (setup_tables(update_table_list) ||
setup_conds(thd,update_table_list,&conds) ||
thd->lex.select_lex.setup_ref_array(thd, order_num) ||
setup_order(thd, thd->lex.select_lex.ref_pointer_array,
thd->lex->select_lex.setup_ref_array(thd, order_num) ||
setup_order(thd, thd->lex->select_lex.ref_pointer_array,
&tables, all_fields, all_fields, order) ||
setup_ftfuncs(&thd->lex.select_lex))
setup_ftfuncs(&thd->lex->select_lex))
DBUG_RETURN(-1); /* purecov: inspected */
/* Check that we are not using table that we are updating in a sub select */
@ -144,7 +144,7 @@ int mysql_update(THD *thd,
#endif
if (setup_fields(thd, 0, update_table_list, values, 0, 0, 0))
{
free_underlaid_joins(thd, &thd->lex.select_lex);
free_underlaid_joins(thd, &thd->lex->select_lex);
DBUG_RETURN(-1); /* purecov: inspected */
}
@ -155,7 +155,7 @@ int mysql_update(THD *thd,
(select && select->check_quick(thd, safe_update, limit)) || !limit)
{
delete select;
free_underlaid_joins(thd, &thd->lex.select_lex);
free_underlaid_joins(thd, &thd->lex->select_lex);
if (error)
{
DBUG_RETURN(-1); // Error in where
@ -174,7 +174,7 @@ int mysql_update(THD *thd,
goto err;
}
}
init_ftfuncs(thd, &thd->lex.select_lex, 1);
init_ftfuncs(thd, &thd->lex->select_lex, 1);
/* Check if we are modifying a key that we are used to search with */
if (select && select->quick)
used_key_is_modified= (!select->quick->unique_key_range() &&
@ -375,7 +375,7 @@ int mysql_update(THD *thd,
}
delete select;
free_underlaid_joins(thd, &thd->lex.select_lex);
free_underlaid_joins(thd, &thd->lex->select_lex);
if (error >= 0)
send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); /* purecov: inspected */
else
@ -394,7 +394,7 @@ int mysql_update(THD *thd,
err:
delete select;
free_underlaid_joins(thd, &thd->lex.select_lex);
free_underlaid_joins(thd, &thd->lex->select_lex);
if (table->key_read)
{
table->key_read=0;
@ -431,7 +431,7 @@ int mysql_multi_update(THD *thd,
#endif
if ((res=open_and_lock_tables(thd,table_list)))
DBUG_RETURN(res);
fix_tables_pointers(thd->lex.all_selects_list);
fix_tables_pointers(thd->lex->all_selects_list);
select_lex->select_limit= HA_POS_ERROR;
if (setup_fields(thd, 0, table_list, *fields, 1, 0, 0))

View file

@ -28,7 +28,7 @@
#define MYSQL_YACC
#define YYINITDEPTH 100
#define YYMAXDEPTH 3200 /* Because of 64K stack */
#define Lex (&(YYTHD->lex))
#define Lex (YYTHD->lex)
#define Select Lex->current_select
#include "mysql_priv.h"
#include "slave.h"
@ -733,14 +733,14 @@ query:
{
THD *thd= YYTHD;
if (!thd->bootstrap &&
(!(thd->lex.select_lex.options & OPTION_FOUND_COMMENT)))
(!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT)))
{
send_error(thd,ER_EMPTY_QUERY);
YYABORT;
}
else
{
thd->lex.sql_command = SQLCOM_EMPTY_QUERY;
thd->lex->sql_command= SQLCOM_EMPTY_QUERY;
}
}
| verb_clause END_OF_INPUT {};
@ -1658,7 +1658,7 @@ alter:
ALTER opt_ignore TABLE_SYM table_ident
{
THD *thd= YYTHD;
LEX *lex=&thd->lex;
LEX *lex= thd->lex;
lex->sql_command = SQLCOM_ALTER_TABLE;
lex->name=0;
if (!lex->select_lex.add_table_to_list(thd, $4, NULL,
@ -2255,7 +2255,7 @@ select_item_list:
THD *thd= YYTHD;
if (add_item_to_list(thd, new Item_field(NULL, NULL, "*")))
YYABORT;
(thd->lex.current_select->with_wild)++;
(thd->lex->current_select->with_wild)++;
};
@ -4053,8 +4053,8 @@ show_param:
| opt_var_type VARIABLES wild
{
THD *thd= YYTHD;
thd->lex.sql_command= SQLCOM_SHOW_VARIABLES;
thd->lex.option_type= (enum_var_type) $1;
thd->lex->sql_command= SQLCOM_SHOW_VARIABLES;
thd->lex->option_type= (enum_var_type) $1;
}
| charset wild
{ Lex->sql_command= SQLCOM_SHOW_CHARSETS; }
@ -4491,7 +4491,7 @@ simple_ident:
| ident '.' ident
{
THD *thd= YYTHD;
LEX *lex= &thd->lex;
LEX *lex= thd->lex;
SELECT_LEX *sel= lex->current_select;
if (sel->no_table_names_allowed)
{
@ -4507,7 +4507,7 @@ simple_ident:
| '.' ident '.' ident
{
THD *thd= YYTHD;
LEX *lex= &thd->lex;
LEX *lex= thd->lex;
SELECT_LEX *sel= lex->current_select;
if (sel->no_table_names_allowed)
{
@ -4523,7 +4523,7 @@ simple_ident:
| ident '.' ident '.' ident
{
THD *thd= YYTHD;
LEX *lex= &thd->lex;
LEX *lex= thd->lex;
SELECT_LEX *sel= lex->current_select;
if (sel->no_table_names_allowed)
{
@ -4930,7 +4930,7 @@ option_value:
YYABORT;
user->host.str=0;
user->user.str=thd->priv_user;
thd->lex.var_list.push_back(new set_var_password(user, $3));
thd->lex->var_list.push_back(new set_var_password(user, $3));
}
| PASSWORD FOR_SYM user equal text_or_password
{
@ -5478,7 +5478,7 @@ optional_order_or_limit:
|
{
THD *thd= YYTHD;
LEX *lex= &thd->lex;
LEX *lex= thd->lex;
DBUG_ASSERT(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
SELECT_LEX *sel= lex->current_select;
SELECT_LEX_UNIT *unit= sel->master_unit();
@ -5494,7 +5494,7 @@ optional_order_or_limit:
order_or_limit
{
THD *thd= YYTHD;
thd->lex.current_select->no_table_names_allowed= 0;
thd->lex->current_select->no_table_names_allowed= 0;
thd->where= "";
}
;