Skip to content

Bug#112704: Fix TempTable CTE clone handler mismatch when TempTable f…#672

Open
catalinbp wants to merge 1 commit into
mysql:trunkfrom
catalinbp:bug112704
Open

Bug#112704: Fix TempTable CTE clone handler mismatch when TempTable f…#672
catalinbp wants to merge 1 commit into
mysql:trunkfrom
catalinbp:bug112704

Conversation

@catalinbp

Copy link
Copy Markdown

…alls back to InnoDB

When TempTable materialization hits RECORD_FILE_FULL and falls back to InnoDB, CTE clones keep TempTable handlers created at preparation time (open_table_from_share()), while the table itself is created in InnoDB. Later open_tmp_table() calls on those clones fail with "Table doesn't exist".

Non-recursive CTE refs hit this in create_materialized_table()'s shortcut path. Recursive CTE refs hit it separately in FollowTailIterator::Init(), which opens recursive clones without going through create_materialized_table().

Changes:

  1. sql_derived.cc: In create_materialized_table()'s shortcut path, detect handler-type mismatch and replace the handler to match an already-created sibling clone before open_tmp_table().

  2. basic_row_iterators.cc: In FollowTailIterator::Init(), detect handler-type mismatch against share->db_type() (already corrected during fallback) and replace the stale handler before opening.

  3. sql_tmp_table.cc: On TempTable->InnoDB fallback, update share->db_plugin so db_type() reflects InnoDB, destroy the stale TempTable handler, keep create_info.db_type consistent, and count Created_tmp_disk_tables once.

…alls back to InnoDB

When TempTable materialization hits RECORD_FILE_FULL and falls back to
InnoDB, CTE clones keep TempTable handlers created at preparation time
(open_table_from_share()), while the table itself is created in InnoDB.
Later open_tmp_table() calls on those clones fail with "Table doesn't
exist".

Non-recursive CTE refs hit this in create_materialized_table()'s
shortcut path. Recursive CTE refs hit it separately in
FollowTailIterator::Init(), which opens recursive clones without going
through create_materialized_table().

Changes:

1. sql_derived.cc: In create_materialized_table()'s shortcut path,
   detect handler-type mismatch and replace the handler to match an
   already-created sibling clone before open_tmp_table().

2. basic_row_iterators.cc: In FollowTailIterator::Init(), detect
   handler-type mismatch against share->db_type() (already corrected
   during fallback) and replace the stale handler before opening.

3. sql_tmp_table.cc: On TempTable->InnoDB fallback, update
   share->db_plugin so db_type() reflects InnoDB, destroy the stale
   TempTable handler, keep create_info.db_type consistent, and count
   Created_tmp_disk_tables once.
@mysql-oca-bot

Copy link
Copy Markdown

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at https://oca.opensource.oracle.com/
Please make sure to include your MySQL bug system user (email) in the returned form.
Thanks

@catalinbp

Copy link
Copy Markdown
Author

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at https://oca.opensource.oracle.com/ Please make sure to include your MySQL bug system user (email) in the returned form. Thanks

I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants