summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc44
1 files changed, 31 insertions, 13 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 9d34f299a07..1dc0a6358c7 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -22,6 +22,7 @@
#include "mysql_priv.h"
#include <m_ctype.h>
#include "my_dir.h"
+#include "sp_rcontext.h"
static void mark_as_dependent(THD *thd,
SELECT_LEX *last, SELECT_LEX *current,
@@ -54,13 +55,13 @@ Item::Item():
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++;
}
}
@@ -205,6 +206,23 @@ CHARSET_INFO * Item::default_charset() const
return current_thd->variables.collation_connection;
}
+
+Item *
+Item_splocal::this_item()
+{
+ THD *thd= current_thd;
+
+ return thd->spcont->get_item(m_offset);
+}
+
+Item *
+Item_splocal::this_const_item() const
+{
+ THD *thd= current_thd;
+
+ return thd->spcont->get_item(m_offset);
+}
+
bool DTCollation::aggregate(DTCollation &dt)
{
if (!my_charset_same(collation, dt.collation))
@@ -815,7 +833,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)
for (SELECT_LEX *sl= cursel->outer_select();
sl;
@@ -1350,17 +1368,17 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
if (!ref)
{
TABLE_LIST *where= 0, *table_list;
- SELECT_LEX *sl= thd->lex.current_select->outer_select();
+ SELECT_LEX *sl= thd->lex->current_select->outer_select();
/*
Finding only in current select will be performed for selects that have
not outer one and for derived tables (which not support using outer
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 :
@@ -1410,7 +1428,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);
ref= 0;
@@ -1422,7 +1440,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
@@ -1433,7 +1451,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;
}
@@ -1448,7 +1466,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;
}
}
@@ -1461,8 +1479,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,