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

Function simplify_joins

sql/sql_select.cc:19905–20202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19903*/
19904
19905static COND *
19906simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
19907 bool in_sj)
19908{
19909 TABLE_LIST *table;
19910 NESTED_JOIN *nested_join;
19911 TABLE_LIST *prev_table= 0;
19912 List_iterator<TABLE_LIST> li(*join_list);
19913 bool straight_join= MY_TEST(join->select_options & SELECT_STRAIGHT_JOIN);
19914 DBUG_ENTER("simplify_joins");
19915
19916 /*
19917 Try to simplify join operations from join_list.
19918 The most outer join operation is checked for conversion first.
19919 */
19920 while ((table= li++))
19921 {
19922 table_map used_tables;
19923 table_map not_null_tables= (table_map) 0;
19924
19925 if ((nested_join= table->nested_join))
19926 {
19927 /*
19928 If the element of join_list is a nested join apply
19929 the procedure to its nested join list first.
19930 */
19931 if (table->on_expr)
19932 {
19933 Item *expr= table->on_expr;
19934 /*
19935 If an on expression E is attached to the table,
19936 check all null rejected predicates in this expression.
19937 If such a predicate over an attribute belonging to
19938 an inner table of an embedded outer join is found,
19939 the outer join is converted to an inner join and
19940 the corresponding on expression is added to E.
19941 */
19942 expr= simplify_joins(join, &nested_join->join_list,
19943 expr, FALSE, in_sj || table->sj_on_expr);
19944
19945 if (!table->prep_on_expr || expr != table->on_expr)
19946 {
19947 DBUG_ASSERT(expr);
19948
19949 table->on_expr= expr;
19950 table->prep_on_expr= expr->copy_andor_structure(join->thd);
19951 }
19952 }
19953 nested_join->used_tables= (table_map) 0;
19954 nested_join->not_null_tables=(table_map) 0;
19955 conds= simplify_joins(join, &nested_join->join_list, conds, top,
19956 in_sj || table->sj_on_expr);
19957 used_tables= nested_join->used_tables;
19958 not_null_tables= nested_join->not_null_tables;
19959 /* The following two might become unequal after table elimination: */
19960 nested_join->n_tables= nested_join->join_list.elements;
19961 }
19962 else

Callers 1

optimize_innerMethod · 0.85

Calls 13

and_condsFunction · 0.85
optimizer_flagFunction · 0.85
get_mapMethod · 0.80
fixedMethod · 0.80
copy_andor_structureMethod · 0.45
not_null_tablesMethod · 0.45
headMethod · 0.45
top_level_itemMethod · 0.45
fix_fieldsMethod · 0.45
used_tablesMethod · 0.45
rewindMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected