diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index 59e29046d90aea81daf2afa5ced41e9f728bd420..80942c861fe66e71c2789bd614e1335fde37f416 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -422,4 +422,10 @@ partition_name	partition_description	table_rows
 x123	11,12	1
 x234	NULL,1	1
 drop table t1;
+create table t1 (a int)
+partition by list (a)
+(partition p0 values in (1));
+alter table t1 rebuild partition;
+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
+drop table t1;
 End of 5.1 tests
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index f22edb54756892ef227a16549fda2ac5a0e7d2a6..8fc464908560c2cda6fab08c0ac19f3d4ed763cc 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -540,4 +540,16 @@ select partition_name, partition_description, table_rows
 from information_schema.partitions where table_schema ='test';
 drop table t1;
 
+#
+# BUG 17947 Crash with REBUILD PARTITION
+#
+create table t1 (a int)
+partition by list (a)
+(partition p0 values in (1));
+
+--error 1064
+alter table t1 rebuild partition;
+
+drop table t1;
+
 --echo End of 5.1 tests
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index a93d10d71734c19a11901d7382c4c622805b537d..47852212b84c35420b477f6ef515463e9ffd4f93 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -4953,7 +4953,7 @@ alter_commands:
         ;
 
 all_or_alt_part_name_list:
-        | ALL
+        ALL
         {
 	  Lex->alter_info.flags|= ALTER_ALL_PARTITION;
         }