MCPcopy Create free account
hub / github.com/MariaDB/server / mysql_new_select

Function mysql_new_select

sql/sql_parse.cc:7551–7635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7549*/
7550
7551bool
7552mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *select_lex)
7553{
7554 THD *thd= lex->thd;
7555 bool new_select= select_lex == NULL;
7556 int old_nest_level= lex->current_select->nest_level;
7557 DBUG_ENTER("mysql_new_select");
7558
7559 if (new_select)
7560 {
7561 if (!(select_lex= new (thd->mem_root) SELECT_LEX()))
7562 DBUG_RETURN(1);
7563 select_lex->select_number= ++thd->lex->stmt_lex->current_select_number;
7564 select_lex->parent_lex= lex; /* Used in init_query. */
7565 select_lex->init_query();
7566 select_lex->init_select();
7567 }
7568 select_lex->nest_level_base= &thd->lex->unit;
7569 if (move_down)
7570 {
7571 lex->nest_level++;
7572 if (select_lex->set_nest_level(old_nest_level + 1))
7573 DBUG_RETURN(1);
7574 SELECT_LEX_UNIT *unit;
7575 /* first select_lex of subselect or derived table */
7576 if (!(unit= lex->alloc_unit()))
7577 DBUG_RETURN(1);
7578
7579 unit->include_down(lex->current_select);
7580 unit->return_to= lex->current_select;
7581 select_lex->include_down(unit);
7582 /*
7583 By default we assume that it is usual subselect and we have outer name
7584 resolution context, if no we will assign it to 0 later
7585 */
7586 select_lex->context.outer_context= &select_lex->outer_select()->context;
7587 }
7588 else
7589 {
7590 bool const outer_most= (lex->current_select->master_unit() == &lex->unit);
7591 if (outer_most && lex->result)
7592 {
7593 my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
7594 DBUG_RETURN(TRUE);
7595 }
7596
7597 /*
7598 This type of query is not possible in the grammar:
7599 SELECT 1 FROM t1 PROCEDURE ANALYSE() UNION ... ;
7600
7601 But this type of query is still possible:
7602 (SELECT 1 FROM t1 PROCEDURE ANALYSE()) UNION ... ;
7603 and it's not easy to disallow this grammatically,
7604 because there can be any parenthesis nest level:
7605 (((SELECT 1 FROM t1 PROCEDURE ANALYSE()))) UNION ... ;
7606 */
7607 if (lex->proc_list.elements!=0)
7608 {

Calls 12

my_errorFunction · 0.85
init_queryMethod · 0.80
set_nest_levelMethod · 0.80
alloc_unitMethod · 0.80
include_downMethod · 0.80
master_unitMethod · 0.80
include_neighbourMethod · 0.80
add_fake_select_lexMethod · 0.80
first_selectMethod · 0.80
include_globalMethod · 0.80
init_selectMethod · 0.45
outer_selectMethod · 0.45

Tested by

no test coverage detected