Commit b21f2d08 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Don't give warnings for empty statements with comments

parent d76fcdc5
......@@ -46890,6 +46890,9 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.49
@itemize @bullet
@item
Don't give warning for statement that is only a comment; This is needed for
@code{mysqldump --disable-keys} to work.
@item
Fixed unlikely caching bug when doing a join without keys. In this case
the last used field for a table always returned @code{NULL}.
@item
......@@ -5,7 +5,7 @@
select 1+2/*hello*/+3;
select 1 /* long
multi line comment */;
!$1065 /* empty query */;
!$1065 ;
select 1 /*!32301 +1 */;
select 1 /*!52301 +1 */;
select 1--1;
......@@ -15,3 +15,4 @@ select 1 --2
+1;
select 1 # The rest of the row will be ignored
;
/* line with only comment */;
......@@ -158,7 +158,8 @@ void kill_one_thread(THD *thd, ulong id);
#define OPTION_LOW_PRIORITY_UPDATES 8192
#define OPTION_WARNINGS 16384
#define OPTION_AUTO_IS_NULL 32768
#define OPTION_SAFE_UPDATES 65536L*2
#define OPTION_FOUND_COMMENT 65536L
#define OPTION_SAFE_UPDATES OPTION_FOUND_COMMENT*2
#define OPTION_BUFFER_RESULT OPTION_SAFE_UPDATES*2
#define OPTION_BIN_LOG OPTION_BUFFER_RESULT*2
#define OPTION_NOT_AUTO_COMMIT OPTION_BIN_LOG*2
......
......@@ -734,6 +734,7 @@ int yylex(void *arg)
return(TEXT_STRING);
case STATE_COMMENT: // Comment
lex->options|= OPTION_FOUND_COMMENT;
while ((c = yyGet()) != '\n' && c) ;
yyUnget(); // Safety against eof
state = STATE_START; // Try again
......@@ -745,6 +746,7 @@ int yylex(void *arg)
break;
}
yySkip(); // Skip '*'
lex->options|= OPTION_FOUND_COMMENT;
if (yyPeek() == '!') // MySQL command in comment
{
ulong version=MYSQL_VERSION_ID;
......
......@@ -53,7 +53,7 @@ enum enum_sql_command {
SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_CHANGE_MASTER,
SQLCOM_RENAME_TABLE, SQLCOM_BACKUP_TABLE, SQLCOM_RESTORE_TABLE,
SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_SHOW_BINLOGS,
SQLCOM_SHOW_OPEN_TABLES, SQLCOM_DO,
SQLCOM_SHOW_OPEN_TABLES, SQLCOM_DO, SQLCOM_EMPTY_QUERY,
SQLCOM_END
};
......
......@@ -1181,6 +1181,10 @@ mysql_execute_command(void)
res=mysql_do(thd, *lex->insert_list);
break;
case SQLCOM_EMPTY_QUERY:
send_ok(&thd->net);
break;
case SQLCOM_PURGE:
{
if (check_process_priv(thd))
......
......@@ -544,10 +544,18 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
query:
END_OF_INPUT
{
if (!current_thd->bootstrap)
THD *thd=current_thd;
if (!thd->bootstrap &&
(!(thd->lex.options & OPTION_FOUND_COMMENT)))
{
send_error(&current_thd->net,ER_EMPTY_QUERY);
YYABORT;
}
else
{
thd->lex.sql_command = SQLCOM_EMPTY_QUERY;
}
}
| verb_clause END_OF_INPUT {}
verb_clause:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment