summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc67
1 files changed, 29 insertions, 38 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index e380c94b58a..33121e5301d 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -110,39 +110,31 @@ st_parsing_options::reset()
allows_derived= TRUE;
}
-Lex_input_stream::Lex_input_stream(THD *thd,
- const char* buffer,
- unsigned int length)
-: m_thd(thd),
- yylineno(1),
- yytoklen(0),
- yylval(NULL),
- m_ptr(buffer),
- m_tok_start(NULL),
- m_tok_end(NULL),
- m_end_of_query(buffer + length),
- m_tok_start_prev(NULL),
- m_buf(buffer),
- m_buf_length(length),
- m_echo(TRUE),
- m_cpp_tok_start(NULL),
- m_cpp_tok_start_prev(NULL),
- m_cpp_tok_end(NULL),
- m_body_utf8(NULL),
- m_cpp_utf8_processed_ptr(NULL),
- next_state(MY_LEX_START),
- found_semicolon(NULL),
- ignore_space(test(thd->variables.sql_mode & MODE_IGNORE_SPACE)),
- stmt_prepare_mode(FALSE),
- in_comment(NO_COMMENT),
- m_underscore_cs(NULL)
+
+bool Lex_input_stream::init(THD *thd, const char *buff, unsigned int length)
{
+ DBUG_EXECUTE_IF("bug42064_simulate_oom",
+ DBUG_SET("+d,simulate_out_of_memory"););
+
m_cpp_buf= (char*) thd->alloc(length + 1);
+
+ DBUG_EXECUTE_IF("bug42064_simulate_oom",
+ DBUG_SET("-d,bug42064_simulate_oom"););
+
+ if (m_cpp_buf == NULL)
+ return TRUE;
+
m_cpp_ptr= m_cpp_buf;
+ m_thd= thd;
+ m_ptr= buff;
+ m_end_of_query= buff + length;
+ m_buf= buff;
+ m_buf_length= length;
+ ignore_space= test(thd->variables.sql_mode & MODE_IGNORE_SPACE);
+
+ return FALSE;
}
-Lex_input_stream::~Lex_input_stream()
-{}
/**
The operation is called from the parser in order to
@@ -1653,7 +1645,7 @@ void st_select_lex::init_select()
linkage= UNSPECIFIED_TYPE;
order_list.elements= 0;
order_list.first= 0;
- order_list.next= (uchar**) &order_list.first;
+ order_list.next= &order_list.first;
/* Set limit and offset to default values */
select_limit= 0; /* denotes the default limit = HA_POS_ERROR */
offset_limit= 0; /* denotes the default offset = 0 */
@@ -1984,7 +1976,7 @@ uint st_select_lex::get_in_sum_expr()
TABLE_LIST* st_select_lex::get_table_list()
{
- return (TABLE_LIST*) table_list.first;
+ return table_list.first;
}
List<Item>* st_select_lex::get_item_list()
@@ -2041,9 +2033,8 @@ void st_select_lex_unit::print(String *str, enum_query_type query_type)
if (fake_select_lex->order_list.elements)
{
str->append(STRING_WITH_LEN(" order by "));
- fake_select_lex->print_order(
- str,
- (ORDER *) fake_select_lex->order_list.first,
+ fake_select_lex->print_order(str,
+ fake_select_lex->order_list.first,
query_type);
}
fake_select_lex->print_limit(thd, str, query_type);
@@ -2688,7 +2679,7 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local)
{
select_lex.context.table_list=
select_lex.context.first_name_resolution_table= first->next_local;
- select_lex.table_list.first= (uchar*) (first->next_local);
+ select_lex.table_list.first= first->next_local;
select_lex.table_list.elements--; //safety
first->next_local= 0;
/*
@@ -2720,7 +2711,7 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local)
void st_lex::first_lists_tables_same()
{
- TABLE_LIST *first_table= (TABLE_LIST*) select_lex.table_list.first;
+ TABLE_LIST *first_table= select_lex.table_list.first;
if (query_tables != first_table && first_table != 0)
{
TABLE_LIST *next;
@@ -2767,9 +2758,9 @@ void st_lex::link_first_table_back(TABLE_LIST *first,
if (link_to_local)
{
- first->next_local= (TABLE_LIST*) select_lex.table_list.first;
+ first->next_local= select_lex.table_list.first;
select_lex.context.table_list= first;
- select_lex.table_list.first= (uchar*) first;
+ select_lex.table_list.first= first;
select_lex.table_list.elements++; //safety
}
}
@@ -2935,7 +2926,7 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds,
prep_having= *having_conds;
*having_conds= having= prep_having->copy_andor_structure(thd);
}
- fix_prepare_info_in_table_list(thd, (TABLE_LIST *)table_list.first);
+ fix_prepare_info_in_table_list(thd, table_list.first);
}
}