SQL_MODEs related to parsing are not applied during execution of the actual statement under SET STATEMENT .. FOR
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Percona Server moved to https://jira.percona.com/projects/PS | Status tracked in 5.7 | |||||
5.6 |
Triaged
|
Medium
|
Unassigned | |||
5.7 |
Triaged
|
Medium
|
Unassigned |
Bug Description
Note: quick search through percona_
#------
Example 1 - ANSI_QUOTES
DROP TABLE IF EXISTS t1;
# Query OK, 0 rows affected (0.18 sec)
# Set sql_mode = 'ANSI_QUOTES' to allow the initial parsing of the whole SET STATEMENT .. FOR
SET sql_mode=
# Query OK, 0 rows affected (0.00 sec)
# But for the *actual* CREATE statement we unset the sql_mode, so
# the execution should fail with the syntax error
SET STATEMENT sql_mode='' FOR CREATE TABLE "t1" (i INT);
# Query OK, 0 rows affected (0.50 sec)
# ... but it doesn't.
# Compare with the usual behavior:
SET sql_mode = '';
# Query OK, 0 rows affected (0.00 sec)
CREATE TABLE "t1" (i INT);
# ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"t1" (i INT)' at line 1
#------
Example 2 - IGNORE_SPACE
DROP TABLE IF EXISTS count;
# Query OK, 0 rows affected (0.21 sec)
# IGNORE_SPACE mode should prevent creation of the `count` table:
SET STATEMENT sql_mode=
# Query OK, 0 rows affected (0.81 sec)
# ... but it doesn't.
# Compare with the usual behavior:
SET sql_mode=
# Query OK, 0 rows affected (0.00 sec)
CREATE TABLE count (i INT);
# ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'count (i INT)' at line 1
#------
bzr version-info
revision-id: <email address hidden>
date: 2014-10-21 11:25:15 +0300
build-date: 2014-10-25 14:01:00 +0400
revno: 687
branch-nick: percona-5.6
description: | updated |
description: | updated |
tags: | added: set-statement |
Easy to confirm:
[openxs@centos mysql-test]$ mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.21-69.0 Percona Server (GPL), Release 69.0, Revision 675
Copyright (c) 2009-2014 Percona LLC and/or its affiliates
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected (0.17 sec)
mysql> SET sql_mode= 'ANSI_QUOTES' ;
Query OK, 0 rows affected (0.00 sec)
mysql> SET STATEMENT sql_mode='' FOR CREATE TABLE "t1" (i INT);
Query OK, 0 rows affected (0.21 sec)
mysql> SET sql_mode='';
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE "t2" (i INT);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"t2" (i INT)' at line 1
mysql> DROP TABLE IF EXISTS count;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SET STATEMENT sql_mode= 'IGNORE_ SPACE' FOR CREATE TABLE count (i INT);
Query OK, 0 rows affected (0.14 sec)
mysql> SET sql_mode= 'IGNORE_ SPACE';
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE count (i INT);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'count (i INT)' at line 1