Bug #69703 Unquoted file names for variable values are accepted but parsed incorrectly
Submitted: 9 Jul 2013 18:13 Modified: 6 Mar 2014 18:56
Reporter: Elena Stepanova Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.1, 5.5, 5.6, 5.7 OS:Any
Assigned to: CPU Architecture:Any

[9 Jul 2013 18:13] Elena Stepanova
Description:
It's possible to use an unquoted string for a variable value, but it causes rather unexpected result:

SET GLOBAL slow_query_log_file = my_slow.log;
SELECT @@slow_query_log_file;
@@slow_query_log_file
log

Same for general_log_file, and probably for more. 

How to repeat:
SET GLOBAL slow_query_log_file = my_slow.log;
SELECT @@slow_query_log_file;
[9 Jul 2013 18:44] Valeriy Kravchuk
Indeed (this is on Windows):

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.12    |
+-----------+
1 row in set (0.03 sec)

mysql> SET GLOBAL slow_query_log_file = my_slow.log;
Query OK, 0 rows affected (0.04 sec)

mysql> SELECT @@slow_query_log_file;
+-----------------------+
| @@slow_query_log_file |
+-----------------------+
| log                   |
+-----------------------+
1 row in set (0.00 sec)
[9 Jul 2013 22:15] MySQL Verification Team
Thank you for the bug report.

mysql> SET GLOBAL slow_query_log_file = my_slow.log;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @@slow_query_log_file;
+-----------------------+
| @@slow_query_log_file |
+-----------------------+
| log                   |
+-----------------------+
1 row in set (0.00 sec)

mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------+
| Variable_name           | Value                        |
+-------------------------+------------------------------+
| innodb_version          | 5.6.12                       |
| protocol_version        | 10                           |
| slave_type_conversions  |                              |
| version                 | 5.6.12                       |
| version_comment         | MySQL Community Server (GPL) |
| version_compile_machine | x86_64                       |
| version_compile_os      | osx10.7                      |
+-------------------------+------------------------------+
7 rows in set (0.00 sec)
[6 Mar 2014 18:56] Paul DuBois
Noted in 5.5.37, 5.6.17, 5.7.4 changelogs.

For system variables that take a string value, SET statements
permitted an unquoted value, but values that contained dots were 
parsed incorrectly and only part of the value was assigned. For
example, SET GLOBAL slow_query_log_file = my_slow.log assigned the
value my_slow. Now such values must be quoted or an error occurs.
[27 Mar 2014 14:27] Laurynas Biveinis
5.5$ bzr log -r 4600 -n0
------------------------------------------------------------
revno: 4600
committer: Neeraj Bisht <neeraj.x.bisht@oracle.com>
branch nick: 5.5
timestamp: Wed 2014-02-12 14:33:56 +0530
message:
  Bug#17075846 - UNQUOTED FILE NAMES FOR VARIABLE VALUES ARE
  	       ACCEPTED BUT PARSED INCORRECTLY
  
  When we are setting the value in a system variable, 
  We can set it like 
  
  set sys_var="Iden1.Iden2";		//1
  set sys_var='Iden1.Iden2';		//2
  set sys_var=Iden1.Iden2;		//3
  set sys_var=.ident1.ident2; 		//4
  set sys_var=`Iden1.Iden2`;		//5
  
  
  While parsing, for case 1(when ANSI_QUOTES is enable) and 2,
  we will take as string literal(we will make item of type Item_string).
  for case 3 & 4, taken as Item_field, where Iden1 is a table name and
  iden2 is a field name.
  for case 5, again Item_field type, where iden1.iden2 is taken as
  field name.
  
  
  Now in case 1, when we are assigning some value to system variable
  (which can take string or enumerate type data), we are setting only 
  field part.
  This means only iden2 value will be set for system variable. This 
  result in wrong result.
  
  Solution:
  
  (for string type) We need to Document that we are not allowed to set 
  system variable which takes string as identifier, otherwise result 
  in unexpected behaviour.
  
  (for enumerate type)
  if we pass iden1.iden2, we will give an error ER_WRONG_TYPE_FOR_VAR
  (Incorrect argument type to variable).