Bug #102251 | CTE produces wrong result | ||
---|---|---|---|
Submitted: | 15 Jan 2021 4:42 | Modified: | 12 Dec 2022 22:27 |
Reporter: | xiaoyang chen | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 8.0, 8.0.22, 8.0.23 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | regression |
[15 Jan 2021 4:42]
xiaoyang chen
[15 Jan 2021 6:02]
MySQL Verification Team
Hello xiaoyang chen, Thank you for the report and test case. Verified as described. regards, Umesh
[15 Jan 2021 11:29]
xiaoyang chen
Suggest fix: we also should condider to set the hash_field in the cloned tmp table. Namely, the fixed code is --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -210,6 +210,12 @@ TABLE *Common_table_expr::clone_tmp_table(THD *thd, TABLE_LIST *tl) { tl->table = t; t->pos_in_table_list = tl; + if (first->hash_field) { + t->hash_field = t->field[0]; + } + + t->hidden_field_count = first->hidden_field_count; + t->set_not_started();
[21 Mar 2021 10:53]
MySQL Verification Team
related - Bug #103052
[12 Dec 2022 22:27]
Jon Stephens
Documented fix as follows in the MySQL 8.0.33 changelog: While cloning a temporary table for a common table expression which used shared materialization, the cloned temp table was not marked as using hash deduplication, leading to wrong results. We now set the hash field for the cloned temporary table correctly, and update the hidden field count to take this into account. Closed.