[Commits] 8b533cc1d5d: MDEV-17399: JSON_TABLE: cleanup table dependency code
revision-id: 8b533cc1d5d85137fa3225a6b11e2c59d85439a0 (mariadb-10.5.2-478-g8b533cc1d5d) parent(s): fd484f44eb29f2580d70bba896e192b4c713ced8 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-03-15 17:03:52 +0300 message: MDEV-17399: JSON_TABLE: cleanup table dependency code - Don't touch simplify_joins() - All dependencies caused by JSON_TABLE(...) are now added by add_table_function_dependencies(). --- sql/json_table.cc | 14 ++++++++++---- sql/sql_select.cc | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sql/json_table.cc b/sql/json_table.cc index 701aeff5020..a7bad26cfc6 100644 --- a/sql/json_table.cc +++ b/sql/json_table.cc @@ -1153,9 +1153,8 @@ int Table_function_json_table::setup(THD *thd, TABLE_LIST *sql_table, if (m_dep_tables) { - sql_table->dep_tables|= m_dep_tables; t->no_cache= TRUE; - if (unlikely(sql_table->dep_tables & sql_table->get_map())) + if (unlikely(m_dep_tables & sql_table->get_map())) { /* Table itself is used in the argument. */ my_error(ER_WRONG_USAGE, MYF(0), "JSON_TABLE", "argument"); @@ -1308,8 +1307,9 @@ static void add_extra_deps(List<TABLE_LIST> *join_list, table_map deps) /* @brief - Add extra dependencies implied by table functions so that the join - optimizer does not construct "dead-end" join prefixes. + Add table dependencies that are directly caused by table functions, also + add extra dependencies so that the join optimizer does not construct + "dead-end" join prefixes. @detail There are two kinds of limitations on join order: @@ -1321,6 +1321,9 @@ static void add_extra_deps(List<TABLE_LIST> *join_list, table_map deps) current table in the query text. The table maybe outside of the current nested join and/or inside another nested join. + One may think that adding dependency according to #2 would be sufficient, + but this is not the case. + @example select ... @@ -1387,7 +1390,10 @@ table_map add_table_function_dependencies(List<TABLE_LIST> *join_list, nested_join->used_tables); } else if (table->table_function) + { + table->dep_tables |= table->table_function->used_tables(); res |= table->dep_tables; + } } res= res & ~nest_tables & ~PSEUDO_TABLE_BITS; // Then, make all "peers" have them: diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d1f4c6a24d5..46ef64e4eba 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -16522,7 +16522,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 || table->table_function)) + if (!(straight_join || table->straight)) { table->dep_tables= 0; TABLE_LIST *embedding= table->embedding;
participants (1)
-
psergey