summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <gluh@gluh.mysql.r18.ru>2004-03-16 17:14:11 +0400
committerunknown <gluh@gluh.mysql.r18.ru>2004-03-16 17:14:11 +0400
commit6c8a28288abef532d4dbd6c74edc11feca50ebd4 (patch)
tree7be5f1da4b294efaab4e3eb76e5c0eeb70eeb3b3
parent5de92fc753881fcc0d5779c4f01ed8628175d586 (diff)
parentded9313d32be91b05391b8bf6852d58aa7eaaf08 (diff)
downloadmariadb-git-6c8a28288abef532d4dbd6c74edc11feca50ebd4.tar.gz
Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-4.1
into gluh.mysql.r18.ru:/home/gluh/mysql-4.1.clear
-rw-r--r--mysql-test/r/variables.result10
-rw-r--r--mysql-test/t/variables.test14
-rw-r--r--sql/item_func.cc16
-rw-r--r--sql/mysql_priv.h3
-rw-r--r--sql/sql_yacc.yy5
5 files changed, 48 insertions, 0 deletions
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 71e26c42b70..c56ccc3641a 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -406,3 +406,13 @@ set @a=@b, @b=@a;
select @a, @b;
@a @b
2 1
+set @@global.global.key_buffer_size= 1;
+ERROR 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
+set GLOBAL global.key_buffer_size= 1;
+ERROR 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
+SELECT @@global.global.key_buffer_size;
+ERROR 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
+SELECT @@global.session.key_buffer_size;
+ERROR 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
+SELECT @@global.local.key_buffer_size;
+ERROR 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
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 05ac0427a92..78fab3afe42 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -285,3 +285,17 @@ select @@global.max_user_connections,@@local.max_join_size;
set @a=1, @b=2;
set @a=@b, @b=@a;
select @a, @b;
+
+#
+# Bug#2586:Disallow global/session/local as structured var. instance names
+#
+--error 1149
+set @@global.global.key_buffer_size= 1;
+--error 1149
+set GLOBAL global.key_buffer_size= 1;
+--error 1149
+SELECT @@global.global.key_buffer_size;
+--error 1149
+SELECT @@global.session.key_buffer_size;
+--error 1149
+SELECT @@global.local.key_buffer_size;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 878c4d2ea5f..88c2bf824c6 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -29,6 +29,16 @@
#include <ft_global.h>
+bool check_reserved_words(LEX_STRING *name)
+{
+ if (!my_strcasecmp(system_charset_info, name->str, "GLOBAL") ||
+ !my_strcasecmp(system_charset_info, name->str, "LOCAL") ||
+ !my_strcasecmp(system_charset_info, name->str, "SESSION"))
+ return TRUE;
+ return FALSE;
+}
+
+
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
const char *fname)
{
@@ -2957,6 +2967,12 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
(uint) strlen(server_version),
system_charset_info);
+ if (name.str && component.str && check_reserved_words(&name))
+ {
+ net_printf(thd, ER_SYNTAX_ERROR);
+ return 0;
+ }
+
Item *item;
sys_var *var;
char buff[MAX_SYS_VAR_LENGTH*2+4+8], *pos;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 8f86d9990fe..56e1a172d0b 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -751,6 +751,9 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
/* mysqld.cc */
extern void yyerror(const char*);
+/* item_func.cc */
+extern bool check_reserved_words(LEX_STRING *name);
+
/* strfunc.cc */
ulonglong find_set(TYPELIB *typelib,const char *x, uint length,
char **err_pos, uint *err_len, bool *set_warning);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index f317219bd38..0f9147b7834 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -5034,6 +5034,11 @@ internal_variable_name:
}
| ident '.' ident
{
+ if (check_reserved_words(&$1))
+ {
+ net_printf(YYTHD, ER_SYNTAX_ERROR);
+ YYABORT;
+ }
sys_var *tmp=find_sys_var($3.str, $3.length);
if (!tmp)
YYABORT;