diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 8652ed89a65..4c795abe986 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -2834,3 +2834,4 @@ a 3 4 DROP TABLE t1,t2,t3; +purge master logs before (select adddate(current_timestamp(), interval -4 day)); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 3d21456ee45..cbc7a3afb5f 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1814,4 +1814,10 @@ SELECT * FROM t1 DROP TABLE t1,t2,t3; +# +# BUG #10308: purge log with subselect +# + +purge master logs before (select adddate(current_timestamp(), interval -4 day)); + # End of 4.1 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2ce419086a0..82f9c5a288f 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4715,7 +4715,10 @@ purge_option: } | BEFORE_SYM expr { - if ($2->check_cols(1) || $2->fix_fields(Lex->thd, 0, &$2)) + if (!$2) + /* Can only be an out of memory situation, no need for a message */ + YYABORT; + if ($2->fix_fields(Lex->thd, 0, &$2) || $2->check_cols(1)) { net_printf(Lex->thd, ER_WRONG_ARGUMENTS, "PURGE LOGS BEFORE"); YYABORT;