Per query variable statement
The initial feature description can be found here: http://
Some of the variable settings has much more meaning being set for query rather
than for connection.
That is you might with to increase sort_buffer_size before doing large sort
query but it is very likely other queries in a session are simple and quite
OK with default settings.
Now to one can set variable value on query basics the following way:
1) store current value got by SHOW SESSION VARIABLES LIKE "name";
2) set new variable value
3) run the query.
4) restore old settings
Which require 4 steps instead of one, which can override all benefit of tuning,
also it requires changing the application rather than the query itself.
The good solution is allow session variable to be set inside of the query.
The syntax is:
SET STATEMENT ... FOR <statement>
"FOR" was added to help the parser (read - resolve reduce/reduce conflicts) to
separate the expression in the assignment from a statement, as
(SELECT 1) is both a valid <statement> and a valid <expression>.
SET STATEMENT ... FOR <statement> can be used anywhere a <statement> can be.
the feature is implemented by remembering a list of modified variables and their
old values at the beginning of the mysql_execute_
value at the end. An error in assignment aborts the statement.
Blueprint information
- Status:
- Complete
- Approver:
- Alexey Kopytov
- Priority:
- Medium
- Drafter:
- Vlad Lesin
- Direction:
- Approved
- Assignee:
- Vlad Lesin
- Definition:
- Approved
- Series goal:
- Accepted for 5.6
- Implementation:
-
Implemented
- Milestone target:
-
5.6.14-62.0
- Started by
- Laurynas Biveinis
- Completed by
- Alexey Kopytov