You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug#33856374: Query returns incorrect results in 8.0.22+
This problem requires a rather complex set of conditions to trigger:
- We have a CTE that is materialized and used in multiple query blocks.
- For the first query block that uses the CTE, there are multiple
possible key definitions, which causes JOIN::finalize_derived_keys()
to move the used key definition into position zero.
- The second query block that uses the CTE manipulates an index that
uses the same position as the original position for the key chosen
for the first query block.
Now, the function TABLE::copy_tmp_key() is supposed to move the first
key into a position that does not overlap with the subsequent keys.
And this is done for the KEY entry, however the associated entries
(KEY_PART_INFO, key names and rec per key information) are kept as is,
meaning that a subsequent key analysis for another query block may
overwrite the information in these data structures, possibly causing
invalid results to be returned.
The fix is to also move these extra data structures, so that subsequent
query block analyses use pristine data structures.
The function TABLE::copy_tmp_key() is renamed to TABLE::move_tmp_key(),
as this is really a move operation. In addition, old entries are
zeroed out so that a later invalid access will likely fail.
A synthetic test case is added, as the original case is too complex and
contains too much data to be included.
Change-Id: I908dca74560d20fecdd886e55cabfcaa348aba4d
0 commit comments