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.cc57
1 files changed, 31 insertions, 26 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index e5b8090dfbc..26cef090b83 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -299,7 +299,7 @@ Lex_input_stream::reset(char *buffer, unsigned int length)
m_cpp_utf8_processed_ptr= NULL;
next_state= MY_LEX_START;
found_semicolon= NULL;
- ignore_space= test(m_thd->variables.sql_mode & MODE_IGNORE_SPACE);
+ ignore_space= MY_TEST(m_thd->variables.sql_mode & MODE_IGNORE_SPACE);
stmt_prepare_mode= FALSE;
multi_statements= TRUE;
in_comment=NO_COMMENT;
@@ -497,13 +497,13 @@ void lex_start(THD *thd)
lex->select_lex.ftfunc_list= &lex->select_lex.ftfunc_list_alloc;
lex->select_lex.group_list.empty();
lex->select_lex.order_list.empty();
+ lex->select_lex.gorder_list.empty();
lex->m_sql_cmd= NULL;
lex->duplicates= DUP_ERROR;
lex->ignore= 0;
lex->spname= NULL;
lex->sphead= NULL;
lex->spcont= NULL;
- lex->m_sql_cmd= NULL;
lex->proc_list.first= 0;
lex->escape_used= FALSE;
lex->query_tables= 0;
@@ -2120,14 +2120,15 @@ void st_select_lex_unit::exclude_tree()
this to 'last' as dependent
SYNOPSIS
- last - pointer to last st_select_lex struct, before wich all
+ last - pointer to last st_select_lex struct, before which all
st_select_lex have to be marked as dependent
NOTE
'last' should be reachable from this st_select_lex_node
*/
-bool st_select_lex::mark_as_dependent(THD *thd, st_select_lex *last, Item *dependency)
+bool st_select_lex::mark_as_dependent(THD *thd, st_select_lex *last,
+ Item *dependency)
{
DBUG_ASSERT(this != last);
@@ -2320,7 +2321,10 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
If we need a bigger array, we must allocate a new one.
*/
if (ref_pointer_array_size >= n_elems)
+ {
+ DBUG_PRINT("info", ("reusing old ref_array"));
return false;
+ }
}
ref_pointer_array= static_cast<Item**>(arena->alloc(sizeof(Item*) * n_elems));
if (ref_pointer_array != NULL)
@@ -2586,7 +2590,9 @@ bool LEX::can_be_merged()
// TODO: do not forget implement case when select_lex.table_list.elements==0
/* find non VIEW subqueries/unions */
- bool selects_allow_merge= select_lex.next_select() == 0;
+ bool selects_allow_merge= (select_lex.next_select() == 0 &&
+ !(select_lex.uncacheable &
+ UNCACHEABLE_RAND));
if (selects_allow_merge)
{
for (SELECT_LEX_UNIT *tmp_unit= select_lex.first_inner_unit();
@@ -3078,7 +3084,7 @@ TABLE_LIST *LEX::unlink_first_table(bool *link_to_local)
/*
and from local list if it is not empty
*/
- if ((*link_to_local= test(select_lex.table_list.first)))
+ if ((*link_to_local= MY_TEST(select_lex.table_list.first)))
{
select_lex.context.table_list=
select_lex.context.first_name_resolution_table= first->next_local;
@@ -3323,6 +3329,7 @@ static void fix_prepare_info_in_table_list(THD *thd, TABLE_LIST *tbl)
void st_select_lex::fix_prepare_information(THD *thd, Item **conds,
Item **having_conds)
{
+ DBUG_ENTER("st_select_lex::fix_prepare_information");
if (!thd->stmt_arena->is_conventional() && first_execution)
{
first_execution= 0;
@@ -3351,6 +3358,7 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds,
}
fix_prepare_info_in_table_list(thd, table_list.first);
}
+ DBUG_VOID_RETURN;
}
@@ -3827,7 +3835,7 @@ void SELECT_LEX::update_used_tables()
do
{
bool maybe_null;
- if ((maybe_null= test(embedding->outer_join)))
+ if ((maybe_null= MY_TEST(embedding->outer_join)))
{
tl->table->maybe_null= maybe_null;
break;
@@ -3904,37 +3912,40 @@ void st_select_lex::update_correlated_cache()
while ((tl= ti++))
{
if (tl->on_expr)
- is_correlated|= test(tl->on_expr->used_tables() & OUTER_REF_TABLE_BIT);
+ is_correlated|= MY_TEST(tl->on_expr->used_tables() & OUTER_REF_TABLE_BIT);
for (TABLE_LIST *embedding= tl->embedding ; embedding ;
embedding= embedding->embedding)
{
if (embedding->on_expr)
- is_correlated|= test(embedding->on_expr->used_tables() &
- OUTER_REF_TABLE_BIT);
+ is_correlated|= MY_TEST(embedding->on_expr->used_tables() &
+ OUTER_REF_TABLE_BIT);
}
}
if (join->conds)
- is_correlated|= test(join->conds->used_tables() & OUTER_REF_TABLE_BIT);
+ is_correlated|= MY_TEST(join->conds->used_tables() & OUTER_REF_TABLE_BIT);
if (join->having)
- is_correlated|= test(join->having->used_tables() & OUTER_REF_TABLE_BIT);
+ is_correlated|= MY_TEST(join->having->used_tables() & OUTER_REF_TABLE_BIT);
if (join->tmp_having)
- is_correlated|= test(join->tmp_having->used_tables() & OUTER_REF_TABLE_BIT);
+ is_correlated|= MY_TEST(join->tmp_having->used_tables() &
+ OUTER_REF_TABLE_BIT);
Item *item;
List_iterator_fast<Item> it(join->fields_list);
while ((item= it++))
- is_correlated|= test(item->used_tables() & OUTER_REF_TABLE_BIT);
+ is_correlated|= MY_TEST(item->used_tables() & OUTER_REF_TABLE_BIT);
for (ORDER *order= group_list.first; order; order= order->next)
- is_correlated|= test((*order->item)->used_tables() & OUTER_REF_TABLE_BIT);
+ is_correlated|= MY_TEST((*order->item)->used_tables() &
+ OUTER_REF_TABLE_BIT);
if (!master_unit()->is_union())
{
for (ORDER *order= order_list.first; order; order= order->next)
- is_correlated|= test((*order->item)->used_tables() & OUTER_REF_TABLE_BIT);
+ is_correlated|= MY_TEST((*order->item)->used_tables() &
+ OUTER_REF_TABLE_BIT);
}
if (!is_correlated)
@@ -4088,11 +4099,8 @@ void SELECT_LEX::mark_const_derived(bool empty)
bool st_select_lex::save_leaf_tables(THD *thd)
{
- Query_arena *arena= thd->stmt_arena, backup;
- if (arena->is_conventional())
- arena= 0;
- else
- thd->set_n_backup_active_arena(arena, &backup);
+ Query_arena *arena, backup;
+ arena= thd->activate_stmt_arena_if_needed(&backup);
List_iterator_fast<TABLE_LIST> li(leaf_tables);
TABLE_LIST *table;
@@ -4120,10 +4128,7 @@ bool st_select_lex::save_prep_leaf_tables(THD *thd)
return 0;
Query_arena *arena= thd->stmt_arena, backup;
- if (arena->is_conventional())
- arena= 0;
- else
- thd->set_n_backup_active_arena(arena, &backup);
+ arena= thd->activate_stmt_arena_if_needed(&backup);
List_iterator_fast<TABLE_LIST> li(leaf_tables);
TABLE_LIST *table;
@@ -4229,7 +4234,7 @@ int st_select_lex_unit::save_union_explain(Explain_query *output)
eu->add_select(sl->select_number);
eu->fake_select_type= "UNION RESULT";
- eu->using_filesort= test(global_parameters->order_list.first);
+ eu->using_filesort= MY_TEST(global_parameters->order_list.first);
// Save the UNION node
output->add_node(eu);