diff options
author | Igor Babaev <igor@askmonty.org> | 2020-12-16 09:11:11 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2020-12-16 09:13:24 -0800 |
commit | a244be7044534a59199a0f11e856be37ba6f02c8 (patch) | |
tree | d224267e41e1aec81df729c916503b4f7bd32ab9 /sql/sql_select.cc | |
parent | 719da2c4cc988760049ef4eefe04081594763149 (diff) | |
download | mariadb-git-a244be7044534a59199a0f11e856be37ba6f02c8.tar.gz |
MDEV-23406 Signal 8 in maria_create after recursive cte query
This bug could cause a crash when executing queries that used mutually
recursive CTEs with system variable big_tables set to 1. It happened due
to several bugs in the code that handled recursive table references
referred mutually recursive CTEs. For each recursive table reference a
temporary table is created that contains all rows generated for the
corresponding recursive CTE table on the previous step of recursion.
This temporary table should be created in the same way as the temporary
table created for a regular materialized derived table using the
method select_union::create_result_table(). In this case when the
temporary table is created it uses the select_union::TMP_TABLE_PARAM
structure as the parameter for the table construction. However the
code created the temporary table using just the function create_tmp_table()
and passed pointers to certain fields of the TMP_TABLE_PARAM structure
used for accumulation of rows of the recursive CTE table as parameters
for update. This was a mistake because now different temporary tables
cannot share some TMP_TABLE_PARAM fields in a general case. Besides,
depending on how mutually recursive CTE tables were defined and which
of them were referred in the executed query the select_union object
allocated for a recursive table reference could be allocated again after
the the temporary table had been created. In this case the TMP_TABLE_PARAM
object associated with the temporary table created for the recursive
table reference contained unassigned fields needed for execution when
Aria engine is employed as the engine for temporary tables.
This patch ensures that
- select_union object is created only once for any recursive table
reference
- any temporary table created for recursive CTEs uses its own
TMP_TABLE_PARAM structure
The patch also fixes a problem caused by incomplete cleanup of join tables
associated with recursive table references.
Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 8b4401b1009..d5e5a79eba2 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11929,10 +11929,6 @@ void JOIN_TAB::cleanup() { DBUG_ENTER("JOIN_TAB::cleanup"); - if (tab_list && tab_list->is_with_table_recursive_reference() && - tab_list->with->is_cleaned()) - DBUG_VOID_RETURN; - DBUG_PRINT("enter", ("tab: %p table %s.%s", this, (table ? table->s->db.str : "?"), |