summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-08-30 11:30:28 -0700
committerIgor Babaev <igor@askmonty.org>2018-08-30 11:30:28 -0700
commitd8b8079e421a7d19d3e0c2c4e4adf526853896cb (patch)
treefb2f11f8b97603c8f7d3fe078617a8a5d62d96e7 /sql/sql_prepare.cc
parent7aa80ba66b042bbcd6f2576522bb87a1fc83a281 (diff)
downloadmariadb-git-d8b8079e421a7d19d3e0c2c4e4adf526853896cb.tar.gz
EV-16992 Assertion `table_ref->table || table_ref->view' failed in
Field_iterator_table_ref::set_field_iterator Several functions that processed different prepare statements missed the DT_INIT flag in last parameter of the open_normal_and_derived_tables() calls. It made context analysis of derived tables dependent on the order in which the derived tables were processed by mysql_handle_derived(). This order was induced by the order of SELECTs in all_select_list. In 10.4 the order of SELECTs in all_select_list became different and lack of the DT_INIT flags in some open_normal_and_derived_tables() call became critical as some derived tables were not identified as such.
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r--sql/sql_prepare.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index fd526f9a660..2ffecbab617 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1582,7 +1582,7 @@ static bool mysql_test_do_fields(Prepared_statement *stmt,
DBUG_RETURN(TRUE);
if (open_normal_and_derived_tables(thd, tables, MYSQL_OPEN_FORCE_SHARED_MDL,
- DT_PREPARE | DT_CREATE))
+ DT_INIT | DT_PREPARE | DT_CREATE))
DBUG_RETURN(TRUE);
DBUG_RETURN(setup_fields(thd, Ref_ptr_array(),
*values, COLUMNS_READ, 0, NULL, 0));
@@ -1614,7 +1614,7 @@ static bool mysql_test_set_fields(Prepared_statement *stmt,
if ((tables &&
check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE)) ||
open_normal_and_derived_tables(thd, tables, MYSQL_OPEN_FORCE_SHARED_MDL,
- DT_PREPARE | DT_CREATE))
+ DT_INIT | DT_PREPARE | DT_CREATE))
goto error;
while ((var= it++))
@@ -1651,7 +1651,8 @@ static bool mysql_test_call_fields(Prepared_statement *stmt,
if ((tables &&
check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE)) ||
- open_normal_and_derived_tables(thd, tables, MYSQL_OPEN_FORCE_SHARED_MDL, DT_PREPARE))
+ open_normal_and_derived_tables(thd, tables, MYSQL_OPEN_FORCE_SHARED_MDL,
+ DT_INIT | DT_PREPARE))
goto err;
while ((item= it++))
@@ -1777,7 +1778,7 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
if (open_normal_and_derived_tables(stmt->thd, lex->query_tables,
MYSQL_OPEN_FORCE_SHARED_MDL,
- DT_PREPARE | DT_CREATE))
+ DT_INIT | DT_PREPARE | DT_CREATE))
DBUG_RETURN(TRUE);
select_lex->context.resolve_in_select_list= TRUE;
@@ -1798,7 +1799,7 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
*/
if (open_normal_and_derived_tables(stmt->thd, lex->query_tables,
MYSQL_OPEN_FORCE_SHARED_MDL,
- DT_PREPARE))
+ DT_INIT | DT_PREPARE))
DBUG_RETURN(TRUE);
}
@@ -2025,7 +2026,7 @@ static bool mysql_test_create_view(Prepared_statement *stmt)
lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
if (open_normal_and_derived_tables(thd, tables, MYSQL_OPEN_FORCE_SHARED_MDL,
- DT_PREPARE))
+ DT_INIT | DT_PREPARE))
goto err;
res= select_like_stmt_test(stmt, 0, 0);