Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SET STATEMENT ... FOR bug 1635927 and bug 1392375. #1273

Merged
merged 1 commit into from Jan 6, 2017

Conversation

laurynas-biveinis
Copy link
Contributor

Bug 1392375 is that repeated execution of SET STATEMENT ... FOR
crashes and bug 1635927 is a memory leak when using per-query variables with subquery temp tables. Both bugs share the root cause which is that SET STATEMENT query variables were set with a sql_set_variables call before main query execution. This function frees subselect joins, if any, at its end, which is premature as they are needed for main query execution. As the subselect lex object is marked as already freed, any subsequent free attempts will be no-ops, resulting in either a memory leak or a crash that the lex already has a join associated. Fix by not freeing subselect joins for SET STATEMENT variable setting part. At the same time add invariant asserts to st_select_lex_unit methods that the object is in cleaned state iff it has no associated joins. http://jenkins.percona.com/job/percona-server-5.6-param/1577/

Bug 1392375 is that repeated execution of SET STATEMENT ... FOR
<SELECT FROM view> crashes and bug 1635927 is a memory leak when using
per-query variables with subquery temp tables.

Both bugs share the root cause which is that SET STATEMENT query
variables were set with a sql_set_variables call before main query
execution. This function frees subselect joins, if any, at its end,
which is premature as they are needed for main query execution. As
the subselect lex object is marked as already freed, any subsequent
free attempts will be no-ops, resulting in either a memory leak or a
crash that the lex already has a join associated. Fix by not freeing
subselect joins for SET STATEMENT variable setting part.

At the same time add invariant asserts to st_select_lex_unit methods
that the object is in cleaned state iff it has no associated joins.
Copy link
Collaborator

@percona-ysorokin percona-ysorokin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@laurynas-biveinis laurynas-biveinis merged commit ce17ecf into percona:5.6 Jan 6, 2017
@laurynas-biveinis laurynas-biveinis deleted the bug1635927-5.6 branch January 6, 2017 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants