summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a4ef786776b..13d7f94591f 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1247,6 +1247,14 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
enum_parsing_place save_place=
thd->lex->current_select->context_analysis_place;
thd->lex->current_select->context_analysis_place= SELECT_LIST;
+
+ for (TABLE_LIST *tbl= tables_list; tbl; tbl= tbl->next_local)
+ {
+ if (tbl->table_function &&
+ tbl->table_function->setup(thd, tbl))
+ DBUG_RETURN(-1);
+ }
+
if (setup_fields(thd, ref_ptrs, fields_list, MARK_COLUMNS_READ,
&all_fields, &select_lex->pre_fix, 1))
DBUG_RETURN(-1);
@@ -9520,7 +9528,7 @@ best_extension_by_limited_search(JOIN *join,
table_map real_table_bit= s->table->map;
if ((remaining_tables & real_table_bit) &&
(allowed_tables & real_table_bit) &&
- !(remaining_tables & s->dependent) &&
+// !(remaining_tables & s->dependent) &&
(!idx || !check_interleaving_with_nj(s)))
{
double current_record_count, current_read_time;
@@ -12661,6 +12669,10 @@ uint check_join_cache_usage(JOIN_TAB *tab,
!join->allowed_outer_join_with_cache)
goto no_join_cache;
+ if (tab->table->pos_in_table_list->table_function &&
+ !tab->table->pos_in_table_list->table_function->join_cache_allowed())
+ goto no_join_cache;
+
/*
Non-linked join buffers can't guarantee one match
*/
@@ -16406,7 +16418,7 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
if (table->outer_join && !table->embedding && table->table)
table->table->maybe_null= FALSE;
table->outer_join= 0;
- if (!(straight_join || table->straight))
+ if (!(straight_join || table->straight || table->table_function))
{
table->dep_tables= 0;
TABLE_LIST *embedding= table->embedding;
@@ -26681,6 +26693,9 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta,
!((QUICK_ROR_INTERSECT_SELECT*)cur_quick)->need_to_fetch_row)
key_read=1;
+ if (table_list->table_function)
+ eta->push_extra(ET_TABLE_FUNCTION);
+
if (info)
{
eta->push_extra(info);
@@ -27517,6 +27532,14 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
cmp_name= table_name.str;
}
}
+ else if (table_function)
+ {
+ /* A table function. */
+ (void) table_function->print(thd, this, str, query_type);
+ str->append(' ');
+ append_identifier(thd, str, &alias);
+ cmp_name= alias.str;
+ }
else
{
// A normal table