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

Function print_join

sql/sql_select.cc:32003–32092  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32001*/
32002
32003static void print_join(THD *thd,
32004 table_map eliminated_tables,
32005 String *str,
32006 List<TABLE_LIST> *tables,
32007 enum_query_type query_type)
32008{
32009 /* List is reversed => we should reverse it before using */
32010 List_iterator_fast<TABLE_LIST> ti(*tables);
32011 TABLE_LIST **table;
32012 DBUG_ENTER("print_join");
32013
32014 /*
32015 If the QT_NO_DATA_EXPANSION flag is specified, we print the
32016 original table list, including constant tables that have been
32017 optimized away, as the constant tables may be referenced in the
32018 expression printed by Item_field::print() when this flag is given.
32019 Otherwise, only non-const tables are printed.
32020
32021 Example:
32022
32023 Original SQL:
32024 select * from (select 1) t
32025
32026 Printed without QT_NO_DATA_EXPANSION:
32027 select '1' AS `1` from dual
32028
32029 Printed with QT_NO_DATA_EXPANSION:
32030 select `t`.`1` from (select 1 AS `1`) `t`
32031 */
32032 const bool print_const_tables= (query_type & QT_NO_DATA_EXPANSION);
32033 size_t tables_to_print= 0;
32034
32035 for (TABLE_LIST *t= ti++; t ; t= ti++)
32036 {
32037 /* See comment in print_table_array() about the second condition */
32038 if (print_const_tables || !t->optimized_away)
32039 if (!is_eliminated_table(eliminated_tables, t))
32040 tables_to_print++;
32041 }
32042 if (tables_to_print == 0)
32043 {
32044 str->append(STRING_WITH_LEN("dual"));
32045 DBUG_VOID_RETURN; // all tables were optimized away
32046 }
32047 ti.rewind();
32048
32049 if (!(table= thd->alloc<TABLE_LIST*>(tables_to_print)))
32050 DBUG_VOID_RETURN; // out of memory
32051
32052 TABLE_LIST *tmp, **t= table + (tables_to_print - 1);
32053 while ((tmp= ti++))
32054 {
32055 if (tmp->optimized_away && !print_const_tables)
32056 continue;
32057 if (is_eliminated_table(eliminated_tables, tmp))
32058 continue;
32059 *t--= tmp;
32060 }

Callers 1

printMethod · 0.85

Calls 4

is_eliminated_tableFunction · 0.85
print_table_arrayFunction · 0.85
appendMethod · 0.45
rewindMethod · 0.45

Tested by

no test coverage detected