Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
cef00484
Commit
cef00484
authored
Jul 20, 2006
by
mikael/pappa@dator5.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG20733: Bug in partition pruning with zerofill field
Problem was with handling NULL values in ranges
parent
bae61f20
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
521 additions
and
1 deletion
+521
-1
mysql-test/r/partition_hash.result
mysql-test/r/partition_hash.result
+84
-0
mysql-test/r/partition_list.result
mysql-test/r/partition_list.result
+94
-0
mysql-test/r/partition_pruning.result
mysql-test/r/partition_pruning.result
+78
-0
mysql-test/r/partition_range.result
mysql-test/r/partition_range.result
+78
-0
mysql-test/t/partition_hash.test
mysql-test/t/partition_hash.test
+30
-0
mysql-test/t/partition_list.test
mysql-test/t/partition_list.test
+44
-0
mysql-test/t/partition_pruning.test
mysql-test/t/partition_pruning.test
+52
-0
mysql-test/t/partition_range.test
mysql-test/t/partition_range.test
+44
-0
sql/opt_range.cc
sql/opt_range.cc
+6
-1
sql/sql_partition.cc
sql/sql_partition.cc
+11
-0
No files found.
mysql-test/r/partition_hash.result
View file @
cef00484
drop table if exists t1;
drop table if exists t1;
create table t1 (a int unsigned)
partition by hash(a div 2)
partitions 4;
insert into t1 values (null),(0),(1),(2),(3),(4),(5),(6),(7);
select * from t1 where a < 0;
a
select * from t1 where a is null or (a >= 5 and a <= 7);
a
NULL
5
6
7
select * from t1 where a is null;
a
NULL
select * from t1 where a is not null;
a
0
1
2
3
4
5
6
7
select * from t1 where a >= 1 and a < 3;
a
1
2
select * from t1 where a >= 3 and a <= 5;
a
3
4
5
select * from t1 where a > 2 and a < 4;
a
3
select * from t1 where a > 3 and a <= 6;
a
4
5
6
select * from t1 where a > 5;
a
6
7
select * from t1 where a >= 1 and a <= 5;
a
1
2
3
4
5
explain partitions select * from t1 where a < 0;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a is null or (a >= 5 and a <= 7);
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p2,p3 ALL NULL NULL NULL NULL 7 Using where
explain partitions select * from t1 where a is null;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t1 where a is not null;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a >= 1 and a < 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 5 Using where
explain partitions select * from t1 where a >= 3 and a <= 5;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,p2 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a > 2 and a < 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a > 3 and a <= 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a > 5;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a >= 1 and a <= 5;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where
drop table t1;
CREATE TABLE t1 (
CREATE TABLE t1 (
a int not null,
a int not null,
b int not null,
b int not null,
...
...
mysql-test/r/partition_list.result
View file @
cef00484
drop table if exists t1;
drop table if exists t1;
create table t1 (a int unsigned)
partition by list (a)
(partition p0 values in (0),
partition p1 values in (1),
partition pnull values in (null),
partition p2 values in (2));
insert into t1 values (null),(0),(1),(2);
select * from t1 where a < 2;
a
0
1
select * from t1 where a <= 0;
a
0
select * from t1 where a < 1;
a
0
select * from t1 where a > 0;
a
1
2
select * from t1 where a > 1;
a
2
select * from t1 where a >= 0;
a
0
1
2
select * from t1 where a >= 1;
a
1
2
select * from t1 where a is null;
a
NULL
select * from t1 where a is not null;
a
0
1
2
select * from t1 where a is null or a > 0;
a
1
NULL
2
drop table t1;
create table t1 (a int unsigned, b int)
partition by list (a)
subpartition by hash (b)
subpartitions 2
(partition p0 values in (0),
partition p1 values in (1),
partition pnull values in (null, 2),
partition p3 values in (3));
insert into t1 values (0,0),(0,1),(1,0),(1,1),(null,0),(null,1);
insert into t1 values (2,0),(2,1),(3,0),(3,1);
explain partitions select * from t1 where a is null;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 4 Using where
select * from t1 where a is null;
a b
NULL 0
NULL 1
explain partitions select * from t1 where a = 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 4 Using where
select * from t1 where a = 2;
a b
2 0
2 1
select * from t1 where a <= 0;
a b
0 0
0 1
select * from t1 where a < 3;
a b
0 0
0 1
1 0
1 1
2 0
2 1
select * from t1 where a >= 1 or a is null;
a b
1 0
1 1
NULL 0
2 0
NULL 1
2 1
3 0
3 1
drop table t1;
CREATE TABLE t1 (
CREATE TABLE t1 (
a int not null,
a int not null,
b int not null,
b int not null,
...
...
mysql-test/r/partition_pruning.result
View file @
cef00484
...
@@ -149,6 +149,48 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
...
@@ -149,6 +149,48 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t6 where a > 3 and a < 5;
explain partitions select * from t6 where a > 3 and a < 5;
id select_type table partitions type possible_keys key key_len ref rows Extra
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
drop table t6;
create table t6 (a int unsigned not null) partition by LIST(a) (
partition p1 values in (1),
partition p3 values in (3),
partition p5 values in (5),
partition p7 values in (7),
partition p9 values in (9)
);
insert into t6 values (1),(3),(5);
explain partitions select * from t6 where a < 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t6 where a <= 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t6 p1 system NULL NULL NULL NULL 1
explain partitions select * from t6 where a > 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t6 where a >= 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t6 where a > 0 and a < 5;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t6 p1,p3 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t6 where a > 5 and a < 12;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t6 where a > 3 and a < 8 ;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t6 p5,p7 system NULL NULL NULL NULL 1
explain partitions select * from t6 where a >= 0 and a <= 5;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t6 p1,p3,p5 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t6 where a >= 5 and a <= 12;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t6 p5,p7,p9 system NULL NULL NULL NULL 1
explain partitions select * from t6 where a >= 3 and a <= 8;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t6 p3,p5,p7 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t6 where a > 3 and a < 5;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
create table t7 (a int not null) partition by RANGE(a) (
create table t7 (a int not null) partition by RANGE(a) (
partition p10 values less than (10),
partition p10 values less than (10),
partition p30 values less than (30),
partition p30 values less than (30),
...
@@ -184,6 +226,42 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
...
@@ -184,6 +226,42 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t7 where a > 11 and a < 29;
explain partitions select * from t7 where a > 11 and a < 29;
id select_type table partitions type possible_keys key key_len ref rows Extra
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
drop table t7;
create table t7 (a int unsigned not null) partition by RANGE(a) (
partition p10 values less than (10),
partition p30 values less than (30),
partition p50 values less than (50),
partition p70 values less than (70),
partition p90 values less than (90)
);
insert into t7 values (10),(30),(50);
explain partitions select * from t7 where a < 5;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a < 10;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a <= 10;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30 system NULL NULL NULL NULL 1
explain partitions select * from t7 where a = 10;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p30 system NULL NULL NULL NULL 1
explain partitions select * from t7 where a < 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a = 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a > 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a >= 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a > 11 and a < 29;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
create table t8 (a date not null) partition by RANGE(YEAR(a)) (
create table t8 (a date not null) partition by RANGE(YEAR(a)) (
partition p0 values less than (1980),
partition p0 values less than (1980),
partition p1 values less than (1990),
partition p1 values less than (1990),
...
...
mysql-test/r/partition_range.result
View file @
cef00484
drop table if exists t1;
drop table if exists t1;
create table t1 (a int unsigned)
partition by range (a)
(partition pnull values less than (0),
partition p0 values less than (1),
partition p1 values less than(2));
insert into t1 values (null),(0),(1);
select * from t1 where a is null;
a
NULL
select * from t1 where a >= 0;
a
0
1
select * from t1 where a < 0;
a
select * from t1 where a <= 0;
a
0
select * from t1 where a > 1;
a
explain partitions select * from t1 where a is null;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull system NULL NULL NULL NULL 1
explain partitions select * from t1 where a >= 0;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a < 0;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t1 where a <= 0;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull,p0 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a > 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
drop table t1;
create table t1 (a int unsigned, b int unsigned)
partition by range (a)
subpartition by hash (b)
subpartitions 2
(partition pnull values less than (0),
partition p0 values less than (1),
partition p1 values less than(2));
insert into t1 values (null,0),(null,1),(0,0),(0,1),(1,0),(1,1);
select * from t1 where a is null;
a b
NULL 0
NULL 1
select * from t1 where a >= 0;
a b
0 0
0 1
1 0
1 1
select * from t1 where a < 0;
a b
select * from t1 where a <= 0;
a b
0 0
0 1
select * from t1 where a > 1;
a b
explain partitions select * from t1 where a is null;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a >= 0;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a < 0;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a <= 0;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1,p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a > 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 2 Using where
drop table t1;
CREATE TABLE t1 (
CREATE TABLE t1 (
a int not null,
a int not null,
b int not null,
b int not null,
...
...
mysql-test/t/partition_hash.test
View file @
cef00484
...
@@ -9,6 +9,36 @@
...
@@ -9,6 +9,36 @@
drop
table
if
exists
t1
;
drop
table
if
exists
t1
;
--
enable_warnings
--
enable_warnings
#
# More partition pruning tests, especially on interval walking
#
create
table
t1
(
a
int
unsigned
)
partition
by
hash
(
a
div
2
)
partitions
4
;
insert
into
t1
values
(
null
),(
0
),(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
);
select
*
from
t1
where
a
<
0
;
select
*
from
t1
where
a
is
null
or
(
a
>=
5
and
a
<=
7
);
select
*
from
t1
where
a
is
null
;
select
*
from
t1
where
a
is
not
null
;
select
*
from
t1
where
a
>=
1
and
a
<
3
;
select
*
from
t1
where
a
>=
3
and
a
<=
5
;
select
*
from
t1
where
a
>
2
and
a
<
4
;
select
*
from
t1
where
a
>
3
and
a
<=
6
;
select
*
from
t1
where
a
>
5
;
select
*
from
t1
where
a
>=
1
and
a
<=
5
;
explain
partitions
select
*
from
t1
where
a
<
0
;
explain
partitions
select
*
from
t1
where
a
is
null
or
(
a
>=
5
and
a
<=
7
);
explain
partitions
select
*
from
t1
where
a
is
null
;
explain
partitions
select
*
from
t1
where
a
is
not
null
;
explain
partitions
select
*
from
t1
where
a
>=
1
and
a
<
3
;
explain
partitions
select
*
from
t1
where
a
>=
3
and
a
<=
5
;
explain
partitions
select
*
from
t1
where
a
>
2
and
a
<
4
;
explain
partitions
select
*
from
t1
where
a
>
3
and
a
<=
6
;
explain
partitions
select
*
from
t1
where
a
>
5
;
explain
partitions
select
*
from
t1
where
a
>=
1
and
a
<=
5
;
drop
table
t1
;
#
#
# Partition by hash, basic
# Partition by hash, basic
#
#
...
...
mysql-test/t/partition_list.test
View file @
cef00484
...
@@ -9,6 +9,49 @@
...
@@ -9,6 +9,49 @@
drop
table
if
exists
t1
;
drop
table
if
exists
t1
;
--
enable_warnings
--
enable_warnings
#
# Bug 20733: Zerofill columns gives wrong result with partitioned tables
#
create
table
t1
(
a
int
unsigned
)
partition
by
list
(
a
)
(
partition
p0
values
in
(
0
),
partition
p1
values
in
(
1
),
partition
pnull
values
in
(
null
),
partition
p2
values
in
(
2
));
insert
into
t1
values
(
null
),(
0
),(
1
),(
2
);
select
*
from
t1
where
a
<
2
;
select
*
from
t1
where
a
<=
0
;
select
*
from
t1
where
a
<
1
;
select
*
from
t1
where
a
>
0
;
select
*
from
t1
where
a
>
1
;
select
*
from
t1
where
a
>=
0
;
select
*
from
t1
where
a
>=
1
;
select
*
from
t1
where
a
is
null
;
select
*
from
t1
where
a
is
not
null
;
select
*
from
t1
where
a
is
null
or
a
>
0
;
drop
table
t1
;
create
table
t1
(
a
int
unsigned
,
b
int
)
partition
by
list
(
a
)
subpartition
by
hash
(
b
)
subpartitions
2
(
partition
p0
values
in
(
0
),
partition
p1
values
in
(
1
),
partition
pnull
values
in
(
null
,
2
),
partition
p3
values
in
(
3
));
insert
into
t1
values
(
0
,
0
),(
0
,
1
),(
1
,
0
),(
1
,
1
),(
null
,
0
),(
null
,
1
);
insert
into
t1
values
(
2
,
0
),(
2
,
1
),(
3
,
0
),(
3
,
1
);
explain
partitions
select
*
from
t1
where
a
is
null
;
select
*
from
t1
where
a
is
null
;
explain
partitions
select
*
from
t1
where
a
=
2
;
select
*
from
t1
where
a
=
2
;
select
*
from
t1
where
a
<=
0
;
select
*
from
t1
where
a
<
3
;
select
*
from
t1
where
a
>=
1
or
a
is
null
;
drop
table
t1
;
#
#
# Test ordinary list partitioning that it works ok
# Test ordinary list partitioning that it works ok
#
#
...
@@ -136,3 +179,4 @@ insert into t1 values (null);
...
@@ -136,3 +179,4 @@ insert into t1 values (null);
select
*
from
t1
;
select
*
from
t1
;
drop
table
t1
;
drop
table
t1
;
mysql-test/t/partition_pruning.test
View file @
cef00484
...
@@ -137,6 +137,32 @@ explain partitions select * from t6 where a >= 3 and a <= 8;
...
@@ -137,6 +137,32 @@ explain partitions select * from t6 where a >= 3 and a <= 8;
explain
partitions
select
*
from
t6
where
a
>
3
and
a
<
5
;
explain
partitions
select
*
from
t6
where
a
>
3
and
a
<
5
;
drop
table
t6
;
create
table
t6
(
a
int
unsigned
not
null
)
partition
by
LIST
(
a
)
(
partition
p1
values
in
(
1
),
partition
p3
values
in
(
3
),
partition
p5
values
in
(
5
),
partition
p7
values
in
(
7
),
partition
p9
values
in
(
9
)
);
insert
into
t6
values
(
1
),(
3
),(
5
);
explain
partitions
select
*
from
t6
where
a
<
1
;
explain
partitions
select
*
from
t6
where
a
<=
1
;
explain
partitions
select
*
from
t6
where
a
>
9
;
explain
partitions
select
*
from
t6
where
a
>=
9
;
explain
partitions
select
*
from
t6
where
a
>
0
and
a
<
5
;
explain
partitions
select
*
from
t6
where
a
>
5
and
a
<
12
;
explain
partitions
select
*
from
t6
where
a
>
3
and
a
<
8
;
explain
partitions
select
*
from
t6
where
a
>=
0
and
a
<=
5
;
explain
partitions
select
*
from
t6
where
a
>=
5
and
a
<=
12
;
explain
partitions
select
*
from
t6
where
a
>=
3
and
a
<=
8
;
explain
partitions
select
*
from
t6
where
a
>
3
and
a
<
5
;
# RANGE(field) partitioning, interval analysis.
# RANGE(field) partitioning, interval analysis.
create
table
t7
(
a
int
not
null
)
partition
by
RANGE
(
a
)
(
create
table
t7
(
a
int
not
null
)
partition
by
RANGE
(
a
)
(
partition
p10
values
less
than
(
10
),
partition
p10
values
less
than
(
10
),
...
@@ -162,6 +188,32 @@ explain partitions select * from t7 where a >= 90;
...
@@ -162,6 +188,32 @@ explain partitions select * from t7 where a >= 90;
# misc intervals
# misc intervals
explain
partitions
select
*
from
t7
where
a
>
11
and
a
<
29
;
explain
partitions
select
*
from
t7
where
a
>
11
and
a
<
29
;
drop
table
t7
;
create
table
t7
(
a
int
unsigned
not
null
)
partition
by
RANGE
(
a
)
(
partition
p10
values
less
than
(
10
),
partition
p30
values
less
than
(
30
),
partition
p50
values
less
than
(
50
),
partition
p70
values
less
than
(
70
),
partition
p90
values
less
than
(
90
)
);
insert
into
t7
values
(
10
),(
30
),(
50
);
# leftmost intervals
explain
partitions
select
*
from
t7
where
a
<
5
;
explain
partitions
select
*
from
t7
where
a
<
10
;
explain
partitions
select
*
from
t7
where
a
<=
10
;
explain
partitions
select
*
from
t7
where
a
=
10
;
#rightmost intervals
explain
partitions
select
*
from
t7
where
a
<
90
;
explain
partitions
select
*
from
t7
where
a
=
90
;
explain
partitions
select
*
from
t7
where
a
>
90
;
explain
partitions
select
*
from
t7
where
a
>=
90
;
# misc intervals
explain
partitions
select
*
from
t7
where
a
>
11
and
a
<
29
;
# LIST(monontonic_func) partitioning
# LIST(monontonic_func) partitioning
create
table
t8
(
a
date
not
null
)
partition
by
RANGE
(
YEAR
(
a
))
(
create
table
t8
(
a
date
not
null
)
partition
by
RANGE
(
YEAR
(
a
))
(
partition
p0
values
less
than
(
1980
),
partition
p0
values
less
than
(
1980
),
...
...
mysql-test/t/partition_range.test
View file @
cef00484
...
@@ -9,6 +9,50 @@
...
@@ -9,6 +9,50 @@
drop
table
if
exists
t1
;
drop
table
if
exists
t1
;
--
enable_warnings
--
enable_warnings
#
# More checks for partition pruning
#
create
table
t1
(
a
int
unsigned
)
partition
by
range
(
a
)
(
partition
pnull
values
less
than
(
0
),
partition
p0
values
less
than
(
1
),
partition
p1
values
less
than
(
2
));
insert
into
t1
values
(
null
),(
0
),(
1
);
select
*
from
t1
where
a
is
null
;
select
*
from
t1
where
a
>=
0
;
select
*
from
t1
where
a
<
0
;
select
*
from
t1
where
a
<=
0
;
select
*
from
t1
where
a
>
1
;
explain
partitions
select
*
from
t1
where
a
is
null
;
explain
partitions
select
*
from
t1
where
a
>=
0
;
explain
partitions
select
*
from
t1
where
a
<
0
;
explain
partitions
select
*
from
t1
where
a
<=
0
;
explain
partitions
select
*
from
t1
where
a
>
1
;
drop
table
t1
;
create
table
t1
(
a
int
unsigned
,
b
int
unsigned
)
partition
by
range
(
a
)
subpartition
by
hash
(
b
)
subpartitions
2
(
partition
pnull
values
less
than
(
0
),
partition
p0
values
less
than
(
1
),
partition
p1
values
less
than
(
2
));
insert
into
t1
values
(
null
,
0
),(
null
,
1
),(
0
,
0
),(
0
,
1
),(
1
,
0
),(
1
,
1
);
select
*
from
t1
where
a
is
null
;
select
*
from
t1
where
a
>=
0
;
select
*
from
t1
where
a
<
0
;
select
*
from
t1
where
a
<=
0
;
select
*
from
t1
where
a
>
1
;
explain
partitions
select
*
from
t1
where
a
is
null
;
explain
partitions
select
*
from
t1
where
a
>=
0
;
explain
partitions
select
*
from
t1
where
a
<
0
;
explain
partitions
select
*
from
t1
where
a
<=
0
;
explain
partitions
select
*
from
t1
where
a
>
1
;
drop
table
t1
;
#
#
# Partition by range, basic
# Partition by range, basic
#
#
...
...
sql/opt_range.cc
View file @
cef00484
...
@@ -3204,6 +3204,11 @@ static bool create_partition_index_description(PART_PRUNE_PARAM *ppar)
...
@@ -3204,6 +3204,11 @@ static bool create_partition_index_description(PART_PRUNE_PARAM *ppar)
ppar
->
is_part_keypart
[
part
]
=
!
in_subpart_fields
;
ppar
->
is_part_keypart
[
part
]
=
!
in_subpart_fields
;
ppar
->
is_subpart_keypart
[
part
]
=
in_subpart_fields
;
ppar
->
is_subpart_keypart
[
part
]
=
in_subpart_fields
;
/*
Check if this was last field in this array, in this case we
switch to subpartitioning fields. (This will only happens if
there are subpartitioning fields to cater for).
*/
if
(
!*
(
++
field
))
if
(
!*
(
++
field
))
{
{
field
=
part_info
->
subpart_field_array
;
field
=
part_info
->
subpart_field_array
;
...
...
sql/sql_partition.cc
View file @
cef00484
...
@@ -2415,6 +2415,10 @@ uint32 get_list_array_idx_for_endpoint(partition_info *part_info,
...
@@ -2415,6 +2415,10 @@ uint32 get_list_array_idx_for_endpoint(partition_info *part_info,
bool
unsigned_flag
=
part_info
->
part_expr
->
unsigned_flag
;
bool
unsigned_flag
=
part_info
->
part_expr
->
unsigned_flag
;
DBUG_ENTER
(
"get_list_array_idx_for_endpoint"
);
DBUG_ENTER
(
"get_list_array_idx_for_endpoint"
);
if
(
part_info
->
part_expr
->
null_value
)
{
DBUG_RETURN
(
0
);
}
if
(
unsigned_flag
)
if
(
unsigned_flag
)
part_func_value
-=
0x8000000000000000ULL
;
part_func_value
-=
0x8000000000000000ULL
;
DBUG_ASSERT
(
part_info
->
no_list_values
);
DBUG_ASSERT
(
part_info
->
no_list_values
);
...
@@ -2539,6 +2543,13 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
...
@@ -2539,6 +2543,13 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
bool
unsigned_flag
=
part_info
->
part_expr
->
unsigned_flag
;
bool
unsigned_flag
=
part_info
->
part_expr
->
unsigned_flag
;
DBUG_ENTER
(
"get_partition_id_range_for_endpoint"
);
DBUG_ENTER
(
"get_partition_id_range_for_endpoint"
);
if
(
part_info
->
part_expr
->
null_value
)
{
uint32
ret_part_id
=
0
;
if
(
!
left_endpoint
&&
include_endpoint
)
ret_part_id
=
1
;
DBUG_RETURN
(
ret_part_id
);
}
if
(
unsigned_flag
)
if
(
unsigned_flag
)
part_func_value
-=
0x8000000000000000ULL
;
part_func_value
-=
0x8000000000000000ULL
;
while
(
max_part_id
>
min_part_id
)
while
(
max_part_id
>
min_part_id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment