Skip to content

Commit a653fca

Browse files
author
Sreeharsha Ramanavarapu
committed
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.
1 parent fe5df42 commit a653fca

File tree

1 file changed

+25
-34
lines changed

1 file changed

+25
-34
lines changed

sql/sql_yacc.yy

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -4670,56 +4670,47 @@ opt_part_values:
46704670
{
46714671
LEX *lex= Lex;
46724672
partition_info *part_info= lex->part_info;
4673-
if (! lex->is_partition_management())
4673+
if (part_info->part_type == NOT_A_PARTITION)
4674+
part_info->part_type= HASH_PARTITION;
4675+
else if (part_info->part_type == RANGE_PARTITION)
46744676
{
4675-
if (part_info->part_type == RANGE_PARTITION)
4676-
{
4677-
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
4678-
"RANGE", "LESS THAN");
4679-
MYSQL_YYABORT;
4680-
}
4681-
if (part_info->part_type == LIST_PARTITION)
4682-
{
4683-
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
4684-
"LIST", "IN");
4685-
MYSQL_YYABORT;
4686-
}
4677+
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
4678+
"RANGE", "LESS THAN");
4679+
MYSQL_YYABORT;
4680+
}
4681+
else if (part_info->part_type == LIST_PARTITION)
4682+
{
4683+
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
4684+
"LIST", "IN");
4685+
MYSQL_YYABORT;
46874686
}
4688-
else
4689-
part_info->part_type= HASH_PARTITION;
46904687
}
46914688
| VALUES LESS_SYM THAN_SYM
46924689
{
46934690
LEX *lex= Lex;
46944691
partition_info *part_info= lex->part_info;
4695-
if (! lex->is_partition_management())
4692+
if (part_info->part_type == NOT_A_PARTITION)
4693+
part_info->part_type= RANGE_PARTITION;
4694+
else if (part_info->part_type != RANGE_PARTITION)
46964695
{
4697-
if (part_info->part_type != RANGE_PARTITION)
4698-
{
4699-
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
4700-
"RANGE", "LESS THAN");
4701-
MYSQL_YYABORT;
4702-
}
4696+
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
4697+
"RANGE", "LESS THAN");
4698+
MYSQL_YYABORT;
47034699
}
4704-
else
4705-
part_info->part_type= RANGE_PARTITION;
47064700
}
47074701
part_func_max {}
47084702
| VALUES IN_SYM
47094703
{
47104704
LEX *lex= Lex;
47114705
partition_info *part_info= lex->part_info;
4712-
if (! lex->is_partition_management())
4706+
if (part_info->part_type == NOT_A_PARTITION)
4707+
part_info->part_type= LIST_PARTITION;
4708+
else if (part_info->part_type != LIST_PARTITION)
47134709
{
4714-
if (part_info->part_type != LIST_PARTITION)
4715-
{
4716-
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
4717-
"LIST", "IN");
4718-
MYSQL_YYABORT;
4719-
}
4710+
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
4711+
"LIST", "IN");
4712+
MYSQL_YYABORT;
47204713
}
4721-
else
4722-
part_info->part_type= LIST_PARTITION;
47234714
}
47244715
part_values_in {}
47254716
;

0 commit comments

Comments
 (0)