mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-10763: Wrong result - server does not return NULL values from default list partition after ALTER table
Fixed partition pruning for NULL value.
This commit is contained in:
@ -1204,3 +1204,32 @@ where a>=10 and (a <=10 and b <=30);
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1,p2,p3 ALL NULL NULL NULL NULL 3 Using where
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-10763: Wrong result - server does not return NULL values
|
||||
# from default list partition after ALTER table
|
||||
#
|
||||
create table t1 (i int) partition by list (i) ( partition p1 default);
|
||||
insert into t1 values (null);
|
||||
select * from t1 where i is null;
|
||||
i
|
||||
NULL
|
||||
alter table t1 partition by list (i) ( partition p1 values in (1), partition p2 default);
|
||||
select * from t1 where i is null;
|
||||
i
|
||||
NULL
|
||||
explain partitions
|
||||
select * from t1 where i is null;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2 system NULL NULL NULL NULL 1
|
||||
alter table t1 partition by list (i) (
|
||||
partition p0 values in (NULL),
|
||||
partition p1 values in (1),
|
||||
partition p2 default);
|
||||
select * from t1 where i is null;
|
||||
i
|
||||
NULL
|
||||
explain partitions
|
||||
select * from t1 where i is null;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0 system NULL NULL NULL NULL 1
|
||||
drop table t1;
|
||||
|
@ -498,5 +498,25 @@ insert into t1 values
|
||||
explain partitions
|
||||
select * from t1
|
||||
where a>=10 and (a <=10 and b <=30);
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-10763: Wrong result - server does not return NULL values
|
||||
--echo # from default list partition after ALTER table
|
||||
--echo #
|
||||
create table t1 (i int) partition by list (i) ( partition p1 default);
|
||||
insert into t1 values (null);
|
||||
select * from t1 where i is null;
|
||||
alter table t1 partition by list (i) ( partition p1 values in (1), partition p2 default);
|
||||
select * from t1 where i is null;
|
||||
explain partitions
|
||||
select * from t1 where i is null;
|
||||
alter table t1 partition by list (i) (
|
||||
partition p0 values in (NULL),
|
||||
partition p1 values in (1),
|
||||
partition p2 default);
|
||||
select * from t1 where i is null;
|
||||
explain partitions
|
||||
select * from t1 where i is null;
|
||||
|
||||
drop table t1;
|
||||
|
@ -7960,8 +7960,19 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info,
|
||||
/* col = x and F(x) = NULL -> only search NULL partition */
|
||||
part_iter->part_nums.cur= part_iter->part_nums.start= 0;
|
||||
part_iter->part_nums.end= 0;
|
||||
part_iter->ret_null_part= part_iter->ret_null_part_orig= TRUE;
|
||||
DBUG_RETURN(1);
|
||||
/*
|
||||
if NULL partition exists:
|
||||
for RANGE it is the first partition (always exists);
|
||||
for LIST should be indicator that it is present
|
||||
*/
|
||||
if (part_info->part_type == RANGE_PARTITION ||
|
||||
part_info->has_null_value)
|
||||
{
|
||||
part_iter->ret_null_part= part_iter->ret_null_part_orig= TRUE;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
// If no NULL partition look up in DEFAULT or there is no such value
|
||||
goto not_found;
|
||||
}
|
||||
part_iter->part_nums.cur= part_iter->part_nums.start;
|
||||
if (check_zero_dates && !part_info->part_expr->null_value)
|
||||
|
Reference in New Issue
Block a user