Bug #26791931: INCORRECT BEHAVIOR IN ALTER TABLE REORGANIZE

               PARTITION

Issue:
------
ALTER TABLE REORGANIZE PARTITION .... can result in
incorrect behavior if any partition other than the last
one misses the "VALUES LESS THAN..." part of the syntax.

Root cause:
-----------
Currently ALTER TABLE with changes to partitions is handled
incorrectly by the parser.

Fix:
----
The if condition which handles partition management
differently for ALTER TABLE in the parser should be removed.
 Change the code to handle the case in the parser.
parent fe5df42a
/* /*
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -4670,57 +4670,48 @@ opt_part_values: ...@@ -4670,57 +4670,48 @@ opt_part_values:
{ {
LEX *lex= Lex; LEX *lex= Lex;
partition_info *part_info= lex->part_info; partition_info *part_info= lex->part_info;
if (! lex->is_partition_management()) if (part_info->part_type == NOT_A_PARTITION)
{ part_info->part_type= HASH_PARTITION;
if (part_info->part_type == RANGE_PARTITION) else if (part_info->part_type == RANGE_PARTITION)
{ {
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
"RANGE", "LESS THAN"); "RANGE", "LESS THAN");
MYSQL_YYABORT; MYSQL_YYABORT;
} }
if (part_info->part_type == LIST_PARTITION) else if (part_info->part_type == LIST_PARTITION)
{ {
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
"LIST", "IN"); "LIST", "IN");
MYSQL_YYABORT; MYSQL_YYABORT;
} }
} }
else
part_info->part_type= HASH_PARTITION;
}
| VALUES LESS_SYM THAN_SYM | VALUES LESS_SYM THAN_SYM
{ {
LEX *lex= Lex; LEX *lex= Lex;
partition_info *part_info= lex->part_info; partition_info *part_info= lex->part_info;
if (! lex->is_partition_management()) if (part_info->part_type == NOT_A_PARTITION)
{ part_info->part_type= RANGE_PARTITION;
if (part_info->part_type != RANGE_PARTITION) else if (part_info->part_type != RANGE_PARTITION)
{ {
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0), my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
"RANGE", "LESS THAN"); "RANGE", "LESS THAN");
MYSQL_YYABORT; MYSQL_YYABORT;
} }
} }
else
part_info->part_type= RANGE_PARTITION;
}
part_func_max {} part_func_max {}
| VALUES IN_SYM | VALUES IN_SYM
{ {
LEX *lex= Lex; LEX *lex= Lex;
partition_info *part_info= lex->part_info; partition_info *part_info= lex->part_info;
if (! lex->is_partition_management()) if (part_info->part_type == NOT_A_PARTITION)
{ part_info->part_type= LIST_PARTITION;
if (part_info->part_type != LIST_PARTITION) else if (part_info->part_type != LIST_PARTITION)
{ {
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0), my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
"LIST", "IN"); "LIST", "IN");
MYSQL_YYABORT; MYSQL_YYABORT;
} }
} }
else
part_info->part_type= LIST_PARTITION;
}
part_values_in {} part_values_in {}
; ;
......
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