MDEV-32401 expression cache lead to crash if table of wrong type created and the cache switched off - #5492
MDEV-32401 expression cache lead to crash if table of wrong type created and the cache switched off#5492forkfun wants to merge 1 commit into
Conversation
…ted and the cache switched off 1) take into account TMP_TABLE_ALL_COLUMNS when we are modifying agg_item->result_field 2) remove unused now "bool materialized_subquery;" (cherry picked from commit 3d0ea3d)
|
|
There was a problem hiding this comment.
Pull request overview
Fixes MDEV-32401 by preventing unsafe Item_sum::result_field rewrites when creating “all columns” temporary tables (e.g., expression cache / non-aggregation temp tables), removes the now-unused temp-table materialization flag, and adds a regression test to cover the crash scenario.
Changes:
- Gate
Item_sum::result_fieldupdates onTMP_TABLE_ALL_COLUMNS/not_all_columnsduring tmp table field creation. - Remove
TMP_TABLE_PARAM::materialized_subqueryand its remaining assignment. - Add mysql-test coverage reproducing the expression-cache crash scenario.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sql/sql_select.cc | Changes when Item_sum::result_field gets updated during tmp table creation. |
| sql/sql_priv.h | Documents semantics of TMP_TABLE_ALL_COLUMNS. |
| sql/sql_class.h | Removes TMP_TABLE_PARAM::materialized_subquery member and constructor init. |
| sql/sql_class.cc | Removes materialized_subquery initialization. |
| sql/item_subselect.cc | Removes setting of the removed materialized_subquery flag. |
| mysql-test/main/subselect_cache.test | Adds regression test queries for MDEV-32401. |
| mysql-test/main/subselect_cache.result | Updates expected output for the new regression test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (not_all_columns) | ||
| { | ||
| DBUG_ASSERT(!agg_item->result_field); | ||
| agg_item->result_field= new_field; | ||
| } |
| /* | ||
| Include all colums in temporary table, i.e. do not ignore aggregate and | ||
| constants, i.e. the temporary table created for other purposes than | ||
| aggregation. | ||
|
|
||
| As a side effect it also require do not modify result_field of the | ||
| Items by which the temporary table created | ||
| */ |
we are modifying agg_item->result_field
(cherry picked from commit 3d0ea3d)