Comment 1 for bug 1376934

Revision history for this message
Muhammad Irfan (muhammad-irfan) wrote : Re: per query variable statements failing

I am able to reproduce this problem. max_statement_time works as expected when set on session level or global level (in my.cnf) but fails to work correctly when set on query level with SET STATEMENT. I tested on on Percona Server 5.6.16/5.6.20

mysql [localhost] {msandbox} (world) > show global variables like '%version%';
+-------------------------+-----------------------------------------------------------------+
| Variable_name | Value |
+-------------------------+-----------------------------------------------------------------+
| innodb_version | 5.6.16-rel64.1 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.6.16-64.1-rel64.1-log |
| version_comment | Percona Server with XtraDB (GPL), Release rel64.1, Revision 563 |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
+-------------------------+-----------------------------------------------------------------+

mysql [localhost] {msandbox} (world) > show global variables like '%version%';
+-------------------------+--------------------------------------------------+
| Variable_name | Value |
+-------------------------+--------------------------------------------------+
| innodb_version | 5.6.20-rel68.0 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.6.20-68.0 |
| version_comment | Percona Server (GPL), Release 68.0, Revision 656 |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
+-------------------------+--------------------------------------------------+

When set max_statement_time variable in my.cnf it works as expected as per below test results.

mysql [localhost] {msandbox} (world) > SELECT * FROM Country GROUP BY HeadOfState ORDER BY Continent;
ERROR 1882 (70101): Query execution was interrupted, max_statement_time exceeded

mysql [localhost] {msandbox} (world) > SELECT * FROM CountryLanguage GROUP BY IsOfficial ORDER BY Percentage DESC;
ERROR 1882 (70101): Query execution was interrupted, max_statement_time exceeded

Again, when one set on session level, it works correctly.

mysql [localhost] {msandbox} (world) > SET SESSION max_statement_time=1;
Query OK, 0 rows affected (0.00 sec)

mysql [localhost] {msandbox} ((none)) > SHOW VARIABLES LIKE 'max_statement_time';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_statement_time | 1 |
+--------------------+-------+
1 row in set (0.00 sec)

mysql [localhost] {msandbox} ((none)) > SHOW GLOBAL VARIABLES LIKE 'max_statement_time';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_statement_time | 0 |
+--------------------+-------+
1 row in set (0.00 sec)

mysql [localhost] {msandbox} (world) > SELECT * FROM Country WHERE Continent NOT IN ('Africa','Oceania') AND Population > 10000 AND Name<>'Pakistan' GROUP BY Capital ASC, GNP DESC ORDER BY Code2 ASC, SurfaceArea DESC;
ERROR 1882 (70101): Query execution was interrupted, max_statement_time exceeded

But it fails on query level when set via SET STATEMENT

mysql [localhost] {msandbox} ((none)) > SHOW VARIABLES LIKE 'max_statement_time';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_statement_time | 0 |
+--------------------+-------+
1 row in set (0.00 sec)

mysql [localhost] {msandbox} ((none)) > SHOW GLOBAL VARIABLES LIKE 'max_statement_time';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_statement_time | 0 |
+--------------------+-------+
1 row in set (0.00 sec)

mysql [localhost] {msandbox} (world) > SET STATEMENT max_statement_time=1 FOR SELECT * FROM Country WHERE Continent NOT IN ('Africa','Oceania') AND Population > 10000 AND Name<>'Pakistan' GROUP BY Capital ASC, GNP DESC ORDER BY Code2 ASC, SurfaceArea DESC;
142 rows in set (0.6 sec)