Per query variable statement

Registered by Vlad Lesin on 2012-08-28

The initial feature description can be found here: http://dev.mysql.com/worklog/task/?id=681 .

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_command, and restoring the
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:
milestone icon 5.6.14-62.0
Started by
Laurynas Biveinis on 2012-09-10
Completed by
Alexey Kopytov on 2013-10-16

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.