summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/variables.result6
-rw-r--r--mysql-test/t/variables.test11
-rw-r--r--sql/gen_lex_hash.cc13
-rw-r--r--sql/sql_lex.cc2
4 files changed, 30 insertions, 2 deletions
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index a0e516d2397..cd834a789bd 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -689,6 +689,12 @@ select @@log_queries_not_using_indexes;
show variables like 'log_queries_not_using_indexes';
Variable_name Value
log_queries_not_using_indexes OFF
+select @@"";
+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 near '""' at line 1
+select @@&;
+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 near '&' at line 1
+select @@@;
+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 near '@' at line 1
End of 5.0 tests
set global binlog_cache_size =@my_binlog_cache_size;
set global connect_timeout =@my_connect_timeout;
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 68efcafd1e0..d855b4d8266 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -585,6 +585,16 @@ show variables like 'ssl%';
select @@log_queries_not_using_indexes;
show variables like 'log_queries_not_using_indexes';
+#
+# Bug#20908: Crash if select @@""
+#
+--error ER_PARSE_ERROR
+select @@"";
+--error ER_PARSE_ERROR
+select @@&;
+--error ER_PARSE_ERROR
+select @@@;
+
--echo End of 5.0 tests
# This is at the very after the versioned tests, since it involves doing
@@ -620,3 +630,4 @@ set global server_id =@my_server_id;
set global slow_launch_time =@my_slow_launch_time;
set global storage_engine =@my_storage_engine;
set global thread_cache_size =@my_thread_cache_size;
+
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 7e0b178f7af..e59986092e4 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -442,13 +442,16 @@ int main(int argc,char **argv)
if (get_options(argc,(char **) argv))
exit(1);
+ /* Broken up to indicate that it's not advice to you, gentle reader. */
+ printf("/*\n\n Do " "not " "edit " "this " "file " "directly!\n\n*/\n");
+
printf("/* Copyright (C) 2001-2004 MySQL AB\n\
This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
and you are welcome to modify and redistribute it under the GPL license\n\
\n*/\n\n");
- printf("/* This code is generated by gen_lex_hash.cc that seeks for\
- a perfect\nhash function */\n\n");
+ printf("/* Do " "not " "edit " "this " "file! This is generated by "
+ "gen_lex_hash.cc\nthat seeks for a perfect hash function */\n\n");
printf("#include \"lex.h\"\n\n");
calc_length();
@@ -468,6 +471,12 @@ static inline SYMBOL *get_hash_symbol(const char *s,\n\
{\n\
register uchar *hash_map;\n\
register const char *cur_str= s;\n\
+\n\
+ if (len == 0) {\n\
+ DBUG_PRINT(\"warning\", (\"get_hash_symbol() received a request for a zero-length symbol, which is probably a mistake.\"));\
+ return(NULL);\n\
+ }\
+\n\
if (function){\n\
if (len>sql_functions_max_len) return 0;\n\
hash_map= sql_functions_map;\n\
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 7d4dca15608..479db7b5b99 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1042,6 +1042,8 @@ int MYSQLlex(void *arg, void *yythd)
if (c == '.')
lex->next_state=MY_LEX_IDENT_SEP;
length= (uint) (lex->ptr - lex->tok_start)-1;
+ if (length == 0)
+ return(ABORT_SYM); // Names must be nonempty.
if ((tokval= find_keyword(lex,length,0)))
{
yyUnget(); // Put back 'c'