target
int64 0
1
| func
stringlengths 0
484k
| idx
int64 1
378k
|
---|---|---|
0 | 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= (first_select_lex()->next_select() == 0 &&
!(first_select_lex()->uncacheable &
UNCACHEABLE_RAND));
if (selects_allow_merge)
{
for (SELECT_LEX_UNIT *tmp_unit= first_select_lex()->first_inner_unit();
tmp_unit;
tmp_unit= tmp_unit->next_unit())
{
if (tmp_unit->first_select()->parent_lex == this &&
(tmp_unit->item != 0 &&
(tmp_unit->item->place() != IN_WHERE &&
tmp_unit->item->place() != IN_ON &&
tmp_unit->item->place() != SELECT_LIST)))
{
selects_allow_merge= 0;
break;
}
}
}
return (selects_allow_merge &&
first_select_lex()->group_list.elements == 0 &&
first_select_lex()->having == 0 &&
first_select_lex()->with_sum_func == 0 &&
first_select_lex()->table_list.elements >= 1 &&
!(first_select_lex()->options & SELECT_DISTINCT) &&
first_select_lex()->select_limit == 0);
} | 377,001 |
0 | void reset()
{
bzero(this, sizeof(*this));
ssl_type= SSL_TYPE_NOT_SPECIFIED;
} | 377,003 |
0 | size_t get_body_utf8_length()
{
return (size_t) (m_body_utf8_ptr - m_body_utf8);
} | 377,004 |
0 | const char *get_tok_end()
{
return m_tok_end;
} | 377,005 |
0 | bool LEX::call_statement_start(THD *thd, const LEX_CSTRING *name1,
const LEX_CSTRING *name2)
{
sp_name *spname= make_sp_name(thd, name1, name2);
return unlikely(!spname) || call_statement_start(thd, spname);
} | 377,006 |
0 | void set(const char *s, size_t len, bool is_8bit, char quote)
{
str= s;
length= len;
set_metadata(is_8bit, quote);
} | 377,009 |
0 | unsigned char yyGetLast()
{
return m_ptr[-1];
} | 377,011 |
0 | void LEX::stmt_deallocate_prepare(const Lex_ident_sys_st &ident)
{
sql_command= SQLCOM_DEALLOCATE_PREPARE;
prepared_stmt.set(ident, NULL, NULL);
} | 377,012 |
0 | inline int cmp_unit_op(enum sub_select_type op1, enum sub_select_type op2)
{
DBUG_ASSERT(op1 >= UNION_TYPE && op1 <= EXCEPT_TYPE);
DBUG_ASSERT(op2 >= UNION_TYPE && op2 <= EXCEPT_TYPE);
return (op1 == INTERSECT_TYPE ? 1 : 0) - (op2 == INTERSECT_TYPE ? 1 : 0);
} | 377,013 |
0 | inline void free_set_stmt_mem_root()
{
DBUG_ASSERT(!is_arena_for_set_stmt());
if (mem_root_for_set_stmt)
{
free_root(mem_root_for_set_stmt, MYF(0));
delete mem_root_for_set_stmt;
mem_root_for_set_stmt= 0;
}
} | 377,014 |
0 | bool add_to_list(THD *thd, SQL_I_List<ORDER> &list, Item *item,bool asc)
{
ORDER *order;
DBUG_ENTER("add_to_list");
if (unlikely(!(order = (ORDER *) thd->alloc(sizeof(ORDER)))))
DBUG_RETURN(1);
order->item_ptr= item;
order->item= &order->item_ptr;
order->direction= (asc ? ORDER::ORDER_ASC : ORDER::ORDER_DESC);
order->used=0;
order->counter_used= 0;
order->fast_field_copier_setup= 0;
list.link_in_list(order, &order->next);
DBUG_RETURN(0);
} | 377,016 |
0 | Item *LEX::create_item_ident_nospvar(THD *thd,
const Lex_ident_sys_st *a,
const Lex_ident_sys_st *b)
{
DBUG_ASSERT(this == thd->lex);
/*
FIXME This will work ok in simple_ident_nospvar case because
we can't meet simple_ident_nospvar in trigger now. But it
should be changed in future.
*/
if (is_trigger_new_or_old_reference(a))
{
bool new_row= (a->str[0]=='N' || a->str[0]=='n');
return create_and_link_Item_trigger_field(thd, b, new_row);
}
if (unlikely(current_select->no_table_names_allowed))
{
my_error(ER_TABLENAME_NOT_ALLOWED_HERE, MYF(0), a->str, thd->where);
return NULL;
}
if (current_select->parsing_place == FOR_LOOP_BOUND)
return create_item_for_loop_bound(thd, &null_clex_str, a, b);
return create_item_ident_field(thd, NullS, a->str, b);
} | 377,017 |
0 | static TABLE_LIST *multi_delete_table_match(LEX *lex, TABLE_LIST *tbl,
TABLE_LIST *tables)
{
TABLE_LIST *match= NULL;
DBUG_ENTER("multi_delete_table_match");
for (TABLE_LIST *elem= tables; elem; elem= elem->next_local)
{
int res;
if (tbl->is_fqtn && elem->is_alias)
continue; /* no match */
if (tbl->is_fqtn && elem->is_fqtn)
res= (my_strcasecmp(table_alias_charset, tbl->table_name.str, elem->table_name.str) ||
cmp(&tbl->db, &elem->db));
else if (elem->is_alias)
res= my_strcasecmp(table_alias_charset, tbl->alias.str, elem->alias.str);
else
res= (my_strcasecmp(table_alias_charset, tbl->table_name.str, elem->table_name.str) ||
cmp(&tbl->db, &elem->db));
if (res)
continue;
if (match)
{
my_error(ER_NONUNIQ_TABLE, MYF(0), elem->alias.str);
DBUG_RETURN(NULL);
}
match= elem;
}
if (!match)
my_error(ER_UNKNOWN_TABLE, MYF(0), tbl->table_name.str, "MULTI DELETE");
DBUG_RETURN(match);
} | 377,020 |
0 | bool st_select_lex::add_window_def(THD *thd,
LEX_CSTRING *win_name,
LEX_CSTRING *win_ref,
SQL_I_List<ORDER> win_partition_list,
SQL_I_List<ORDER> win_order_list,
Window_frame *win_frame)
{
SQL_I_List<ORDER> *win_part_list_ptr=
new (thd->mem_root) SQL_I_List<ORDER> (win_partition_list);
SQL_I_List<ORDER> *win_order_list_ptr=
new (thd->mem_root) SQL_I_List<ORDER> (win_order_list);
if (!(win_part_list_ptr && win_order_list_ptr))
return true;
Window_def *win_def= new (thd->mem_root) Window_def(win_name,
win_ref,
win_part_list_ptr,
win_order_list_ptr,
win_frame);
group_list= thd->lex->save_group_list;
order_list= thd->lex->save_order_list;
if (parsing_place != SELECT_LIST)
{
fields_in_window_functions+= win_part_list_ptr->elements +
win_order_list_ptr->elements;
}
return (win_def == NULL || window_specs.push_back(win_def));
} | 377,023 |
0 | Lex_input_stream()
{
} | 377,024 |
0 | void SELECT_LEX::update_used_tables()
{
TABLE_LIST *tl;
List_iterator<TABLE_LIST> ti(leaf_tables);
while ((tl= ti++))
{
if (tl->table && !tl->is_view_or_derived())
{
TABLE_LIST *embedding= tl->embedding;
for (embedding= tl->embedding; embedding; embedding=embedding->embedding)
{
if (embedding->is_view_or_derived())
{
DBUG_ASSERT(embedding->is_merged_derived());
TABLE *tab= tl->table;
tab->covering_keys= tab->s->keys_for_keyread;
tab->covering_keys.intersect(tab->keys_in_use_for_query);
/*
View/derived was merged. Need to recalculate read_set
bitmaps here. For example:
CREATE VIEW v1 AS SELECT f1,f2,f3 FROM t1;
SELECT f1 FROM v1;
Initially, the view definition will put all f1,f2,f3 in the
read_set for t1. But after the view is merged, only f1 should
be in the read_set.
*/
bitmap_clear_all(tab->read_set);
break;
}
}
}
}
ti.rewind();
while ((tl= ti++))
{
TABLE_LIST *embedding= tl;
do
{
bool maybe_null;
if ((maybe_null= MY_TEST(embedding->outer_join)))
{
tl->table->maybe_null= maybe_null;
break;
}
}
while ((embedding= embedding->embedding));
if (tl->on_expr)
{
tl->on_expr->update_used_tables();
tl->on_expr->walk(&Item::eval_not_null_tables, 0, NULL);
}
/*
- There is no need to check sj_on_expr, because merged semi-joins inject
sj_on_expr into the parent's WHERE clase.
- For non-merged semi-joins (aka JTBMs), we need to check their
left_expr. There is no need to check the rest of the subselect, we know
it is uncorrelated and so cannot refer to any tables in this select.
*/
if (tl->jtbm_subselect)
{
Item *left_expr= tl->jtbm_subselect->left_expr;
left_expr->walk(&Item::update_table_bitmaps_processor, FALSE, NULL);
}
embedding= tl->embedding;
while (embedding)
{
if (embedding->on_expr &&
embedding->nested_join->join_list.head() == tl)
{
embedding->on_expr->update_used_tables();
embedding->on_expr->walk(&Item::eval_not_null_tables, 0, NULL);
}
tl= embedding;
embedding= tl->embedding;
}
}
if (join->conds)
{
join->conds->update_used_tables();
join->conds->walk(&Item::eval_not_null_tables, 0, NULL);
}
if (join->having)
{
join->having->update_used_tables();
}
Item *item;
List_iterator_fast<Item> it(join->all_fields);
select_list_tables= 0;
while ((item= it++))
{
item->update_used_tables();
select_list_tables|= item->used_tables();
}
Item_outer_ref *ref;
List_iterator_fast<Item_outer_ref> ref_it(inner_refs_list);
while ((ref= ref_it++))
{
item= ref->outer_ref;
item->update_used_tables();
}
for (ORDER *order= group_list.first; order; order= order->next)
(*order->item)->update_used_tables();
if (!master_unit()->is_unit_op() ||
master_unit()->global_parameters() != this)
{
for (ORDER *order= order_list.first; order; order= order->next)
(*order->item)->update_used_tables();
}
join->result->update_used_tables();
} | 377,025 |
0 | void Lex_input_stream::body_utf8_start(THD *thd, const char *begin_ptr)
{
DBUG_ASSERT(begin_ptr);
DBUG_ASSERT(m_cpp_buf <= begin_ptr && begin_ptr <= m_cpp_buf + m_buf_length);
size_t body_utf8_length= get_body_utf8_maximum_length(thd);
m_body_utf8= (char *) thd->alloc(body_utf8_length + 1);
m_body_utf8_ptr= m_body_utf8;
*m_body_utf8_ptr= 0;
m_cpp_utf8_processed_ptr= begin_ptr;
} | 377,026 |
0 | st_select_lex::build_pushable_cond_for_having_pushdown(THD *thd, Item *cond)
{
List<Item> equalities;
/* Condition can't be pushed */
if (cond->get_extraction_flag() == NO_EXTRACTION_FL)
return false;
/**
Condition can be pushed entirely.
Transform its multiple equalities and add to attach_to_conds list.
*/
if (cond->get_extraction_flag() == FULL_EXTRACTION_FL)
{
Item *result= cond->transform(thd,
&Item::multiple_equality_transformer,
(uchar *)this);
if (!result)
return true;
if (result->type() == Item::COND_ITEM &&
((Item_cond*) result)->functype() == Item_func::COND_AND_FUNC)
{
List_iterator<Item> li(*((Item_cond*) result)->argument_list());
Item *item;
while ((item= li++))
{
if (attach_to_conds.push_back(item, thd->mem_root))
return true;
}
}
else
{
if (attach_to_conds.push_back(result, thd->mem_root))
return true;
}
return false;
}
/**
There is no flag set for this condition. It means that some
part of this condition can be pushed.
*/
if (cond->type() != Item::COND_ITEM)
return false;
if (((Item_cond *)cond)->functype() != Item_cond::COND_AND_FUNC)
{
/*
cond is not a conjunctive formula and it cannot be pushed into WHERE.
Try to extract a formula that can be pushed.
*/
Item *fix= cond->build_pushable_cond(thd, 0, 0);
if (!fix)
return false;
if (attach_to_conds.push_back(fix, thd->mem_root))
return true;
}
else
{
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
Item *item;
while ((item=li++))
{
if (item->get_extraction_flag() == NO_EXTRACTION_FL)
continue;
else if (item->get_extraction_flag() == FULL_EXTRACTION_FL)
{
Item *result= item->transform(thd,
&Item::multiple_equality_transformer,
(uchar *)item);
if (!result)
return true;
if (result->type() == Item::COND_ITEM &&
((Item_cond*) result)->functype() == Item_func::COND_AND_FUNC)
{
List_iterator<Item> li(*((Item_cond*) result)->argument_list());
Item *item;
while ((item=li++))
{
if (attach_to_conds.push_back(item, thd->mem_root))
return true;
}
}
else
{
if (attach_to_conds.push_back(result, thd->mem_root))
return true;
}
}
else
{
Item *fix= item->build_pushable_cond(thd, 0, 0);
if (!fix)
continue;
if (attach_to_conds.push_back(fix, thd->mem_root))
return true;
}
}
}
return false;
} | 377,027 |
0 | bool LEX::sp_add_agg_cfetch()
{
sphead->m_flags|= sp_head::HAS_AGGREGATE_INSTR;
sp_instr_agg_cfetch *i=
new (thd->mem_root) sp_instr_agg_cfetch(sphead->instructions(), spcont);
return i == NULL || sphead->add_instr(i);
} | 377,028 |
0 | bool LEX::check_expr_allows_fields_or_error(THD *thd, const char *name) const
{
if (select_stack_top > 0)
return false; // OK, fields are allowed
my_error(ER_BAD_FIELD_ERROR, MYF(0), name, thd->where);
return true; // Error, fields are not allowed
} | 377,029 |
0 | st_select_lex_node *st_select_lex_node:: insert_chain_before(
st_select_lex_node **ptr_pos_to_insert,
st_select_lex_node *end_chain_node)
{
end_chain_node->link_next= *ptr_pos_to_insert;
(*ptr_pos_to_insert)->link_prev= &end_chain_node->link_next;
this->link_prev= ptr_pos_to_insert;
return this;
} | 377,030 |
0 | int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
enum enum_schema_tables schema_table_idx)
{
SELECT_LEX *schema_select_lex= NULL;
DBUG_ENTER("prepare_schema_table");
switch (schema_table_idx) {
case SCH_SCHEMATA:
#if defined(DONT_ALLOW_SHOW_COMMANDS)
my_message(ER_NOT_ALLOWED_COMMAND,
ER_THD(thd, ER_NOT_ALLOWED_COMMAND), MYF(0));
DBUG_RETURN(1);
#else
break;
#endif
case SCH_TABLE_NAMES:
case SCH_TABLES:
case SCH_CHECK_CONSTRAINTS:
case SCH_VIEWS:
case SCH_TRIGGERS:
case SCH_EVENTS:
#ifdef DONT_ALLOW_SHOW_COMMANDS
my_message(ER_NOT_ALLOWED_COMMAND,
ER_THD(thd, ER_NOT_ALLOWED_COMMAND), MYF(0));
DBUG_RETURN(1);
#else
{
if (lex->first_select_lex()->db.str == NULL &&
lex->copy_db_to(&lex->first_select_lex()->db))
{
DBUG_RETURN(1);
}
schema_select_lex= new (thd->mem_root) SELECT_LEX();
schema_select_lex->table_list.first= NULL;
if (lower_case_table_names == 1)
lex->first_select_lex()->db.str=
thd->strdup(lex->first_select_lex()->db.str);
schema_select_lex->db= lex->first_select_lex()->db;
/*
check_db_name() may change db.str if lower_case_table_names == 1,
but that's ok as the db is allocted above in this case.
*/
if (check_db_name((LEX_STRING*) &lex->first_select_lex()->db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), lex->first_select_lex()->db.str);
DBUG_RETURN(1);
}
break;
}
#endif
case SCH_COLUMNS:
case SCH_STATISTICS:
#ifdef DONT_ALLOW_SHOW_COMMANDS
my_message(ER_NOT_ALLOWED_COMMAND,
ER_THD(thd, ER_NOT_ALLOWED_COMMAND), MYF(0));
DBUG_RETURN(1);
#else
{
DBUG_ASSERT(table_ident);
TABLE_LIST **query_tables_last= lex->query_tables_last;
schema_select_lex= new (thd->mem_root) SELECT_LEX();
/* 'parent_lex' is used in init_query() so it must be before it. */
schema_select_lex->parent_lex= lex;
schema_select_lex->init_query();
if (!schema_select_lex->add_table_to_list(thd, table_ident, 0, 0, TL_READ,
MDL_SHARED_READ))
DBUG_RETURN(1);
lex->query_tables_last= query_tables_last;
break;
#endif
}
case SCH_PROFILES:
/*
Mark this current profiling record to be discarded. We don't
wish to have SHOW commands show up in profiling.
*/
#if defined(ENABLED_PROFILING)
thd->profiling.discard_current_query();
#endif
break;
default:
break;
}
if (schema_select_lex)
schema_select_lex->set_master_unit(&lex->unit);
SELECT_LEX *select_lex= lex->current_select;
if (make_schema_select(thd, select_lex, get_schema_table(schema_table_idx)))
DBUG_RETURN(1);
select_lex->table_list.first->schema_select_lex= schema_select_lex;
DBUG_RETURN(0);
} | 377,031 |
0 | LEX::create_unit(SELECT_LEX *first_sel)
{
SELECT_LEX_UNIT *unit;
DBUG_ENTER("LEX::create_unit");
unit = first_sel->master_unit();
if (!unit && !(unit= alloc_unit()))
DBUG_RETURN(NULL);
unit->register_select_chain(first_sel);
if (first_sel->next_select())
{
unit->reset_distinct();
DBUG_ASSERT(!unit->fake_select_lex);
if (unit->add_fake_select_lex(thd))
DBUG_RETURN(NULL);
}
DBUG_RETURN(unit);
} | 377,033 |
0 | bool sp_for_loop_condition_test(THD *thd, const Lex_for_loop_st &loop)
{
return loop.is_for_loop_cursor() ?
sp_for_loop_cursor_condition_test(thd, loop) :
sp_for_loop_intrange_condition_test(thd, loop);
} | 377,034 |
0 | LEX::add_tail_to_query_expression_body_ext_parens(SELECT_LEX_UNIT *unit,
Lex_order_limit_lock *l)
{
SELECT_LEX *sel= unit->first_select()->next_select() ? unit->fake_select_lex :
unit->first_select();
DBUG_ASSERT(l != NULL);
pop_select();
if (sel->is_set_query_expr_tail)
{
if (!l->order_list && !sel->explicit_limit)
l->order_list= &sel->order_list;
else
{
if (!unit)
return NULL;
sel= wrap_unit_into_derived(unit);
if (!sel)
return NULL;
if (!create_unit(sel))
return NULL;
}
}
l->set_to(sel);
return sel->master_unit();
} | 377,035 |
0 | sp_variable *find_variable(const LEX_CSTRING *name,
const Sp_rcontext_handler **rh) const
{
sp_pcontext *not_used_ctx;
return find_variable(name, ¬_used_ctx, rh);
} | 377,036 |
0 | sp_head *LEX::make_sp_head(THD *thd, const sp_name *name,
const Sp_handler *sph,
enum_sp_aggregate_type agg_type)
{
sp_package *package= get_sp_package();
sp_head *sp;
/* Order is important here: new - reset - init */
if (likely((sp= sp_head::create(package, sph, agg_type))))
{
sp->reset_thd_mem_root(thd);
sp->init(this);
if (name)
{
if (package)
sp->make_package_routine_name(sp->get_main_mem_root(),
package->m_db,
package->m_name,
name->m_name);
else
sp->init_sp_name(name);
sp->make_qname(sp->get_main_mem_root(), &sp->m_qname);
}
sphead= sp;
}
sp_chistics.init();
return sp;
} | 377,037 |
0 | inline bool is_mixed_stmt_unsafe(bool in_multi_stmt_transaction_mode,
bool binlog_direct,
bool trx_cache_is_not_empty,
uint tx_isolation)
{
bool unsafe= FALSE;
if (in_multi_stmt_transaction_mode)
{
uint condition=
(binlog_direct ? BINLOG_DIRECT_ON : BINLOG_DIRECT_OFF) &
(trx_cache_is_not_empty ? TRX_CACHE_NOT_EMPTY : TRX_CACHE_EMPTY) &
(tx_isolation >= ISO_REPEATABLE_READ ? IL_GTE_REPEATABLE : IL_LT_REPEATABLE);
unsafe= (binlog_unsafe_map[stmt_accessed_table_flag] & condition);
#if !defined(DBUG_OFF)
DBUG_PRINT("LEX::is_mixed_stmt_unsafe", ("RESULT %02X %02X %02X", condition,
binlog_unsafe_map[stmt_accessed_table_flag],
(binlog_unsafe_map[stmt_accessed_table_flag] & condition)));
int type_in= 0;
for (; type_in < STMT_ACCESS_TABLE_COUNT; type_in++)
{
if (stmt_accessed_table((enum_stmt_accessed_table) type_in))
DBUG_PRINT("LEX::is_mixed_stmt_unsafe", ("ACCESSED %s ",
stmt_accessed_table_string((enum_stmt_accessed_table) type_in)));
}
#endif
}
if (stmt_accessed_table(STMT_WRITES_NON_TRANS_TABLE) &&
stmt_accessed_table(STMT_READS_TRANS_TABLE) &&
tx_isolation < ISO_REPEATABLE_READ)
unsafe= TRUE;
else if (stmt_accessed_table(STMT_WRITES_TEMP_NON_TRANS_TABLE) &&
stmt_accessed_table(STMT_READS_TRANS_TABLE) &&
tx_isolation < ISO_REPEATABLE_READ)
unsafe= TRUE;
return(unsafe);
} | 377,038 |
0 | void st_select_lex_node::init_query_common()
{
options= 0;
set_linkage(UNSPECIFIED_TYPE);
distinct= TRUE;
no_table_names_allowed= 0;
uncacheable= 0;
} | 377,039 |
0 | bool requires_prelocking()
{
return MY_TEST(query_tables_own_last);
} | 377,040 |
0 | static bool prepare_db_action(THD *thd, ulong want_access, LEX_CSTRING *dbname)
{
if (check_db_name((LEX_STRING*)dbname))
{
my_error(ER_WRONG_DB_NAME, MYF(0), dbname->str);
return true;
}
/*
If in a slave thread :
- CREATE DATABASE DB was certainly not preceded by USE DB.
- ALTER DATABASE DB may not be preceded by USE DB.
- DROP DATABASE DB may not be preceded by USE DB.
For that reason, db_ok() in sql/slave.cc did not check the
do_db/ignore_db. And as this query involves no tables, tables_ok()
was not called. So we have to check rules again here.
*/
#ifdef HAVE_REPLICATION
if (thd->slave_thread)
{
Rpl_filter *rpl_filter;
rpl_filter= thd->system_thread_info.rpl_sql_info->rpl_filter;
if (!rpl_filter->db_ok(dbname->str) ||
!rpl_filter->db_ok_with_wild_table(dbname->str))
{
my_message(ER_SLAVE_IGNORED_TABLE,
ER_THD(thd, ER_SLAVE_IGNORED_TABLE), MYF(0));
return true;
}
}
#endif
return check_access(thd, want_access, dbname->str, NULL, NULL, 1, 0);
} | 377,043 |
0 | inline uint32 get_stmt_unsafe_flags() const {
DBUG_ENTER("get_stmt_unsafe_flags");
DBUG_RETURN(binlog_stmt_flags & BINLOG_STMT_UNSAFE_ALL_FLAGS);
} | 377,045 |
0 | sp_package *LEX::create_package_start(THD *thd,
enum_sql_command command,
const Sp_handler *sph,
const sp_name *name_arg,
DDL_options_st options)
{
sp_package *pkg;
if (unlikely(sphead))
{
my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), sph->type_str());
return NULL;
}
if (unlikely(set_command_with_check(command, options)))
return NULL;
if (sph->type() == TYPE_ENUM_PACKAGE_BODY)
{
/*
If we start parsing a "CREATE PACKAGE BODY", we need to load
the corresponding "CREATE PACKAGE", for the following reasons:
1. "CREATE PACKAGE BODY" is allowed only if "CREATE PACKAGE"
was done earlier for the same package name.
So if "CREATE PACKAGE" does not exist, we throw an error here.
2. When parsing "CREATE PACKAGE BODY", we need to know all package
public and private routine names, to translate procedure and
function calls correctly.
For example, this statement inside a package routine:
CALL p;
can be translated to:
CALL db.pkg.p; -- p is a known (public or private) package routine
CALL db.p; -- p is not a known package routine
*/
sp_head *spec;
int ret= sp_handler_package_spec.
sp_cache_routine_reentrant(thd, name_arg, &spec);
if (unlikely(!spec))
{
if (!ret)
my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
"PACKAGE", ErrConvDQName(name_arg).ptr());
return 0;
}
}
if (unlikely(!(pkg= sp_package::create(this, name_arg, sph))))
return NULL;
pkg->reset_thd_mem_root(thd);
pkg->init(this);
pkg->make_qname(pkg->get_main_mem_root(), &pkg->m_qname);
sphead= pkg;
return pkg;
} | 377,046 |
0 | void st_select_lex_unit::print(String *str, enum_query_type query_type)
{
bool union_all= !union_distinct;
if (with_clause)
with_clause->print(str, query_type);
for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
{
if (sl != first_select())
{
switch (sl->linkage)
{
default:
DBUG_ASSERT(0);
/* fall through */
case UNION_TYPE:
str->append(STRING_WITH_LEN(" union "));
if (union_all)
str->append(STRING_WITH_LEN("all "));
break;
case INTERSECT_TYPE:
str->append(STRING_WITH_LEN(" intersect "));
break;
case EXCEPT_TYPE:
str->append(STRING_WITH_LEN(" except "));
break;
}
if (sl == union_distinct)
union_all= TRUE;
}
if (sl->braces)
str->append('(');
sl->print(thd, str, query_type);
if (sl->braces)
str->append(')');
}
if (fake_select_lex)
{
if (fake_select_lex->order_list.elements)
{
str->append(STRING_WITH_LEN(" order by "));
fake_select_lex->print_order(str,
fake_select_lex->order_list.first,
query_type);
}
fake_select_lex->print_limit(thd, str, query_type);
}
else if (saved_fake_select_lex)
saved_fake_select_lex->print_limit(thd, str, query_type);
} | 377,047 |
0 | bool SELECT_LEX::make_unique_derived_name(THD *thd, LEX_CSTRING *alias)
{
// uint32 digits + two underscores + trailing '\0'
char buff[MAX_INT_WIDTH + 2 + 1];
alias->length= my_snprintf(buff, sizeof(buff), "__%u", select_number);
alias->str= thd->strmake(buff, alias->length);
return !alias->str;
} | 377,048 |
0 | void LEX::first_lists_tables_same()
{
TABLE_LIST *first_table= first_select_lex()->table_list.first;
if (query_tables != first_table && first_table != 0)
{
TABLE_LIST *next;
if (query_tables_last == &first_table->next_global)
query_tables_last= first_table->prev_global;
if (query_tables_own_last == &first_table->next_global)
query_tables_own_last= first_table->prev_global;
if ((next= *first_table->prev_global= first_table->next_global))
next->prev_global= first_table->prev_global;
/* include in new place */
first_table->next_global= query_tables;
/*
We are sure that query_tables is not 0, because first_table was not
first table in the global list => we can use
query_tables->prev_global without check of query_tables
*/
query_tables->prev_global= &first_table->next_global;
first_table->prev_global= &query_tables;
query_tables= first_table;
}
} | 377,049 |
0 | bool Lex_input_stream::consume_comment(int remaining_recursions_permitted)
{
// only one level of nested comments are allowed
DBUG_ASSERT(remaining_recursions_permitted == 0 ||
remaining_recursions_permitted == 1);
uchar c;
while (!eof())
{
c= yyGet();
if (remaining_recursions_permitted == 1)
{
if ((c == '/') && (yyPeek() == '*'))
{
yyUnput('('); // Replace nested "/*..." with "(*..."
yySkip(); // and skip "("
yySkip(); /* Eat asterisk */
if (consume_comment(0))
return true;
yyUnput(')'); // Replace "...*/" with "...*)"
yySkip(); // and skip ")"
continue;
}
}
if (c == '*')
{
if (yyPeek() == '/')
{
yySkip(); // Eat slash
return FALSE;
}
}
if (c == '\n')
yylineno++;
}
return TRUE;
} | 377,050 |
0 | void Lex_select_lock::set_to(SELECT_LEX *sel)
{
if (defined_lock)
{
if (sel->master_unit() &&
sel == sel->master_unit()->fake_select_lex)
sel->master_unit()->set_lock_to_the_last_select(*this);
else
{
sel->parent_lex->safe_to_cache_query= 0;
if (update_lock)
{
sel->lock_type= TL_WRITE;
sel->set_lock_for_tables(TL_WRITE, false);
}
else
{
sel->lock_type= TL_READ_WITH_SHARED_LOCKS;
sel->set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS, false);
}
}
}
} | 377,052 |
0 | LEX::sp_block_with_exceptions_finalize_executable_section(THD *thd,
uint executable_section_ip)
{
/*
We're now at the end of "executable_section" of the block,
near the "EXCEPTION" or the "END" keyword.
Generate a jump to the END of the block over the EXCEPTION section.
*/
if (sphead->add_instr_jump_forward_with_backpatch(thd, spcont))
return true;
/*
Set the destination for the jump that we added in
sp_block_with_exceptions_finalize_declarations().
*/
sp_instr *instr= sphead->get_instr(executable_section_ip - 1);
instr->backpatch(sphead->instructions(), spcont);
return false;
} | 377,053 |
0 | bool is_part_of_union() { return master_unit()->is_unit_op(); } | 377,055 |
0 | bool LEX::sp_exit_statement(THD *thd, const LEX_CSTRING *label_name, Item *item)
{
sp_label *lab= spcont->find_label(label_name);
if (unlikely(!lab || lab->type != sp_label::ITERATION))
{
my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "EXIT", label_name->str);
return true;
}
return sp_exit_block(thd, lab, item);
} | 377,056 |
0 | Item *LEX::create_item_limit(THD *thd,
const Lex_ident_cli_st *ca,
const Lex_ident_cli_st *cb)
{
DBUG_ASSERT(thd->m_parser_state->m_lip.get_buf() <= ca->pos());
DBUG_ASSERT(ca->pos() <= cb->end());
DBUG_ASSERT(cb->end() <= thd->m_parser_state->m_lip.get_end_of_query());
const Sp_rcontext_handler *rh;
sp_variable *spv;
Lex_ident_sys sa(thd, ca), sb(thd, cb);
if (unlikely(sa.is_null() || sb.is_null()))
return NULL; // EOM
if (!(spv= find_variable(&sa, &rh)))
{
my_error(ER_SP_UNDECLARED_VAR, MYF(0), sa.str);
return NULL;
}
// Qualified %TYPE variables are not possible
DBUG_ASSERT(!spv->field_def.column_type_ref());
Item_splocal *item;
if (unlikely(!(item= create_item_spvar_row_field(thd, rh, &sa, &sb, spv,
ca->pos(), cb->end()))))
return NULL;
if (!item->is_valid_limit_clause_variable_with_error())
return NULL;
item->limit_clause_param= true;
return item;
} | 377,058 |
0 | bool parse_sql(THD *thd, Parser_state *parser_state,
Object_creation_ctx *creation_ctx, bool do_pfs_digest)
{
bool ret_value;
DBUG_ENTER("parse_sql");
DBUG_ASSERT(thd->m_parser_state == NULL);
DBUG_ASSERT(thd->lex->m_sql_cmd == NULL);
MYSQL_QUERY_PARSE_START(thd->query());
/* Backup creation context. */
Object_creation_ctx *backup_ctx= NULL;
if (creation_ctx)
backup_ctx= creation_ctx->set_n_backup(thd);
/* Set parser state. */
thd->m_parser_state= parser_state;
parser_state->m_digest_psi= NULL;
parser_state->m_lip.m_digest= NULL;
if (do_pfs_digest)
{
/* Start Digest */
parser_state->m_digest_psi= MYSQL_DIGEST_START(thd->m_statement_psi);
if (parser_state->m_digest_psi != NULL)
{
/*
If either:
- the caller wants to compute a digest
- the performance schema wants to compute a digest
set the digest listener in the lexer.
*/
parser_state->m_lip.m_digest= thd->m_digest;
parser_state->m_lip.m_digest->m_digest_storage.m_charset_number= thd->charset()->number;
}
}
/* Parse the query. */
bool mysql_parse_status=
((thd->variables.sql_mode & MODE_ORACLE) ?
ORAparse(thd) :
MYSQLparse(thd)) != 0;
DBUG_ASSERT(opt_bootstrap || mysql_parse_status ||
thd->lex->select_stack_top == 0);
thd->lex->current_select= thd->lex->first_select_lex();
/*
Check that if MYSQLparse() failed either thd->is_error() is set, or an
internal error handler is set.
The assert will not catch a situation where parsing fails without an
error reported if an error handler exists. The problem is that the
error handler might have intercepted the error, so thd->is_error() is
not set. However, there is no way to be 100% sure here (the error
handler might be for other errors than parsing one).
*/
DBUG_ASSERT(!mysql_parse_status ||
thd->is_error() ||
thd->get_internal_handler());
/* Reset parser state. */
thd->m_parser_state= NULL;
/* Restore creation context. */
if (creation_ctx)
creation_ctx->restore_env(thd, backup_ctx);
/* That's it. */
ret_value= mysql_parse_status || thd->is_fatal_error;
if ((ret_value == 0) && (parser_state->m_digest_psi != NULL))
{
/*
On parsing success, record the digest in the performance schema.
*/
DBUG_ASSERT(do_pfs_digest);
DBUG_ASSERT(thd->m_digest != NULL);
MYSQL_DIGEST_END(parser_state->m_digest_psi,
& thd->m_digest->m_digest_storage);
}
MYSQL_QUERY_PARSE_DONE(ret_value);
DBUG_RETURN(ret_value);
} | 377,059 |
0 | LEX_USER *create_definer(THD *thd, LEX_CSTRING *user_name,
LEX_CSTRING *host_name)
{
LEX_USER *definer;
/* Create and initialize. */
if (unlikely(!(definer= (LEX_USER*) thd->alloc(sizeof(LEX_USER)))))
return 0;
definer->user= *user_name;
definer->host= *host_name;
definer->auth= NULL;
return definer;
} | 377,060 |
0 | void skip_binary(int n)
{
if (m_echo)
{
memcpy(m_cpp_ptr, m_ptr, n);
m_cpp_ptr += n;
}
m_ptr += n;
} | 377,061 |
0 | int Lex_input_stream::lex_one_token(YYSTYPE *yylval, THD *thd)
{
uchar UNINIT_VAR(c);
bool comment_closed;
int tokval;
uint length;
enum my_lex_states state;
LEX *lex= thd->lex;
CHARSET_INFO *const cs= thd->charset();
const uchar *const state_map= cs->state_map;
const uchar *const ident_map= cs->ident_map;
start_token();
state= next_state;
next_state= MY_LEX_OPERATOR_OR_IDENT;
for (;;)
{
switch (state) {
case MY_LEX_OPERATOR_OR_IDENT: // Next is operator or keyword
case MY_LEX_START: // Start of token
// Skip starting whitespace
while(state_map[c= yyPeek()] == MY_LEX_SKIP)
{
if (c == '\n')
yylineno++;
yySkip();
}
/* Start of real token */
restart_token();
c= yyGet();
state= (enum my_lex_states) state_map[c];
break;
case MY_LEX_ESCAPE:
if (!eof() && yyGet() == 'N')
{ // Allow \N as shortcut for NULL
yylval->lex_str.str= (char*) "\\N";
yylval->lex_str.length= 2;
return NULL_SYM;
}
/* Fall through */
case MY_LEX_CHAR: // Unknown or single char token
if (c == '%' && (m_thd->variables.sql_mode & MODE_ORACLE))
{
next_state= MY_LEX_START;
return PERCENT_ORACLE_SYM;
}
if (c == '[' && (m_thd->variables.sql_mode & MODE_MSSQL))
return scan_ident_delimited(thd, &yylval->ident_cli, ']');
/* Fall through */
case MY_LEX_SKIP: // This should not happen
if (c != ')')
next_state= MY_LEX_START; // Allow signed numbers
yylval->kwd.set_keyword(m_tok_start, 1);
return((int) c);
case MY_LEX_MINUS_OR_COMMENT:
if (yyPeek() == '-' &&
(my_isspace(cs,yyPeekn(1)) ||
my_iscntrl(cs,yyPeekn(1))))
{
state=MY_LEX_COMMENT;
break;
}
next_state= MY_LEX_START; // Allow signed numbers
return((int) c);
case MY_LEX_PLACEHOLDER:
/*
Check for a placeholder: it should not precede a possible identifier
because of binlogging: when a placeholder is replaced with
its value in a query for the binlog, the query must stay
grammatically correct.
*/
next_state= MY_LEX_START; // Allow signed numbers
if (stmt_prepare_mode && !ident_map[(uchar) yyPeek()])
return(PARAM_MARKER);
return((int) c);
case MY_LEX_COMMA:
next_state= MY_LEX_START; // Allow signed numbers
/*
Warning:
This is a work around, to make the "remember_name" rule in
sql/sql_yacc.yy work properly.
The problem is that, when parsing "select expr1, expr2",
the code generated by bison executes the *pre* action
remember_name (see select_item) *before* actually parsing the
first token of expr2.
*/
restart_token();
return((int) c);
case MY_LEX_IDENT_OR_NCHAR:
{
uint sep;
if (yyPeek() != '\'')
{
state= MY_LEX_IDENT;
break;
}
/* Found N'string' */
yySkip(); // Skip '
if (get_text(&yylval->lex_string_with_metadata, (sep= yyGetLast()), 2, 1))
{
state= MY_LEX_CHAR; // Read char by char
break;
}
body_utf8_append(m_cpp_text_start);
body_utf8_append_escape(thd, &yylval->lex_string_with_metadata,
national_charset_info,
m_cpp_text_end, sep);
return(NCHAR_STRING);
}
case MY_LEX_IDENT_OR_HEX:
if (yyPeek() == '\'')
{ // Found x'hex-number'
state= MY_LEX_HEX_NUMBER;
break;
}
/* fall through */
case MY_LEX_IDENT_OR_BIN:
if (yyPeek() == '\'')
{ // Found b'bin-number'
state= MY_LEX_BIN_NUMBER;
break;
}
/* fall through */
case MY_LEX_IDENT:
{
tokval= scan_ident_middle(thd, &yylval->ident_cli,
&yylval->charset, &state);
if (!tokval)
continue;
if (tokval == UNDERSCORE_CHARSET)
m_underscore_cs= yylval->charset;
return tokval;
}
case MY_LEX_IDENT_SEP: // Found ident and now '.'
yylval->lex_str.str= (char*) get_ptr();
yylval->lex_str.length= 1;
c= yyGet(); // should be '.'
if (lex->parsing_options.lookup_keywords_after_qualifier)
next_state= MY_LEX_IDENT_OR_KEYWORD;
else
next_state= MY_LEX_IDENT_START; // Next is ident (not keyword)
if (!ident_map[(uchar) yyPeek()]) // Probably ` or "
next_state= MY_LEX_START;
return((int) c);
case MY_LEX_NUMBER_IDENT: // number or ident which num-start
if (yyGetLast() == '0')
{
c= yyGet();
if (c == 'x')
{
while (my_isxdigit(cs, (c = yyGet()))) ;
if ((yyLength() >= 3) && !ident_map[c])
{
/* skip '0x' */
yylval->lex_str= get_token(2, yyLength() - 2);
return (HEX_NUM);
}
yyUnget();
state= MY_LEX_IDENT_START;
break;
}
else if (c == 'b')
{
while ((c= yyGet()) == '0' || c == '1')
;
if ((yyLength() >= 3) && !ident_map[c])
{
/* Skip '0b' */
yylval->lex_str= get_token(2, yyLength() - 2);
return (BIN_NUM);
}
yyUnget();
state= MY_LEX_IDENT_START;
break;
}
yyUnget();
}
while (my_isdigit(cs, (c= yyGet()))) ;
if (!ident_map[c])
{ // Can't be identifier
state=MY_LEX_INT_OR_REAL;
break;
}
if (c == 'e' || c == 'E')
{
// The following test is written this way to allow numbers of type 1e1
if (my_isdigit(cs, yyPeek()) ||
(c=(yyGet())) == '+' || c == '-')
{ // Allow 1E+10
if (my_isdigit(cs, yyPeek())) // Number must have digit after sign
{
yySkip();
while (my_isdigit(cs, yyGet())) ;
yylval->lex_str= get_token(0, yyLength());
return(FLOAT_NUM);
}
}
/*
We've found:
- A sequence of digits
- Followed by 'e' or 'E'
- Followed by some byte XX which is not a known mantissa start,
and it's known to be a valid identifier part.
XX can be either a 8bit identifier character, or a multi-byte head.
*/
yyUnget();
return scan_ident_start(thd, &yylval->ident_cli);
}
/*
We've found:
- A sequence of digits
- Followed by some character XX, which is neither 'e' nor 'E',
and it's known to be a valid identifier part.
XX can be a 8bit identifier character, or a multi-byte head.
*/
yyUnget();
return scan_ident_start(thd, &yylval->ident_cli);
case MY_LEX_IDENT_START: // We come here after '.'
return scan_ident_start(thd, &yylval->ident_cli);
case MY_LEX_USER_VARIABLE_DELIMITER: // Found quote char
return scan_ident_delimited(thd, &yylval->ident_cli, m_tok_start[0]);
case MY_LEX_INT_OR_REAL: // Complete int or incomplete real
if (c != '.' || yyPeek() == '.')
{
/*
Found a complete integer number:
- the number is either not followed by a dot at all, or
- the number is followed by a double dot as in: FOR i IN 1..10
*/
yylval->lex_str= get_token(0, yyLength());
return int_token(yylval->lex_str.str, (uint) yylval->lex_str.length);
}
// fall through
case MY_LEX_REAL: // Incomplete real number
while (my_isdigit(cs, c= yyGet())) ;
if (c == 'e' || c == 'E')
{
c= yyGet();
if (c == '-' || c == '+')
c= yyGet(); // Skip sign
if (!my_isdigit(cs, c))
return ABORT_SYM; // No digit after sign
while (my_isdigit(cs, yyGet())) ;
yylval->lex_str= get_token(0, yyLength());
return(FLOAT_NUM);
}
yylval->lex_str= get_token(0, yyLength());
return(DECIMAL_NUM);
case MY_LEX_HEX_NUMBER: // Found x'hexstring'
yySkip(); // Accept opening '
while (my_isxdigit(cs, (c= yyGet()))) ;
if (c != '\'')
return(ABORT_SYM); // Illegal hex constant
yySkip(); // Accept closing '
length= yyLength(); // Length of hexnum+3
if ((length % 2) == 0)
return(ABORT_SYM); // odd number of hex digits
yylval->lex_str= get_token(2, // skip x'
length - 3); // don't count x' and last '
return HEX_STRING;
case MY_LEX_BIN_NUMBER: // Found b'bin-string'
yySkip(); // Accept opening '
while ((c= yyGet()) == '0' || c == '1')
;
if (c != '\'')
return(ABORT_SYM); // Illegal hex constant
yySkip(); // Accept closing '
length= yyLength(); // Length of bin-num + 3
yylval->lex_str= get_token(2, // skip b'
length - 3); // don't count b' and last '
return (BIN_NUM);
case MY_LEX_CMP_OP: // Incomplete comparison operator
next_state= MY_LEX_START; // Allow signed numbers
if (state_map[(uchar) yyPeek()] == MY_LEX_CMP_OP ||
state_map[(uchar) yyPeek()] == MY_LEX_LONG_CMP_OP)
{
yySkip();
if ((tokval= find_keyword(&yylval->kwd, 2, 0)))
return(tokval);
yyUnget();
}
return(c);
case MY_LEX_LONG_CMP_OP: // Incomplete comparison operator
next_state= MY_LEX_START;
if (state_map[(uchar) yyPeek()] == MY_LEX_CMP_OP ||
state_map[(uchar) yyPeek()] == MY_LEX_LONG_CMP_OP)
{
yySkip();
if (state_map[(uchar) yyPeek()] == MY_LEX_CMP_OP)
{
yySkip();
if ((tokval= find_keyword(&yylval->kwd, 3, 0)))
return(tokval);
yyUnget();
}
if ((tokval= find_keyword(&yylval->kwd, 2, 0)))
return(tokval);
yyUnget();
}
return(c);
case MY_LEX_BOOL:
if (c != yyPeek())
{
state= MY_LEX_CHAR;
break;
}
yySkip();
tokval= find_keyword(&yylval->kwd, 2, 0); // Is a bool operator
next_state= MY_LEX_START; // Allow signed numbers
return(tokval);
case MY_LEX_STRING_OR_DELIMITER:
if (thd->variables.sql_mode & MODE_ANSI_QUOTES)
{
state= MY_LEX_USER_VARIABLE_DELIMITER;
break;
}
/* " used for strings */
/* fall through */
case MY_LEX_STRING: // Incomplete text string
{
uint sep;
if (get_text(&yylval->lex_string_with_metadata, (sep= yyGetLast()), 1, 1))
{
state= MY_LEX_CHAR; // Read char by char
break;
}
CHARSET_INFO *strcs= m_underscore_cs ? m_underscore_cs : cs;
body_utf8_append(m_cpp_text_start);
body_utf8_append_escape(thd, &yylval->lex_string_with_metadata,
strcs, m_cpp_text_end, sep);
m_underscore_cs= NULL;
return(TEXT_STRING);
}
case MY_LEX_COMMENT: // Comment
lex->lex_options|= OPTION_LEX_FOUND_COMMENT;
while ((c= yyGet()) != '\n' && c) ;
yyUnget(); // Safety against eof
state= MY_LEX_START; // Try again
break;
case MY_LEX_LONG_COMMENT: // Long C comment?
if (yyPeek() != '*')
{
state= MY_LEX_CHAR; // Probable division
break;
}
lex->lex_options|= OPTION_LEX_FOUND_COMMENT;
/* Reject '/' '*', since we might need to turn off the echo */
yyUnget();
save_in_comment_state();
if (yyPeekn(2) == '!' ||
(yyPeekn(2) == 'M' && yyPeekn(3) == '!'))
{
bool maria_comment_syntax= yyPeekn(2) == 'M';
in_comment= DISCARD_COMMENT;
/* Accept '/' '*' '!', but do not keep this marker. */
set_echo(FALSE);
yySkipn(maria_comment_syntax ? 4 : 3);
/*
The special comment format is very strict:
'/' '*' '!', followed by an optional 'M' and exactly
1-2 digits (major), 2 digits (minor), then 2 digits (dot).
32302 -> 3.23.02
50032 -> 5.0.32
50114 -> 5.1.14
100000 -> 10.0.0
*/
if ( my_isdigit(cs, yyPeekn(0))
&& my_isdigit(cs, yyPeekn(1))
&& my_isdigit(cs, yyPeekn(2))
&& my_isdigit(cs, yyPeekn(3))
&& my_isdigit(cs, yyPeekn(4))
)
{
ulong version;
uint length= 5;
char *end_ptr= (char*) get_ptr() + length;
int error;
if (my_isdigit(cs, yyPeekn(5)))
{
end_ptr++; // 6 digit number
length++;
}
version= (ulong) my_strtoll10(get_ptr(), &end_ptr, &error);
/*
MySQL-5.7 has new features and might have new SQL syntax that
MariaDB-10.0 does not understand. Ignore all versioned comments
with MySQL versions in the range 50700-999999, but
do not ignore MariaDB specific comments for the same versions.
*/
if (version <= MYSQL_VERSION_ID &&
(version < 50700 || version > 99999 || maria_comment_syntax))
{
/* Accept 'M' 'm' 'm' 'd' 'd' */
yySkipn(length);
/* Expand the content of the special comment as real code */
set_echo(TRUE);
state=MY_LEX_START;
break; /* Do not treat contents as a comment. */
}
else
{
#ifdef WITH_WSREP
if (WSREP(thd) && version == 99997 && wsrep_thd_is_local(thd))
{
WSREP_DEBUG("consistency check: %s", thd->query());
thd->wsrep_consistency_check= CONSISTENCY_CHECK_DECLARED;
yySkipn(5);
set_echo(TRUE);
state= MY_LEX_START;
break; /* Do not treat contents as a comment. */
}
#endif /* WITH_WSREP */
/*
Patch and skip the conditional comment to avoid it
being propagated infinitely (eg. to a slave).
*/
char *pcom= yyUnput(' ');
comment_closed= ! consume_comment(1);
if (! comment_closed)
{
*pcom= '!';
}
/* version allowed to have one level of comment inside. */
}
}
else
{
/* Not a version comment. */
state=MY_LEX_START;
set_echo(TRUE);
break;
}
}
else
{
in_comment= PRESERVE_COMMENT;
yySkip(); // Accept /
yySkip(); // Accept *
comment_closed= ! consume_comment(0);
/* regular comments can have zero comments inside. */
}
/*
Discard:
- regular '/' '*' comments,
- special comments '/' '*' '!' for a future version,
by scanning until we find a closing '*' '/' marker.
Nesting regular comments isn't allowed. The first
'*' '/' returns the parser to the previous state.
/#!VERSI oned containing /# regular #/ is allowed #/
Inside one versioned comment, another versioned comment
is treated as a regular discardable comment. It gets
no special parsing.
*/
/* Unbalanced comments with a missing '*' '/' are a syntax error */
if (! comment_closed)
return (ABORT_SYM);
state = MY_LEX_START; // Try again
restore_in_comment_state();
break;
case MY_LEX_END_LONG_COMMENT:
if ((in_comment != NO_COMMENT) && yyPeek() == '/')
{
/* Reject '*' '/' */
yyUnget();
/* Accept '*' '/', with the proper echo */
set_echo(in_comment == PRESERVE_COMMENT);
yySkipn(2);
/* And start recording the tokens again */
set_echo(TRUE);
in_comment= NO_COMMENT;
state=MY_LEX_START;
}
else
state= MY_LEX_CHAR; // Return '*'
break;
case MY_LEX_SET_VAR: // Check if ':='
if (yyPeek() != '=')
{
next_state= MY_LEX_START;
if (m_thd->variables.sql_mode & MODE_ORACLE)
{
yylval->kwd.set_keyword(m_tok_start, 1);
return COLON_ORACLE_SYM;
}
return (int) ':';
}
yySkip();
return (SET_VAR);
case MY_LEX_SEMICOLON: // optional line terminator
state= MY_LEX_CHAR; // Return ';'
break;
case MY_LEX_EOL:
if (eof())
{
yyUnget(); // Reject the last '\0'
set_echo(FALSE);
yySkip();
set_echo(TRUE);
/* Unbalanced comments with a missing '*' '/' are a syntax error */
if (in_comment != NO_COMMENT)
return (ABORT_SYM);
next_state= MY_LEX_END; // Mark for next loop
return(END_OF_INPUT);
}
state=MY_LEX_CHAR;
break;
case MY_LEX_END:
next_state= MY_LEX_END;
return(0); // We found end of input last time
/* Actually real shouldn't start with . but allow them anyhow */
case MY_LEX_REAL_OR_POINT:
if (my_isdigit(cs, (c= yyPeek())))
state = MY_LEX_REAL; // Real
else if (c == '.')
{
yySkip();
return DOT_DOT_SYM;
}
else
{
state= MY_LEX_IDENT_SEP; // return '.'
yyUnget(); // Put back '.'
}
break;
case MY_LEX_USER_END: // end '@' of user@hostname
switch (state_map[(uchar) yyPeek()]) {
case MY_LEX_STRING:
case MY_LEX_USER_VARIABLE_DELIMITER:
case MY_LEX_STRING_OR_DELIMITER:
break;
case MY_LEX_USER_END:
next_state= MY_LEX_SYSTEM_VAR;
break;
default:
next_state= MY_LEX_HOSTNAME;
break;
}
yylval->lex_str.str= (char*) get_ptr();
yylval->lex_str.length= 1;
return((int) '@');
case MY_LEX_HOSTNAME: // end '@' of user@hostname
for (c= yyGet() ;
my_isalnum(cs, c) || c == '.' || c == '_' || c == '$';
c= yyGet()) ;
yylval->lex_str= get_token(0, yyLength());
return(LEX_HOSTNAME);
case MY_LEX_SYSTEM_VAR:
yylval->lex_str.str= (char*) get_ptr();
yylval->lex_str.length= 1;
yySkip(); // Skip '@'
next_state= (state_map[(uchar) yyPeek()] ==
MY_LEX_USER_VARIABLE_DELIMITER ?
MY_LEX_OPERATOR_OR_IDENT :
MY_LEX_IDENT_OR_KEYWORD);
return((int) '@');
case MY_LEX_IDENT_OR_KEYWORD:
/*
We come here when we have found two '@' in a row.
We should now be able to handle:
[(global | local | session) .]variable_name
*/
return scan_ident_sysvar(thd, &yylval->ident_cli);
}
}
} | 377,062 |
0 | bool LEX::part_values_current(THD *thd)
{
partition_element *elem= part_info->curr_part_elem;
if (!is_partition_management())
{
if (unlikely(part_info->part_type != VERSIONING_PARTITION))
{
my_error(ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME");
return true;
}
}
else
{
DBUG_ASSERT(create_last_non_select_table);
DBUG_ASSERT(create_last_non_select_table->table_name.str);
// FIXME: other ALTER commands?
my_error(ER_VERS_WRONG_PARTS, MYF(0),
create_last_non_select_table->table_name.str);
return true;
}
elem->type= partition_element::CURRENT;
DBUG_ASSERT(part_info->vers_info);
part_info->vers_info->now_part= elem;
return false;
} | 377,063 |
0 | void init() { bzero(this, sizeof(*this)); } | 377,064 |
0 | SELECT_LEX *pop_select()
{
DBUG_ENTER("LEX::pop_select");
SELECT_LEX *select_lex;
if (likely(select_stack_top))
select_lex= select_stack[--select_stack_top];
else
select_lex= 0;
DBUG_PRINT("info", ("Top Select is %p (%d) depth: %u poped: %p (%d)",
select_stack_head(),
select_stack_top,
(select_stack_top ?
select_stack_head()->select_number :
0),
select_lex,
(select_lex ? select_lex->select_number : 0)));
DBUG_ASSERT(select_lex);
pop_context();
if (unlikely(!select_stack_top))
{
current_select= &builtin_select;
DBUG_PRINT("info", ("Top Select is empty -> sel builtin: %p",
current_select));
}
else
current_select= select_stack[select_stack_top - 1];
DBUG_RETURN(select_lex);
} | 377,065 |
0 | bool stmt_create_procedure_start(const DDL_options_st &options)
{
sql_command= SQLCOM_CREATE_PROCEDURE;
return stmt_create_routine_start(options);
} | 377,066 |
0 | void yySkip()
{
if (m_echo)
*m_cpp_ptr++ = *m_ptr++;
else
m_ptr++;
} | 377,067 |
0 | bool add_create_options_with_check(DDL_options_st options)
{
create_info.add(options);
return check_create_options(create_info);
} | 377,068 |
0 | Name_resolution_context *current_context()
{
return context_stack.head();
} | 377,069 |
0 | static bool check_show_access(THD *thd, TABLE_LIST *table)
{
/*
This is a SHOW command using an INFORMATION_SCHEMA table.
check_access() has not been called for 'table',
and SELECT is currently always granted on the I_S, so we automatically
grant SELECT on table here, to bypass a call to check_access().
Note that not calling check_access(table) is an optimization,
which needs to be revisited if the INFORMATION_SCHEMA does
not always automatically grant SELECT but use the grant tables.
See Bug#38837 need a way to disable information_schema for security
*/
table->grant.privilege= SELECT_ACL;
switch (get_schema_table_idx(table->schema_table)) {
case SCH_SCHEMATA:
return (specialflag & SPECIAL_SKIP_SHOW_DB) &&
check_global_access(thd, SHOW_DB_ACL);
case SCH_TABLE_NAMES:
case SCH_TABLES:
case SCH_VIEWS:
case SCH_TRIGGERS:
case SCH_EVENTS:
{
const char *dst_db_name= table->schema_select_lex->db.str;
DBUG_ASSERT(dst_db_name);
if (check_access(thd, SELECT_ACL, dst_db_name,
&thd->col_access, NULL, FALSE, FALSE))
return TRUE;
if (!thd->col_access && check_grant_db(thd, dst_db_name))
{
status_var_increment(thd->status_var.access_denied_errors);
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
thd->security_ctx->priv_user,
thd->security_ctx->priv_host,
dst_db_name);
return TRUE;
}
return FALSE;
}
case SCH_COLUMNS:
case SCH_STATISTICS:
{
TABLE_LIST *dst_table;
dst_table= table->schema_select_lex->table_list.first;
DBUG_ASSERT(dst_table);
/*
Open temporary tables to be able to detect them during privilege check.
*/
if (thd->open_temporary_tables(dst_table))
return TRUE;
if (check_access(thd, SELECT_ACL, dst_table->db.str,
&dst_table->grant.privilege,
&dst_table->grant.m_internal,
FALSE, FALSE))
return TRUE; /* Access denied */
/*
Check_grant will grant access if there is any column privileges on
all of the tables thanks to the fourth parameter (bool show_table).
*/
if (check_grant(thd, SELECT_ACL, dst_table, TRUE, 1, FALSE))
return TRUE; /* Access denied */
close_thread_tables(thd);
dst_table->table= NULL;
/* Access granted */
return FALSE;
}
default:
break;
}
return FALSE;
} | 377,071 |
0 | bool st_select_lex::collect_fields_equal_to_grouping(THD *thd)
{
if (!join->cond_equal || join->cond_equal->is_empty())
return false;
List_iterator_fast<Item_equal> li(join->cond_equal->current_level);
Item_equal *item_equal;
while ((item_equal= li++))
{
Item_equal_fields_iterator it(*item_equal);
Item *item;
while ((item= it++))
{
if (get_corresponding_field_pair(item, grouping_tmp_fields))
break;
}
if (!item)
break;
it.rewind();
while ((item= it++))
{
if (get_corresponding_field_pair(item, grouping_tmp_fields))
continue;
Field_pair *grouping_tmp_field=
new Field_pair(((Item_field *)item->real_item())->field, item);
if (grouping_tmp_fields.push_back(grouping_tmp_field, thd->mem_root))
return true;
}
}
return false;
} | 377,072 |
0 | Item *LEX::create_item_func_setval(THD *thd, Table_ident *table_ident,
longlong nextval, ulonglong round,
bool is_used)
{
TABLE_LIST *table;
if (unlikely(!(table= current_select->add_table_to_list(thd, table_ident, 0,
TL_OPTION_SEQUENCE,
TL_WRITE_ALLOW_WRITE,
MDL_SHARED_WRITE))))
return NULL;
return new (thd->mem_root) Item_func_setval(thd, table, nextval, round,
is_used);
} | 377,073 |
0 | const st_select_lex* first_select() const
{
return reinterpret_cast<const st_select_lex*>(slave);
} | 377,074 |
0 | inline st_select_lex *global_parameters()
{
if (fake_select_lex != NULL)
return fake_select_lex;
else if (saved_fake_select_lex != NULL)
return saved_fake_select_lex;
return first_select();
}; | 377,075 |
0 | void restart_token()
{
m_tok_start= m_ptr;
m_cpp_tok_start= m_cpp_ptr;
} | 377,076 |
0 | st_select_lex* first_select()
{
return reinterpret_cast<st_select_lex*>(slave);
} | 377,078 |
0 | THD *find_thread_by_id(longlong id, bool query_id)
{
find_thread_callback_arg arg(id, query_id);
server_threads.iterate(find_thread_callback, &arg);
return arg.thd;
} | 377,079 |
0 | bool sp_block_finalize(THD *thd, const Lex_spblock_st spblock)
{
class sp_label *tmp;
return sp_block_finalize(thd, spblock, &tmp);
} | 377,080 |
0 | bool LEX::sp_push_loop_empty_label(THD *thd)
{
if (maybe_start_compound_statement(thd))
return true;
/* Unlabeled controls get an empty label. */
spcont->push_label(thd, &empty_clex_str, sphead->instructions(),
sp_label::ITERATION);
return false;
} | 377,081 |
0 | bool LEX::stmt_execute(const Lex_ident_sys_st &ident, List<Item> *params)
{
sql_command= SQLCOM_EXECUTE;
prepared_stmt.set(ident, NULL, params);
return stmt_prepare_validate("EXECUTE..USING");
} | 377,083 |
0 | With_clause *get_with_clause()
{
return master_unit()->with_clause;
} | 377,084 |
0 | bool has_lookahead() const
{
return lookahead_token >= 0;
} | 377,085 |
0 | const char *pos() const { return str - is_quoted(); } | 377,086 |
0 | bool is_single_level_stmt()
{
/*
This check exploits the fact that the last added to all_select_list is
on its top. So select_lex (as the first added) will be at the tail
of the list.
*/
if (first_select_lex() == all_selects_list && !sroutines.records)
{
return TRUE;
}
return FALSE;
} | 377,087 |
0 | Item *LEX::make_item_func_substr(THD *thd, Item *a, Item *b, Item *c)
{
return (thd->variables.sql_mode & MODE_ORACLE) ?
new (thd->mem_root) Item_func_substr_oracle(thd, a, b, c) :
new (thd->mem_root) Item_func_substr(thd, a, b, c);
} | 377,088 |
0 | int path_starts_from_data_home_dir(const char *path)
{
size_t dir_len= strlen(path);
DBUG_ENTER("path_starts_from_data_home_dir");
if (mysql_unpacked_real_data_home_len<= dir_len)
{
if (dir_len > mysql_unpacked_real_data_home_len &&
path[mysql_unpacked_real_data_home_len] != FN_LIBCHAR)
DBUG_RETURN(0);
if (lower_case_file_system)
{
if (!my_strnncoll(default_charset_info, (const uchar*) path,
mysql_unpacked_real_data_home_len,
(const uchar*) mysql_unpacked_real_data_home,
mysql_unpacked_real_data_home_len))
{
DBUG_PRINT("error", ("Path is part of mysql_real_data_home"));
DBUG_RETURN(1);
}
}
else if (!memcmp(path, mysql_unpacked_real_data_home,
mysql_unpacked_real_data_home_len))
{
DBUG_PRINT("error", ("Path is part of mysql_real_data_home"));
DBUG_RETURN(1);
}
}
DBUG_RETURN(0);
} | 377,089 |
0 | static bool do_execute_sp(THD *thd, sp_head *sp)
{
/* bits that should be cleared in thd->server_status */
uint bits_to_be_cleared= 0;
ulonglong affected_rows;
if (sp->m_flags & sp_head::MULTI_RESULTS)
{
if (!(thd->client_capabilities & CLIENT_MULTI_RESULTS))
{
/* The client does not support multiple result sets being sent back */
my_error(ER_SP_BADSELECT, MYF(0), ErrConvDQName(sp).ptr());
return 1;
}
}
/*
If SERVER_MORE_RESULTS_EXISTS is not set,
then remember that it should be cleared
*/
bits_to_be_cleared= (~thd->server_status &
SERVER_MORE_RESULTS_EXISTS);
thd->server_status|= SERVER_MORE_RESULTS_EXISTS;
ha_rows select_limit= thd->variables.select_limit;
thd->variables.select_limit= HA_POS_ERROR;
/*
Reset current_select as it may point to random data as a
result of previous parsing.
*/
thd->lex->current_select= NULL;
thd->lex->in_sum_func= 0; // For Item_field::fix_fields()
/*
We never write CALL statements into binlog:
- If the mode is non-prelocked, each statement will be logged
separately.
- If the mode is prelocked, the invoking statement will care
about writing into binlog.
So just execute the statement.
*/
int res= sp->execute_procedure(thd, &thd->lex->value_list);
thd->variables.select_limit= select_limit;
thd->server_status&= ~bits_to_be_cleared;
if (res)
{
DBUG_ASSERT(thd->is_error() || thd->killed);
return 1; // Substatement should already have sent error
}
affected_rows= thd->affected_rows; // Affected rows for all sub statements
thd->affected_rows= 0; // Reset total, as my_ok() adds to it
my_ok(thd, affected_rows);
return 0;
} | 377,091 |
0 | TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
Table_ident *table,
LEX_CSTRING *alias,
ulong table_options,
thr_lock_type lock_type,
enum_mdl_type mdl_type,
List<Index_hint> *index_hints_arg,
List<String> *partition_names,
LEX_STRING *option)
{
TABLE_LIST *ptr;
TABLE_LIST *UNINIT_VAR(previous_table_ref); /* The table preceding the current one. */
LEX_CSTRING alias_str;
LEX *lex= thd->lex;
DBUG_ENTER("add_table_to_list");
DBUG_PRINT("enter", ("Table '%s' (%p) Select %p (%u)",
(alias ? alias->str : table->table.str),
table,
this, select_number));
DBUG_ASSERT(!is_service_select || (table_options & TL_OPTION_SEQUENCE));
if (unlikely(!table))
DBUG_RETURN(0); // End of memory
alias_str= alias ? *alias : table->table;
DBUG_ASSERT(alias_str.str);
if (!MY_TEST(table_options & TL_OPTION_ALIAS) &&
unlikely(check_table_name(table->table.str, table->table.length, FALSE)))
{
my_error(ER_WRONG_TABLE_NAME, MYF(0), table->table.str);
DBUG_RETURN(0);
}
if (unlikely(table->is_derived_table() == FALSE && table->db.str &&
check_db_name((LEX_STRING*) &table->db)))
{
my_error(ER_WRONG_DB_NAME, MYF(0), table->db.str);
DBUG_RETURN(0);
}
if (!alias) /* Alias is case sensitive */
{
if (unlikely(table->sel))
{
my_message(ER_DERIVED_MUST_HAVE_ALIAS,
ER_THD(thd, ER_DERIVED_MUST_HAVE_ALIAS), MYF(0));
DBUG_RETURN(0);
}
/* alias_str points to table->table; Let's make a copy */
if (unlikely(!(alias_str.str= (char*) thd->memdup(alias_str.str, alias_str.length+1))))
DBUG_RETURN(0);
}
if (unlikely(!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST)))))
DBUG_RETURN(0); /* purecov: inspected */
if (table->db.str)
{
ptr->is_fqtn= TRUE;
ptr->db= table->db;
}
else if (!lex->with_cte_resolution && lex->copy_db_to(&ptr->db))
DBUG_RETURN(0);
else
ptr->is_fqtn= FALSE;
ptr->alias= alias_str;
ptr->is_alias= alias ? TRUE : FALSE;
if (lower_case_table_names)
{
if (table->table.length)
table->table.length= my_casedn_str(files_charset_info,
(char*) table->table.str);
if (ptr->db.length && ptr->db.str != any_db)
ptr->db.length= my_casedn_str(files_charset_info, (char*) ptr->db.str);
}
ptr->table_name= table->table;
ptr->lock_type= lock_type;
ptr->mdl_type= mdl_type;
ptr->table_options= table_options;
ptr->updating= MY_TEST(table_options & TL_OPTION_UPDATING);
/* TODO: remove TL_OPTION_FORCE_INDEX as it looks like it's not used */
ptr->force_index= MY_TEST(table_options & TL_OPTION_FORCE_INDEX);
ptr->ignore_leaves= MY_TEST(table_options & TL_OPTION_IGNORE_LEAVES);
ptr->sequence= MY_TEST(table_options & TL_OPTION_SEQUENCE);
ptr->derived= table->sel;
if (!ptr->derived && is_infoschema_db(&ptr->db))
{
if (ptr->updating &&
/* Special cases which are processed by commands itself */
lex->sql_command != SQLCOM_CHECK &&
lex->sql_command != SQLCOM_CHECKSUM)
{
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
thd->security_ctx->priv_user,
thd->security_ctx->priv_host,
INFORMATION_SCHEMA_NAME.str);
DBUG_RETURN(0);
}
ST_SCHEMA_TABLE *schema_table;
schema_table= find_schema_table(thd, &ptr->table_name);
ptr->schema_table_name= ptr->table_name;
ptr->schema_table= schema_table;
}
ptr->select_lex= this;
/*
We can't cache internal temporary tables between prepares as the
table may be deleted before next exection.
*/
ptr->cacheable_table= !table->is_derived_table();
ptr->index_hints= index_hints_arg;
ptr->option= option ? option->str : 0;
/* check that used name is unique. Sequences are ignored */
if (lock_type != TL_IGNORE && !ptr->sequence)
{
TABLE_LIST *first_table= table_list.first;
if (lex->sql_command == SQLCOM_CREATE_VIEW)
first_table= first_table ? first_table->next_local : NULL;
for (TABLE_LIST *tables= first_table ;
tables ;
tables=tables->next_local)
{
if (unlikely(!my_strcasecmp(table_alias_charset, alias_str.str,
tables->alias.str) &&
!cmp(&ptr->db, &tables->db) && ! tables->sequence))
{
my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str.str); /* purecov: tested */
DBUG_RETURN(0); /* purecov: tested */
}
}
}
/* Store the table reference preceding the current one. */
if (table_list.elements > 0 && likely(!ptr->sequence))
{
/*
table_list.next points to the last inserted TABLE_LIST->next_local'
element
We don't use the offsetof() macro here to avoid warnings from gcc
*/
previous_table_ref= (TABLE_LIST*) ((char*) table_list.next -
((char*) &(ptr->next_local) -
(char*) ptr));
/*
Set next_name_resolution_table of the previous table reference to point
to the current table reference. In effect the list
TABLE_LIST::next_name_resolution_table coincides with
TABLE_LIST::next_local. Later this may be changed in
store_top_level_join_columns() for NATURAL/USING joins.
*/
previous_table_ref->next_name_resolution_table= ptr;
}
/*
Link the current table reference in a local list (list for current select).
Notice that as a side effect here we set the next_local field of the
previous table reference to 'ptr'. Here we also add one element to the
list 'table_list'.
We don't store sequences into the local list to hide them from INSERT
and SELECT.
*/
if (likely(!ptr->sequence))
table_list.link_in_list(ptr, &ptr->next_local);
ptr->next_name_resolution_table= NULL;
#ifdef WITH_PARTITION_STORAGE_ENGINE
ptr->partition_names= partition_names;
#endif /* WITH_PARTITION_STORAGE_ENGINE */
/* Link table in global list (all used tables) */
lex->add_to_query_tables(ptr);
// Pure table aliases do not need to be locked:
if (ptr->db.str && !(table_options & TL_OPTION_ALIAS))
{
ptr->mdl_request.init(MDL_key::TABLE, ptr->db.str, ptr->table_name.str,
mdl_type,
MDL_TRANSACTION);
}
DBUG_RETURN(ptr);
} | 377,092 |
0 | SELECT_LEX *parser_current_outer_select()
{
return select_stack_top - 1 == select_stack_outer_barrier ?
0 : select_stack[select_stack_top - 1];
} | 377,093 |
0 | inline bool stmt_accessed_temp_table()
{
DBUG_ENTER("THD::stmt_accessed_temp_table");
DBUG_RETURN(stmt_accessed_non_trans_temp_table() ||
stmt_accessed_trans_temp_table());
} | 377,094 |
0 | bool LEX::maybe_start_compound_statement(THD *thd)
{
if (!sphead)
{
if (!make_sp_head(thd, NULL, &sp_handler_procedure, DEFAULT_AGGREGATE))
return true;
sphead->set_suid(SP_IS_NOT_SUID);
sphead->set_body_start(thd, thd->m_parser_state->m_lip.get_cpp_ptr());
}
return false;
} | 377,095 |
0 | void set_keyword(const char *s, size_t len)
{
set(s, len, false, '\0');
} | 377,096 |
0 | LEX::sp_variable_declarations_copy_type_finalize(THD *thd, int nvars,
const Column_definition &ref,
Row_definition_list *fields,
Item *default_value)
{
for (uint i= 0 ; i < (uint) nvars; i++)
{
sp_variable *spvar= spcont->get_last_context_variable((uint) nvars - 1 - i);
spvar->field_def.set_type(ref);
if (fields)
{
DBUG_ASSERT(ref.type_handler() == &type_handler_row);
spvar->field_def.set_row_field_definitions(fields);
}
spvar->field_def.field_name= spvar->name;
}
if (unlikely(sp_variable_declarations_set_default(thd, nvars,
default_value)))
return true;
spcont->declare_var_boundary(0);
return sphead->restore_lex(thd);
} | 377,097 |
0 | LEX::sp_variable_declarations_rowtype_finalize(THD *thd, int nvars,
Qualified_column_ident *ref,
Item *def)
{
uint coffp;
const sp_pcursor *pcursor= ref->table.str && ref->db.str ? NULL :
spcont->find_cursor(&ref->m_column, &coffp,
false);
if (pcursor)
return sp_variable_declarations_cursor_rowtype_finalize(thd, nvars,
coffp, def);
/*
When parsing a qualified identifier chain, the parser does not know yet
if it's going to be a qualified column name (for %TYPE),
or a qualified table name (for %ROWTYPE). So it collects the chain
into Qualified_column_ident.
Now we know that it was actually a qualified table name (%ROWTYPE).
Create a new Table_ident from Qualified_column_ident,
shifting fields as follows:
- ref->m_column becomes table_ref->table
- ref->table becomes table_ref->db
*/
return sp_variable_declarations_table_rowtype_finalize(thd, nvars,
ref->table,
ref->m_column,
def);
} | 377,098 |
0 | int bootstrap(MYSQL_FILE *file)
{
int bootstrap_error= 0;
DBUG_ENTER("handle_bootstrap");
THD *thd= new THD(next_thread_id());
#ifdef WITH_WSREP
thd->variables.wsrep_on= 0;
#endif
thd->bootstrap=1;
my_net_init(&thd->net,(st_vio*) 0, thd, MYF(0));
thd->max_client_packet_length= thd->net.max_packet;
thd->security_ctx->master_access= ~(ulong)0;
#ifndef EMBEDDED_LIBRARY
mysql_thread_set_psi_id(thd->thread_id);
#else
thd->mysql= 0;
#endif
/* The following must be called before DBUG_ENTER */
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->security_ctx->user= (char*) my_strdup("boot", MYF(MY_WME));
thd->security_ctx->priv_user[0]= thd->security_ctx->priv_host[0]=
thd->security_ctx->priv_role[0]= 0;
/*
Make the "client" handle multiple results. This is necessary
to enable stored procedures with SELECTs and Dynamic SQL
in init-file.
*/
thd->client_capabilities|= CLIENT_MULTI_RESULTS;
thd->init_for_queries();
for ( ; ; )
{
char buffer[MAX_BOOTSTRAP_QUERY_SIZE] = "";
int rc, length;
char *query;
int error= 0;
rc= read_bootstrap_query(buffer, &length, file, fgets_fn, &error);
if (rc == READ_BOOTSTRAP_EOF)
break;
/*
Check for bootstrap file errors. SQL syntax errors will be
caught below.
*/
if (rc != READ_BOOTSTRAP_SUCCESS)
{
/*
mysql_parse() may have set a successful error status for the previous
query. We must clear the error status to report the bootstrap error.
*/
thd->get_stmt_da()->reset_diagnostics_area();
/* Get the nearest query text for reference. */
char *err_ptr= buffer + (length <= MAX_BOOTSTRAP_ERROR_LEN ?
0 : (length - MAX_BOOTSTRAP_ERROR_LEN));
switch (rc)
{
case READ_BOOTSTRAP_ERROR:
my_printf_error(ER_UNKNOWN_ERROR, "Bootstrap file error, return code (%d). "
"Nearest query: '%s'", MYF(0), error, err_ptr);
break;
case READ_BOOTSTRAP_QUERY_SIZE:
my_printf_error(ER_UNKNOWN_ERROR, "Boostrap file error. Query size "
"exceeded %d bytes near '%s'.", MYF(0),
MAX_BOOTSTRAP_LINE_SIZE, err_ptr);
break;
default:
DBUG_ASSERT(false);
break;
}
thd->protocol->end_statement();
bootstrap_error= 1;
break;
}
query= (char *) thd->memdup_w_gap(buffer, length + 1,
thd->db.length + 1 +
QUERY_CACHE_DB_LENGTH_SIZE +
QUERY_CACHE_FLAGS_SIZE);
size_t db_len= 0;
memcpy(query + length + 1, (char *) &db_len, sizeof(size_t));
thd->set_query_and_id(query, length, thd->charset(), next_query_id());
int2store(query + length + 1, 0); // No db in bootstrap
DBUG_PRINT("query",("%-.4096s",thd->query()));
#if defined(ENABLED_PROFILING)
thd->profiling.start_new_query();
thd->profiling.set_query_source(thd->query(), length);
#endif
thd->set_time();
Parser_state parser_state;
if (parser_state.init(thd, thd->query(), length))
{
thd->protocol->end_statement();
bootstrap_error= 1;
break;
}
mysql_parse(thd, thd->query(), length, &parser_state, FALSE, FALSE);
bootstrap_error= thd->is_error();
thd->protocol->end_statement();
#if defined(ENABLED_PROFILING)
thd->profiling.finish_current_query();
#endif
delete_explain_query(thd->lex);
if (unlikely(bootstrap_error))
break;
thd->reset_kill_query(); /* Ensure that killed_errmsg is released */
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
thd->lex->restore_set_statement_var();
}
delete thd;
DBUG_RETURN(bootstrap_error);
} | 377,099 |
0 | TABLE_LIST* first_not_own_table()
{
return ( query_tables_own_last ? *query_tables_own_last : 0);
} | 377,101 |
0 | bool LEX::sp_body_finalize_routine(THD *thd)
{
if (sphead->check_unresolved_goto())
return true;
sphead->set_stmt_end(thd);
sphead->restore_thd_mem_root(thd);
return false;
} | 377,103 |
0 | const SELECT_LEX *first_select_lex() const { return unit.first_select(); } | 377,104 |
0 | void set_8bit(bool is_8bit) { m_is_8bit= is_8bit; } | 377,106 |
0 | sp_variable *LEX::sp_add_for_loop_variable(THD *thd, const LEX_CSTRING *name,
Item *value)
{
sp_variable *spvar= spcont->add_variable(thd, name);
spcont->declare_var_boundary(1);
spvar->field_def.field_name= spvar->name;
spvar->field_def.set_handler(&type_handler_longlong);
type_handler_longlong.Column_definition_prepare_stage2(&spvar->field_def,
NULL, HA_CAN_GEOMETRY);
if (!value && unlikely(!(value= new (thd->mem_root) Item_null(thd))))
return NULL;
spvar->default_value= value;
sp_instr_set *is= new (this->thd->mem_root)
sp_instr_set(sphead->instructions(),
spcont, &sp_rcontext_handler_local,
spvar->offset, value,
this, true);
if (unlikely(is == NULL || sphead->add_instr(is)))
return NULL;
spcont->declare_var_boundary(0);
return spvar;
} | 377,107 |
0 | inline bool is_prepared() { return prepared; } | 377,108 |
0 | SELECT_LEX *LEX::alloc_select(bool select)
{
SELECT_LEX *select_lex;
DBUG_ENTER("LEX::alloc_select");
if (!(select_lex= new (thd->mem_root) SELECT_LEX()))
DBUG_RETURN(NULL);
DBUG_PRINT("info", ("Allocate select: %p #%u statement lex: %p",
select_lex, thd->lex->stmt_lex->current_select_number,
thd->lex->stmt_lex));
/*
TODO: move following init to constructor when we get rid of builtin
select
*/
select_lex->select_number= ++thd->lex->stmt_lex->current_select_number;
select_lex->parent_lex= this; /* Used in init_query. */
select_lex->init_query();
if (select)
select_lex->init_select();
select_lex->nest_level_base= &this->unit;
select_lex->include_global((st_select_lex_node**)&all_selects_list);
select_lex->context.resolve_in_select_list= TRUE;
DBUG_RETURN(select_lex);
} | 377,109 |
0 | bool LEX::sp_open_cursor(THD *thd, const LEX_CSTRING *name,
List<sp_assignment_lex> *parameters)
{
uint offset;
const sp_pcursor *pcursor;
uint param_count= parameters ? parameters->elements : 0;
return !(pcursor= spcont->find_cursor_with_error(name, &offset, false)) ||
pcursor->check_param_count_with_error(param_count) ||
sphead->add_open_cursor(thd, spcont, offset,
pcursor->param_context(), parameters);
} | 377,110 |
0 | static my_bool find_thread_callback(THD *thd, find_thread_callback_arg *arg)
{
if (arg->id == (arg->query_id ? thd->query_id : (longlong) thd->thread_id))
{
mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete
arg->thd= thd;
return 1;
}
return 0;
} | 377,111 |
0 | bool SELECT_LEX_UNIT::set_lock_to_the_last_select(Lex_select_lock l)
{
if (l.defined_lock)
{
SELECT_LEX *sel= first_select();
while (sel->next_select())
sel= sel->next_select();
if (sel->braces)
{
my_error(ER_WRONG_USAGE, MYF(0), "lock options",
"SELECT in brackets");
return TRUE;
}
l.set_to(sel);
}
return FALSE;
} | 377,112 |
0 | bool eof(int n)
{
return ((m_ptr + n) >= m_end_of_query);
} | 377,113 |
0 | void set(const Lex_ident_sys_st &ident, Item *code, List<Item> *params)
{
DBUG_ASSERT(m_params.elements == 0);
m_name= ident;
m_code= code;
if (params)
m_params= *params;
} | 377,114 |
0 | enum sub_select_type get_linkage() { return linkage; } | 377,117 |
0 | bool sp_declarations_join(Lex_spblock_st *res,
const Lex_spblock_st b1,
const Lex_spblock_st b2) const
{
if ((b2.vars || b2.conds) && (b1.curs || b1.hndlrs))
{
my_error(ER_SP_VARCOND_AFTER_CURSHNDLR, MYF(0));
return true;
}
if (b2.curs && b1.hndlrs)
{
my_error(ER_SP_CURSOR_AFTER_HANDLER, MYF(0));
return true;
}
res->join(b1, b2);
return false;
} | 377,118 |
0 | sp_name *LEX::make_sp_name(THD *thd, const LEX_CSTRING *name)
{
sp_name *res;
LEX_CSTRING db;
if (unlikely(check_routine_name(name)) ||
unlikely(copy_db_to(&db)) ||
unlikely((!(res= new (thd->mem_root) sp_name(&db, name, false)))))
return NULL;
return res;
} | 377,120 |
0 | bool LEX::sp_for_loop_cursor_finalize(THD *thd, const Lex_for_loop_st &loop)
{
sp_instr_cfetch *instr=
new (thd->mem_root) sp_instr_cfetch(sphead->instructions(),
spcont, loop.m_cursor_offset, false);
if (unlikely(instr == NULL) || unlikely(sphead->add_instr(instr)))
return true;
instr->add_to_varlist(loop.m_index);
// Generate a jump to the beginning of the loop
return sp_while_loop_finalize(thd);
} | 377,123 |
0 | void cut_next() { next= NULL; } | 377,124 |
0 | bool LEX::add_alter_view(THD *thd, uint16 algorithm,
enum_view_suid suid,
Table_ident *table_ident)
{
if (unlikely(sphead))
{
my_error(ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW");
return true;
}
if (unlikely(!(create_view= new (thd->mem_root)
Create_view_info(VIEW_ALTER, algorithm, suid))))
return true;
return create_or_alter_view_finalize(thd, table_ident);
} | 377,125 |
0 | inline void set_stmt_unsafe(enum_binlog_stmt_unsafe unsafe_type) {
DBUG_ENTER("set_stmt_unsafe");
DBUG_ASSERT(unsafe_type >= 0 && unsafe_type < BINLOG_STMT_UNSAFE_COUNT);
binlog_stmt_flags|= (1U << unsafe_type);
DBUG_VOID_RETURN;
} | 377,127 |
0 | void st_select_lex_node::fast_exclude()
{
if (link_prev)
{
if ((*link_prev= link_next))
link_next->link_prev= link_prev;
}
// Remove slave structure
for (; slave; slave= slave->next)
slave->fast_exclude();
} | 377,128 |
0 | Item *LEX::create_item_ident_field(THD *thd, const char *db,
const char *table,
const Lex_ident_sys_st *name)
{
if (check_expr_allows_fields_or_error(thd, name->str))
return NULL;
if (current_select->parsing_place != IN_HAVING ||
current_select->get_in_sum_expr() > 0)
return new (thd->mem_root) Item_field(thd, current_context(),
db, table, name);
return new (thd->mem_root) Item_ref(thd, current_context(),
db, table, name);
} | 377,129 |
Subsets and Splits