[MDEV-6944] SQL_MODEs related to parsing are not applied during execution of the actual statement under SET STATEMENT .. FOR Created: 2014-10-25  Updated: 2015-04-07  Resolved: 2015-04-07

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: N/A
Fix Version/s: 10.1.4

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Won't Fix Votes: 0
Labels: None

Issue Links:
PartOf
includes MDEV-7012 SET STATEMENT character_set_client, c... Closed
Relates
relates to MDEV-5231 Per query variables from Percona Serv... Closed
relates to MDEV-6923 Testing for SET STATEMENT .. FOR (MDE... Closed

 Description   

Note: there are quite a few tests for ANSI mode in the patch, but they seem to work the other way round – checking that SQL_MODEs which are set under 'SET STATEMENT sql_mode=<mode>}} are not applied when the whole initial SET STATEMENT sql_mode=... FOR ... is being parsed; so I'm not sure if the behavior described below is intentional, which is why I set it to 'Minor' for now. It does not look logical, though.

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='ANSI_QUOTES';
# 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='IGNORE_SPACE' FOR CREATE TABLE count (i INT);
# Query OK, 0 rows affected (0.81 sec)
 
# ... but it doesn't.
 
# Compare with the usual behavior:
 
SET sql_mode='IGNORE_SPACE';
# 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

It's all the same in Percona server.



 Comments   
Comment by Oleksandr Byelkin [ 2014-11-11 ]

It can't work because all statement parsed as one. (doc should be updated)

Comment by Oleksandr Byelkin [ 2015-03-11 ]

could be fixed by early assignment after parsing SET STATEMENT part, but 7006 have to be approved first...

Comment by Oleksandr Byelkin [ 2015-03-18 ]

Most part of this bug fixed in MDEV-7012

Comment by Oleksandr Byelkin [ 2015-03-18 ]

revision-id: 7054be616427d9a3c92f321741b3cd120321281f
parent(s): 622611bc6a9371803f349d8cf4de6538ebbcdb37
committer: Oleksandr Byelkin
branch nick: server
timestamp: 2015-03-18 00:10:42 +0100
message:

MDEV-6944: SQL_MODEs related to parsing are not applied during execution of the actual statement under SET STATEMENT .. FOR

Actually fix for MDEV-7012 is fixing it, here is only parsing mode recalculating added and test suite.

Comment by Oleksandr Byelkin [ 2015-04-07 ]

the behavior will be described in documantation

Generated at Thu Feb 08 07:15:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.