Commit 557a6832 authored by reggie@linux.site's avatar reggie@linux.site

Bug# 15968 - Partitions: crash when insert with f1 = -1 into partition by hash(f1)

fixed
parent dca852ff
...@@ -64,3 +64,9 @@ primary key(a,b)) ...@@ -64,3 +64,9 @@ primary key(a,b))
partition by key (a) partition by key (a)
(partition x1); (partition x1);
drop table t1; drop table t1;
CREATE TABLE t1 (f1 INTEGER, f2 char(20)) ENGINE = 'MYISAM' PARTITION BY HASH(f1) PARTITIONS 2;
INSERT INTO t1 SET f1 = 0 - 1, f2 = '#######';
select * from t1;
f1 f2
-1 #######
drop table t1;
...@@ -75,3 +75,12 @@ partition by key (a) ...@@ -75,3 +75,12 @@ partition by key (a)
(partition x1); (partition x1);
drop table t1; drop table t1;
#
# Bug# 15968 - crash when INSERT with f1 = -1 into partition by hash(f1)
#
CREATE TABLE t1 (f1 INTEGER, f2 char(20)) ENGINE = 'MYISAM' PARTITION BY HASH(f1) PARTITIONS 2;
INSERT INTO t1 SET f1 = 0 - 1, f2 = '#######';
select * from t1;
drop table t1;
...@@ -2327,7 +2327,8 @@ static uint32 get_part_id_hash(uint no_parts, ...@@ -2327,7 +2327,8 @@ static uint32 get_part_id_hash(uint no_parts,
Item *part_expr) Item *part_expr)
{ {
DBUG_ENTER("get_part_id_hash"); DBUG_ENTER("get_part_id_hash");
DBUG_RETURN((uint32)(part_expr->val_int() % no_parts)); longlong int_hash_id= part_expr->val_int() % no_parts;
DBUG_RETURN(int_hash_id < 0 ? -int_hash_id : int_hash_id);
} }
......
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