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

Method wrap_select_chain_into_derived

sql/sql_lex.cc:6649–6723  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6647}
6648
6649SELECT_LEX *LEX::wrap_select_chain_into_derived(SELECT_LEX *sel)
6650{
6651 SELECT_LEX *dummy_select;
6652 SELECT_LEX_UNIT *unit;
6653 Table_ident *ti;
6654 Item *sel_item;
6655 DBUG_ENTER("LEX::wrap_select_chain_into_derived");
6656
6657 if (!(dummy_select= alloc_select(TRUE)))
6658 DBUG_RETURN(NULL);
6659 Name_resolution_context *context= &dummy_select->context;
6660 dummy_select->automatic_brackets= FALSE;
6661 sel->distinct= TRUE; // First select has not this attribute (safety)
6662
6663 if (!(unit= dummy_select->attach_selects_chain(sel, context)))
6664 DBUG_RETURN(NULL);
6665
6666 /* stuff dummy SELECT * FROM (...) */
6667
6668 if (push_select(dummy_select)) // for Items & TABLE_LIST
6669 DBUG_RETURN(NULL);
6670
6671 /* add SELECT list*/
6672 if (sel->item_list.elements)
6673 {
6674 List_iterator<Item> li(sel->item_list);
6675 while ((sel_item= li++))
6676 {
6677 Item *item= new (thd->mem_root) Item_field(thd, context, sel_item->name);
6678 if (item == NULL ||
6679 add_item_to_list(thd, item))
6680 goto err;
6681 }
6682 dummy_select->with_wild= sel->with_wild;
6683 }
6684 else
6685 {
6686 Item *item= new (thd->mem_root) Item_field(thd, context, star_clex_str);
6687 if (item == NULL)
6688 goto err;
6689 if (add_item_to_list(thd, item))
6690 goto err;
6691 (dummy_select->with_wild)++;
6692 }
6693
6694 sel->set_linkage(DERIVED_TABLE_TYPE);
6695
6696 ti= new (thd->mem_root) Table_ident(unit);
6697 if (ti == NULL)
6698 goto err;
6699 {
6700 TABLE_LIST *table_list;
6701 LEX_CSTRING alias;
6702 if (dummy_select->make_unique_derived_name(thd, &alias))
6703 goto err;
6704
6705 if (!(table_list= dummy_select->add_table_to_list(thd, ti, &alias,
6706 0, TL_READ,

Callers

nothing calls this directly

Calls 7

add_item_to_listFunction · 0.85
attach_selects_chainMethod · 0.80
set_linkageMethod · 0.80
add_table_to_listMethod · 0.80
add_joined_tableMethod · 0.80

Tested by

no test coverage detected