Commit e21b150a authored by mattiasj@mattiasj-laptop.(none)'s avatar mattiasj@mattiasj-laptop.(none)

Merge mattiasj-laptop.(none):/home/mattiasj/clones/mysql-5.1-engines

into  mattiasj-laptop.(none):/home/mattiasj/clones/mysql-5.1-bug30878
parents 3f33002f 2d71933f
drop table if exists t1; drop table if exists t1;
CREATE TABLE t1 (
d DATE NOT NULL
)
PARTITION BY RANGE( YEAR(d) ) (
PARTITION p0 VALUES LESS THAN (1960),
PARTITION p1 VALUES LESS THAN (1970),
PARTITION p2 VALUES LESS THAN (1980),
PARTITION p3 VALUES LESS THAN (1990)
);
ALTER TABLE t1 ADD PARTITION (
PARTITION `p5` VALUES LESS THAN (2010)
COMMENT 'APSTART \' APEND'
);
SELECT * FROM t1 LIMIT 1;
d
DROP TABLE t1;
create table t1 (id int auto_increment, s1 int, primary key (id));
insert into t1 values (null,1);
insert into t1 values (null,6);
select * from t1;
id s1
1 1
2 6
alter table t1 partition by range (id) (
partition p0 values less than (3),
partition p1 values less than maxvalue
);
drop table t1;
create table t1 (a int) create table t1 (a int)
partition by key(a) partition by key(a)
partitions 0.2+e1; partitions 0.2+e1;
......
...@@ -9,6 +9,50 @@ ...@@ -9,6 +9,50 @@
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings
#
# Bug #30695: An apostrophe ' in the comment of the ADD PARTITION causes the Server to crash.
#
# To verify the fix for crashing (on unix-type OS)
# uncomment the exec and error rows!
CREATE TABLE t1 (
d DATE NOT NULL
)
PARTITION BY RANGE( YEAR(d) ) (
PARTITION p0 VALUES LESS THAN (1960),
PARTITION p1 VALUES LESS THAN (1970),
PARTITION p2 VALUES LESS THAN (1980),
PARTITION p3 VALUES LESS THAN (1990)
);
ALTER TABLE t1 ADD PARTITION (
PARTITION `p5` VALUES LESS THAN (2010)
COMMENT 'APSTART \' APEND'
);
#--exec sed 's/APSTART \\/APSTART /' var/master-data/test/t1.frm > tmpt1.frm && mv tmpt1.frm var/master-data/test/t1.frm
#--error 1064
SELECT * FROM t1 LIMIT 1;
DROP TABLE t1;
#
# Bug 30878: crashing when alter an auto_increment non partitioned
# table to partitioned
create table t1 (id int auto_increment, s1 int, primary key (id));
insert into t1 values (null,1);
insert into t1 values (null,6);
select * from t1;
alter table t1 partition by range (id) (
partition p0 values less than (3),
partition p1 values less than maxvalue
);
drop table t1;
# #
# Bug 15890: Strange number of partitions accepted # Bug 15890: Strange number of partitions accepted
# #
......
...@@ -2678,7 +2678,8 @@ int ha_partition::write_row(uchar * buf) ...@@ -2678,7 +2678,8 @@ int ha_partition::write_row(uchar * buf)
uint32 part_id; uint32 part_id;
int error; int error;
longlong func_value; longlong func_value;
bool autoincrement_lock= false; bool autoincrement_lock= FALSE;
my_bitmap_map *old_map;
#ifdef NOT_NEEDED #ifdef NOT_NEEDED
uchar *rec0= m_rec0; uchar *rec0= m_rec0;
#endif #endif
...@@ -2705,8 +2706,17 @@ int ha_partition::write_row(uchar * buf) ...@@ -2705,8 +2706,17 @@ int ha_partition::write_row(uchar * buf)
use autoincrement_lock variable to avoid unnecessary locks. use autoincrement_lock variable to avoid unnecessary locks.
Probably not an ideal solution. Probably not an ideal solution.
*/ */
autoincrement_lock= true; if (table_share->tmp_table == NO_TMP_TABLE)
pthread_mutex_lock(&table_share->mutex); {
/*
Bug#30878 crash when alter table from non partitioned table
to partitioned.
Checking if tmp table then there is no need to lock,
and the table_share->mutex may not be initialised.
*/
autoincrement_lock= TRUE;
pthread_mutex_lock(&table_share->mutex);
}
error= update_auto_increment(); error= update_auto_increment();
/* /*
...@@ -2715,10 +2725,10 @@ int ha_partition::write_row(uchar * buf) ...@@ -2715,10 +2725,10 @@ int ha_partition::write_row(uchar * buf)
the correct partition. We must check and fail if neccessary. the correct partition. We must check and fail if neccessary.
*/ */
if (error) if (error)
DBUG_RETURN(error); goto exit;
} }
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); old_map= dbug_tmp_use_all_columns(table, table->read_set);
#ifdef NOT_NEEDED #ifdef NOT_NEEDED
if (likely(buf == rec0)) if (likely(buf == rec0))
#endif #endif
......
...@@ -1856,6 +1856,20 @@ static int add_uint(File fptr, ulonglong number) ...@@ -1856,6 +1856,20 @@ static int add_uint(File fptr, ulonglong number)
return add_string(fptr, buff); return add_string(fptr, buff);
} }
/*
Must escape strings in partitioned tables frm-files,
parsing it later with mysql_unpack_partition will fail otherwise.
*/
static int add_quoted_string(File fptr, const char *quotestr)
{
String orgstr(quotestr, system_charset_info);
String escapedstr;
int err= add_string(fptr, "'");
err+= append_escaped(&escapedstr, &orgstr);
err+= add_string(fptr, escapedstr.c_ptr());
return err + add_string(fptr, "'");
}
static int add_keyword_string(File fptr, const char *keyword, static int add_keyword_string(File fptr, const char *keyword,
bool should_use_quotes, bool should_use_quotes,
const char *keystr) const char *keystr)
...@@ -1866,10 +1880,9 @@ static int add_keyword_string(File fptr, const char *keyword, ...@@ -1866,10 +1880,9 @@ static int add_keyword_string(File fptr, const char *keyword,
err+= add_equal(fptr); err+= add_equal(fptr);
err+= add_space(fptr); err+= add_space(fptr);
if (should_use_quotes) if (should_use_quotes)
err+= add_string(fptr, "'"); err+= add_quoted_string(fptr, keystr);
err+= add_string(fptr, keystr); else
if (should_use_quotes) err+= add_string(fptr, keystr);
err+= add_string(fptr, "'");
return err + add_space(fptr); return err + add_space(fptr);
} }
......
...@@ -1782,7 +1782,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, ...@@ -1782,7 +1782,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
outparam, is_create_table, outparam, is_create_table,
share->default_part_db_type, share->default_part_db_type,
&work_part_info_used); &work_part_info_used);
outparam->part_info->is_auto_partitioned= share->auto_partitioned; if (!tmp)
outparam->part_info->is_auto_partitioned= share->auto_partitioned;
DBUG_PRINT("info", ("autopartitioned: %u", share->auto_partitioned)); DBUG_PRINT("info", ("autopartitioned: %u", share->auto_partitioned));
/* we should perform the fix_partition_func in either local or /* we should perform the fix_partition_func in either local or
caller's arena depending on work_part_info_used value caller's arena depending on work_part_info_used value
......
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