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

Function pushdown_cond_for_derived

sql/sql_derived.cc:1543–1672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1541*/
1542
1543bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived)
1544{
1545 DBUG_ENTER("pushdown_cond_for_derived");
1546 if (!cond)
1547 DBUG_RETURN(false);
1548
1549 st_select_lex_unit *unit= derived->get_unit();
1550 st_select_lex *first_sl= unit->first_select();
1551 st_select_lex *sl= first_sl;
1552
1553 if (derived->prohibit_cond_pushdown)
1554 DBUG_RETURN(false);
1555
1556 /* Do not push conditions into constant derived */
1557 if (unit->executed)
1558 DBUG_RETURN(false);
1559
1560 /* Do not push conditions into recursive with tables */
1561 if (derived->is_recursive_with_table())
1562 DBUG_RETURN(false);
1563
1564 /* Do not push conditions into unit with global ORDER BY ... LIMIT */
1565 if (unit->fake_select_lex &&
1566 unit->fake_select_lex->limit_params.explicit_limit)
1567 DBUG_RETURN(false);
1568
1569 /* Check whether any select of 'unit' allows condition pushdown */
1570 bool some_select_allows_cond_pushdown= false;
1571 for (; sl; sl= sl->next_select())
1572 {
1573 if (sl->cond_pushdown_is_allowed())
1574 {
1575 some_select_allows_cond_pushdown= true;
1576 break;
1577 }
1578 }
1579 if (!some_select_allows_cond_pushdown)
1580 DBUG_RETURN(false);
1581
1582 /* 1. Check what pushable formula can be extracted from cond */
1583 Item *extracted_cond;
1584 cond->check_pushable_cond(&Item::pushable_cond_checker_for_derived,
1585 (uchar *)(&derived->table->map));
1586 /* 2. Build a clone PC of the formula that can be extracted */
1587 extracted_cond=
1588 cond->build_pushable_cond(thd,
1589 &Item::pushable_equality_checker_for_derived,
1590 ((uchar *)&derived->table->map));
1591 if (!extracted_cond)
1592 {
1593 /* Nothing can be pushed into the derived table */
1594 DBUG_RETURN(false);
1595 }
1596
1597 st_select_lex *save_curr_select= thd->lex->current_select;
1598 for (; sl; sl= sl->next_select())
1599 {
1600 Item *extracted_cond_copy;

Callers 1

optimize_innerMethod · 0.85

Calls 15

get_unitMethod · 0.80
first_selectMethod · 0.80
next_selectMethod · 0.80
check_pushable_condMethod · 0.80
build_pushable_condMethod · 0.80
deep_copy_with_checksMethod · 0.80
save_item_list_namesMethod · 0.80
share_name_withMethod · 0.80
have_window_funcsMethod · 0.80

Tested by

no test coverage detected