Skip to content

Commit 359f102

Browse files
author
Debarun Banerjee
committed
BUG#16613004 PARTITIONING DDL, CRASH IN FIELD_VARSTRING::CMP_MAX
Problem : --------- The specific issue reported in this bug is with range/list column value that is allocated and initialized by evaluating partition expression(item tree) during execution. After evaluation the range list value is marked fixed [part_column_list_val]. During next execution, we don't re-evaluate the expression and use the old value since it is marked fixed. Solution : ---------- One way to solve the issue is to mark all column values as not fixed during clone so that the expression is always re-evaluated once we attempt partition_info::fix_column_value_functions() after cloning the part_info object during execution of DDL on partitioned table. Reviewed-by: Jimmy Yang <[email protected]> Reviewed-by: Mattias Jonsson <[email protected]> RB: 9424
1 parent 2ac01ca commit 359f102

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

sql/partition_info.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "ha_partition.h"
3232

3333

34-
partition_info *partition_info::get_clone()
34+
partition_info *partition_info::get_clone(bool reset /* = false */)
3535
{
3636
if (!this)
3737
return 0;
@@ -57,6 +57,26 @@ partition_info *partition_info::get_clone()
5757
return NULL;
5858
}
5959
memcpy(part_clone, part, sizeof(partition_element));
60+
61+
/*
62+
Mark that RANGE and LIST values needs to be fixed so that we don't
63+
use old values. fix_column_value_functions would evaluate the values
64+
from Item expression.
65+
*/
66+
if (reset)
67+
{
68+
clone->defined_max_value = false;
69+
List_iterator<part_elem_value> list_it(part_clone->list_val_list);
70+
while (part_elem_value *list_value= list_it++)
71+
{
72+
part_column_list_val *col_val= list_value->col_val_array;
73+
for (uint i= 0; i < num_columns; col_val++, i++)
74+
{
75+
col_val->fixed= 0;
76+
}
77+
}
78+
}
79+
6080
part_clone->subpartitions.empty();
6181
while ((subpart= (subpart_it++)))
6282
{

sql/partition_info.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef PARTITION_INFO_INCLUDED
22
#define PARTITION_INFO_INCLUDED
33

4-
/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
4+
/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
55
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -265,7 +265,7 @@ class partition_info : public Sql_alloc
265265
}
266266
~partition_info() {}
267267

268-
partition_info *get_clone();
268+
partition_info *get_clone(bool reset = false);
269269
/* Answers the question if subpartitioning is used for a certain table */
270270
bool is_sub_partitioned()
271271
{

sql/sql_parse.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -2428,7 +2428,7 @@ case SQLCOM_PREPARE:
24282428
#ifdef WITH_PARTITION_STORAGE_ENGINE
24292429
{
24302430
partition_info *part_info= thd->lex->part_info;
2431-
if (part_info && !(part_info= thd->lex->part_info->get_clone()))
2431+
if (part_info && !(part_info= thd->lex->part_info->get_clone(true)))
24322432
{
24332433
res= -1;
24342434
goto end_with_restore_list;

sql/sql_partition.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -4718,7 +4718,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
47184718
thd->work_part_info= thd->lex->part_info;
47194719

47204720
if (thd->work_part_info &&
4721-
!(thd->work_part_info= thd->lex->part_info->get_clone()))
4721+
!(thd->work_part_info= thd->lex->part_info->get_clone(true)))
47224722
DBUG_RETURN(TRUE);
47234723

47244724
/* ALTER_ADMIN_PARTITION is handled in mysql_admin_table */

0 commit comments

Comments
 (0)