Commit 7d6d808b authored by sergefp@mysql.com's avatar sergefp@mysql.com

BUG#32772: partition crash 1: enum column

The bug was that for ordered index scans, ha_partition::index_init() did
not put index columns into table->read_set if the underlying storage 
engine did not have HA_PARTIAL_COLUMN_READ flag. 
This was causing assertion failure when handle_ordered_index_scan() tried
to sort the records according to index order.

Fixed by making ha_partition::index_init() put index columns into table->read_set
for all ordered scans. 
parent 0f3db011
......@@ -1290,4 +1290,17 @@ create table t1
partition by key(s1) partitions 3;
insert into t1 values (null,null);
drop table t1;
create table t1 (
c0 int,
c1 bigint,
c2 set('sweet'),
key (c2,c1,c0),
key(c0)
) engine=myisam partition by hash (month(c0)) partitions 5;
insert ignore into t1 set c0 = -6502262, c1 = 3992917, c2 = 35019;
insert ignore into t1 set c0 = 241221, c1 = -6862346, c2 = 56644;
select c1 from t1 group by (select c0 from t1 limit 1);
c1
-6862346
drop table t1;
End of 5.1 tests
......@@ -1531,4 +1531,24 @@ while ($cnt)
--enable_query_log
drop table t1;
#
# BUG#32272: partition crash 1: enum column
#
create table t1 (
c0 int,
c1 bigint,
c2 set('sweet'),
key (c2,c1,c0),
key(c0)
) engine=myisam partition by hash (month(c0)) partitions 5;
--disable_warnings
insert ignore into t1 set c0 = -6502262, c1 = 3992917, c2 = 35019;
insert ignore into t1 set c0 = 241221, c1 = -6862346, c2 = 56644;
--enable_warnings
# This must not fail assert:
select c1 from t1 group by (select c0 from t1 limit 1);
drop table t1;
--echo End of 5.1 tests
......@@ -3413,14 +3413,17 @@ int ha_partition::index_init(uint inx, bool sorted)
*/
if (m_lock_type == F_WRLCK)
bitmap_union(table->read_set, &m_part_info->full_part_field_set);
else if (sorted && m_table_flags & HA_PARTIAL_COLUMN_READ)
else if (sorted)
{
/*
An ordered scan is requested and necessary fields aren't in read_set.
This may happen e.g. with SELECT COUNT(*) FROM t1. We must ensure
that all fields of current key are included into read_set, as
partitioning requires them for sorting
(see ha_partition::handle_ordered_index_scan).
An ordered scan is requested. We must make sure all fields of the
used index are in the read set, as partitioning requires them for
sorting (see ha_partition::handle_ordered_index_scan).
The SQL layer may request an ordered index scan without having index
fields in the read set when
- it needs to do an ordered scan over an index prefix.
- it evaluates ORDER BY with SELECT COUNT(*) FROM t1.
TODO: handle COUNT(*) queries via unordered scan.
*/
......
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