summaryrefslogtreecommitdiff
path: root/sql/sql_yacc.yy
diff options
context:
space:
mode:
authorNeeraj Bisht <neeraj.x.bisht@oracle.com>2014-02-12 14:33:56 +0530
committerNeeraj Bisht <neeraj.x.bisht@oracle.com>2014-02-12 14:33:56 +0530
commita3123b847515b9607e34ecd2a408c0f4efc0d5bc (patch)
treecf3a270bb74235b92be8fd5825703b15cc3c0152 /sql/sql_yacc.yy
parentb0b08e76f35bab8c1f1a89fe1ccd27670aa8a8f7 (diff)
downloadmariadb-git-a3123b847515b9607e34ecd2a408c0f4efc0d5bc.tar.gz
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).
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r--sql/sql_yacc.yy9
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 13c547cb9f7..3af964db731 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -444,6 +444,13 @@ set_system_variable(THD *thd, struct sys_var_with_base *tmp,
if (lex->spcont && tmp->var == Sys_autocommit_ptr)
lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT;
+ if (val && val->type() == Item::FIELD_ITEM &&
+ ((Item_field*)val)->table_name)
+ {
+ my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), tmp->var->name.str);
+ return TRUE;
+ }
+
if (! (var= new set_var(var_type, tmp->var, &tmp->base_name, val)))
return TRUE;