summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2006-02-16 08:15:36 -0800
committerunknown <jimw@mysql.com>2006-02-16 08:15:36 -0800
commit0deff29c05c1d77453470ef5578204f69aff110f (patch)
treeb3b0f8b24657de41c9fe7ebd9edba9b16ee35408
parenta7da76f24e5e670b44d01bd7f4b47f592741bf24 (diff)
downloadmariadb-git-0deff29c05c1d77453470ef5578204f69aff110f.tar.gz
Bug #17169: Partitions: out of memory if add partition and unique.
When creating a new partition, a bogus memory allocation problem was reported. mysql-test/r/partition.result: Add new results mysql-test/t/partition.test: Add new regression test sql/sql_table.cc: Fix inverted tests that caused mysql_copy_key_list() to not work at all, remove a forward declaration for a function that does not exist, and fix a debug message.
-rw-r--r--mysql-test/r/partition.result3
-rw-r--r--mysql-test/t/partition.test7
-rw-r--r--sql/sql_table.cc23
3 files changed, 19 insertions, 14 deletions
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index e2601937da6..2864afab8b2 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -312,4 +312,7 @@ partition by hash(f_int1) partitions 2;
insert into t1 values (1,1),(2,2);
replace into t1 values (1,1),(2,2);
drop table t1;
+create table t1 (s1 int, unique (s1)) partition by list (s1) (partition x1 VALUES in (10), partition x2 values in (20));
+alter table t1 add partition (partition x3 values in (30));
+drop table t1;
End of 5.1 tests
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index ded54ad28b4..4760219c911 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -401,4 +401,11 @@ insert into t1 values (1,1),(2,2);
replace into t1 values (1,1),(2,2);
drop table t1;
+#
+# Bug #17169: Partitions: out of memory if add partition and unique
+#
+create table t1 (s1 int, unique (s1)) partition by list (s1) (partition x1 VALUES in (10), partition x2 values in (20));
+alter table t1 add partition (partition x3 values in (30));
+drop table t1;
+
--echo End of 5.1 tests
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 92ade0ff43b..96f82463e25 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -50,11 +50,6 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
handler *file, KEY **key_info_buffer,
uint *key_count, int select_field_count);
-static int mysql_copy_create_lists(List<create_field> *orig_create_list,
- List<Key> *orig_key,
- List<create_field> *new_create_list,
- List<Key> *new_key);
-
#define MYSQL50_TABLE_NAME_PREFIX "#mysql50#"
#define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9
@@ -164,8 +159,7 @@ uint build_tmptable_filename(THD* thd, char *buff, size_t bufflen)
*/
static int mysql_copy_create_list(List<create_field> *orig_create_list,
-
- List<create_field> *new_create_list)
+ List<create_field> *new_create_list)
{
List_iterator<create_field> prep_field_it(*orig_create_list);
create_field *prep_field;
@@ -205,7 +199,7 @@ static int mysql_copy_key_list(List<Key> *orig_key,
{
List_iterator<Key> prep_key_it(*orig_key);
Key *prep_key;
- DBUG_ENTER("mysql_copy_create_lists");
+ DBUG_ENTER("mysql_copy_key_list");
while ((prep_key= prep_key_it++))
{
@@ -217,7 +211,8 @@ static int mysql_copy_key_list(List<Key> *orig_key,
while ((prep_col= prep_col_it++))
{
key_part_spec *prep_key_part;
- if (prep_key_part= new key_part_spec(*prep_col))
+
+ if (!(prep_key_part= new key_part_spec(*prep_col)))
{
mem_alloc_error(sizeof(key_part_spec));
DBUG_RETURN(TRUE);
@@ -228,11 +223,11 @@ static int mysql_copy_key_list(List<Key> *orig_key,
DBUG_RETURN(TRUE);
}
}
- if ((temp_key= new Key(prep_key->type, prep_key->name,
- prep_key->algorithm,
- prep_key->generated,
- prep_columns,
- prep_key->parser_name)))
+ if (!(temp_key= new Key(prep_key->type, prep_key->name,
+ prep_key->algorithm,
+ prep_key->generated,
+ prep_columns,
+ prep_key->parser_name)))
{
mem_alloc_error(sizeof(Key));
DBUG_RETURN(TRUE);