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
9181dbd5
Commit
9181dbd5
authored
Jan 27, 2010
by
Alexander Nozdrin
Browse files
Options
Browse Files
Download
Plain Diff
Manual merge from mysql-trunk-merge.
Conflicts: - sql/sql_partition.cc
parents
32ab87c3
22cff392
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
795 additions
and
179 deletions
+795
-179
mysql-test/r/partition_pruning.result
mysql-test/r/partition_pruning.result
+611
-1
mysql-test/suite/rpl/r/rpl_myisam_null_values.result
mysql-test/suite/rpl/r/rpl_myisam_null_values.result
+0
-24
mysql-test/suite/rpl/t/rpl_myisam_null_values.test
mysql-test/suite/rpl/t/rpl_myisam_null_values.test
+0
-53
mysql-test/t/partition_pruning.test
mysql-test/t/partition_pruning.test
+160
-0
sql/log_event.cc
sql/log_event.cc
+1
-38
sql/log_event_old.cc
sql/log_event_old.cc
+1
-38
sql/sql_partition.cc
sql/sql_partition.cc
+22
-25
No files found.
mysql-test/r/partition_pruning.result
View file @
9181dbd5
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
#
# Bug#49742: Partition Pruning not working correctly for RANGE
#
CREATE TABLE t1 (a INT PRIMARY KEY)
PARTITION BY RANGE (a) (
PARTITION p0 VALUES LESS THAN (1),
PARTITION p1 VALUES LESS THAN (2),
PARTITION p2 VALUES LESS THAN (3),
PARTITION p3 VALUES LESS THAN (4),
PARTITION p4 VALUES LESS THAN (5),
PARTITION p5 VALUES LESS THAN (6),
PARTITION max VALUES LESS THAN MAXVALUE);
INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8);
SELECT * FROM t1 WHERE a < 1;
a
-1
0
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 p0 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a < 2;
a
-1
0
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 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a < 3;
a
-1
0
1
2
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT * FROM t1 WHERE a < 4;
a
-1
0
1
2
3
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index
SELECT * FROM t1 WHERE a < 5;
a
-1
0
1
2
3
4
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,p4 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index
SELECT * FROM t1 WHERE a < 6;
a
-1
0
1
2
3
4
5
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3,p4,p5 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
SELECT * FROM t1 WHERE a < 7;
a
-1
0
1
2
3
4
5
6
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a <= 1;
a
-1
0
1
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 p0,p1 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a <= 2;
a
-1
0
1
2
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 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a <= 3;
a
-1
0
1
2
3
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a <= 4;
a
-1
0
1
2
3
4
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a <= 5;
a
-1
0
1
2
3
4
5
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,p4,p5 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a <= 6;
a
-1
0
1
2
3
4
5
6
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a <= 7;
a
-1
0
1
2
3
4
5
6
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 7;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a = 1;
a
1
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 system PRIMARY NULL NULL NULL 1
SELECT * FROM t1 WHERE a = 2;
a
2
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 p2 system PRIMARY NULL NULL NULL 1
SELECT * FROM t1 WHERE a = 3;
a
3
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p3 system PRIMARY NULL NULL NULL 1
SELECT * FROM t1 WHERE a = 4;
a
4
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4 system PRIMARY NULL NULL NULL 1
SELECT * FROM t1 WHERE a = 5;
a
5
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 p5 system PRIMARY NULL NULL NULL 1
SELECT * FROM t1 WHERE a = 6;
a
6
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max const PRIMARY PRIMARY 4 const 1 Using index
SELECT * FROM t1 WHERE a = 7;
a
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 7;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max const PRIMARY PRIMARY 4 const 1 Using index
SELECT * FROM t1 WHERE a >= 1;
a
1
2
3
4
5
6
7
8
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,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a >= 2;
a
2
3
4
5
6
7
8
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 p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a >= 3;
a
3
4
5
6
7
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a >= 4;
a
4
5
6
7
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a >= 5;
a
5
6
7
8
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 p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a >= 6;
a
6
7
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a >= 7;
a
7
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 7;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a > 1;
a
2
3
4
5
6
7
8
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 p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a > 2;
a
3
4
5
6
7
8
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 p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a > 3;
a
4
5
6
7
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a > 4;
a
5
6
7
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a > 5;
a
6
7
8
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 max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a > 6;
a
7
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a > 7;
a
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 7;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY)
PARTITION BY RANGE (a) (
PARTITION p0 VALUES LESS THAN (1),
PARTITION p1 VALUES LESS THAN (2),
PARTITION p2 VALUES LESS THAN (3),
PARTITION p3 VALUES LESS THAN (4),
PARTITION p4 VALUES LESS THAN (5),
PARTITION max VALUES LESS THAN MAXVALUE);
INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7);
SELECT * FROM t1 WHERE a < 1;
a
-1
0
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 p0 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a < 2;
a
-1
0
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 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a < 3;
a
-1
0
1
2
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT * FROM t1 WHERE a < 4;
a
-1
0
1
2
3
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index
SELECT * FROM t1 WHERE a < 5;
a
-1
0
1
2
3
4
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,p4 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index
SELECT * FROM t1 WHERE a < 6;
a
-1
0
1
2
3
4
5
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
SELECT * FROM t1 WHERE a <= 1;
a
-1
0
1
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 p0,p1 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a <= 2;
a
-1
0
1
2
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 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a <= 3;
a
-1
0
1
2
3
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a <= 4;
a
-1
0
1
2
3
4
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a <= 5;
a
-1
0
1
2
3
4
5
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,p4,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
SELECT * FROM t1 WHERE a <= 6;
a
-1
0
1
2
3
4
5
6
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
SELECT * FROM t1 WHERE a = 1;
a
1
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 system PRIMARY NULL NULL NULL 1
SELECT * FROM t1 WHERE a = 2;
a
2
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 p2 system PRIMARY NULL NULL NULL 1
SELECT * FROM t1 WHERE a = 3;
a
3
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p3 system PRIMARY NULL NULL NULL 1
SELECT * FROM t1 WHERE a = 4;
a
4
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4 system PRIMARY NULL NULL NULL 1
SELECT * FROM t1 WHERE a = 5;
a
5
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 max const PRIMARY PRIMARY 4 const 1 Using index
SELECT * FROM t1 WHERE a = 6;
a
6
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max const PRIMARY PRIMARY 4 const 1 Using index
SELECT * FROM t1 WHERE a >= 1;
a
1
2
3
4
5
6
7
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,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a >= 2;
a
2
3
4
5
6
7
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 p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a >= 3;
a
3
4
5
6
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a >= 4;
a
4
5
6
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a >= 5;
a
5
6
7
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 max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a >= 6;
a
6
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a > 1;
a
2
3
4
5
6
7
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 p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a > 2;
a
3
4
5
6
7
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 p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a > 3;
a
4
5
6
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a > 4;
a
5
6
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a > 5;
a
6
7
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 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a > 6;
a
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
DROP TABLE t1;
# test of RANGE and index
# test of RANGE and index
CREATE TABLE t1 (a DATE, KEY(a))
CREATE TABLE t1 (a DATE, KEY(a))
PARTITION BY RANGE (TO_DAYS(a))
PARTITION BY RANGE (TO_DAYS(a))
...
@@ -2145,7 +2755,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
...
@@ -2145,7 +2755,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p4 ALL NULL NULL NULL NULL 910 Using where
1 SIMPLE t2 p0,p4 ALL NULL NULL NULL NULL 910 Using where
explain partitions select * from t2 where (a > 100 AND a < 600);
explain partitions select * from t2 where (a > 100 AND a < 600);
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 t2 p0,p1,p2
,p3
ALL NULL NULL NULL NULL 910 Using where
1 SIMPLE t2 p0,p1,p2 ALL NULL NULL NULL NULL 910 Using where
explain partitions select * from t2 where b = 4;
explain partitions select * from t2 where b = 4;
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 t2 p0,p1,p2,p3,p4 ref b b 5 const 76 Using where
1 SIMPLE t2 p0,p1,p2,p3,p4 ref b b 5 const 76 Using where
...
...
mysql-test/suite/rpl/r/rpl_myisam_null_values.result
deleted
100644 → 0
View file @
32ab87c3
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 (c1 BIT, c2 INT);
INSERT INTO `t1` VALUES ( 1, 1 );
UPDATE t1 SET c1=NULL where c2=1;
Comparing tables master:test.t1 and slave:test.t1
DELETE FROM t1 WHERE c2=1 LIMIT 1;
Comparing tables master:test.t1 and slave:test.t1
DROP TABLE t1;
CREATE TABLE t1 (c1 CHAR);
INSERT INTO t1 ( c1 ) VALUES ( 'w' ) ;
SELECT * FROM t1;
c1
w
# should trigger switch to row due to LIMIT
UPDATE t1 SET c1=NULL WHERE c1='w' LIMIT 2;
Comparing tables master:test.t1 and slave:test.t1
DELETE FROM t1 LIMIT 2;
Comparing tables master:test.t1 and slave:test.t1
DROP TABLE t1;
mysql-test/suite/rpl/t/rpl_myisam_null_values.test
deleted
100644 → 0
View file @
32ab87c3
# BUG#49481: RBR: MyISAM and bit fields may cause slave to stop on delete cant find record
# BUG#49482: RBR: Replication may break on deletes when MyISAM tables + char field are used
--
source
include
/
master
-
slave
.
inc
--
source
include
/
have_binlog_format_mixed_or_row
.
inc
--
connection
master
CREATE
TABLE
t1
(
c1
BIT
,
c2
INT
);
INSERT
INTO
`t1`
VALUES
(
1
,
1
);
UPDATE
t1
SET
c1
=
NULL
where
c2
=
1
;
--
sync_slave_with_master
--
let
$diff_table_1
=
master
:
test
.
t1
--
let
$diff_table_2
=
slave
:
test
.
t1
--
source
include
/
diff_tables
.
inc
--
connection
master
DELETE
FROM
t1
WHERE
c2
=
1
LIMIT
1
;
--
sync_slave_with_master
--
let
$diff_table_1
=
master
:
test
.
t1
--
let
$diff_table_2
=
slave
:
test
.
t1
--
source
include
/
diff_tables
.
inc
--
connection
master
DROP
TABLE
t1
;
--
sync_slave_with_master
--
connection
master
CREATE
TABLE
t1
(
c1
CHAR
);
INSERT
INTO
t1
(
c1
)
VALUES
(
'w'
)
;
SELECT
*
FROM
t1
;
--
echo
# should trigger switch to row due to LIMIT
UPDATE
t1
SET
c1
=
NULL
WHERE
c1
=
'w'
LIMIT
2
;
--
sync_slave_with_master
--
let
$diff_table_1
=
master
:
test
.
t1
--
let
$diff_table_2
=
slave
:
test
.
t1
--
source
include
/
diff_tables
.
inc
--
connection
master
DELETE
FROM
t1
LIMIT
2
;
--
sync_slave_with_master
--
let
$diff_table_1
=
master
:
test
.
t1
--
let
$diff_table_2
=
slave
:
test
.
t1
--
source
include
/
diff_tables
.
inc
--
connection
master
DROP
TABLE
t1
;
--
sync_slave_with_master
mysql-test/t/partition_pruning.test
View file @
9181dbd5
...
@@ -8,6 +8,166 @@
...
@@ -8,6 +8,166 @@
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
t7
,
t8
,
t9
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
t7
,
t8
,
t9
;
--
enable_warnings
--
enable_warnings
--
echo
#
--
echo
# Bug#49742: Partition Pruning not working correctly for RANGE
--
echo
#
CREATE
TABLE
t1
(
a
INT
PRIMARY
KEY
)
PARTITION
BY
RANGE
(
a
)
(
PARTITION
p0
VALUES
LESS
THAN
(
1
),
PARTITION
p1
VALUES
LESS
THAN
(
2
),
PARTITION
p2
VALUES
LESS
THAN
(
3
),
PARTITION
p3
VALUES
LESS
THAN
(
4
),
PARTITION
p4
VALUES
LESS
THAN
(
5
),
PARTITION
p5
VALUES
LESS
THAN
(
6
),
PARTITION
max
VALUES
LESS
THAN
MAXVALUE
);
INSERT
INTO
t1
VALUES
(
-
1
),(
0
),(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
);
SELECT
*
FROM
t1
WHERE
a
<
1
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
1
;
SELECT
*
FROM
t1
WHERE
a
<
2
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
2
;
SELECT
*
FROM
t1
WHERE
a
<
3
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
3
;
SELECT
*
FROM
t1
WHERE
a
<
4
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
4
;
SELECT
*
FROM
t1
WHERE
a
<
5
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
5
;
SELECT
*
FROM
t1
WHERE
a
<
6
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
6
;
SELECT
*
FROM
t1
WHERE
a
<
7
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
7
;
SELECT
*
FROM
t1
WHERE
a
<=
1
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
1
;
SELECT
*
FROM
t1
WHERE
a
<=
2
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
2
;
SELECT
*
FROM
t1
WHERE
a
<=
3
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
3
;
SELECT
*
FROM
t1
WHERE
a
<=
4
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
4
;
SELECT
*
FROM
t1
WHERE
a
<=
5
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
5
;
SELECT
*
FROM
t1
WHERE
a
<=
6
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
6
;
SELECT
*
FROM
t1
WHERE
a
<=
7
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
7
;
SELECT
*
FROM
t1
WHERE
a
=
1
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
1
;
SELECT
*
FROM
t1
WHERE
a
=
2
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
2
;
SELECT
*
FROM
t1
WHERE
a
=
3
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
3
;
SELECT
*
FROM
t1
WHERE
a
=
4
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
4
;
SELECT
*
FROM
t1
WHERE
a
=
5
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
5
;
SELECT
*
FROM
t1
WHERE
a
=
6
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
6
;
SELECT
*
FROM
t1
WHERE
a
=
7
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
7
;
SELECT
*
FROM
t1
WHERE
a
>=
1
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
1
;
SELECT
*
FROM
t1
WHERE
a
>=
2
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
2
;
SELECT
*
FROM
t1
WHERE
a
>=
3
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
3
;
SELECT
*
FROM
t1
WHERE
a
>=
4
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
4
;
SELECT
*
FROM
t1
WHERE
a
>=
5
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
5
;
SELECT
*
FROM
t1
WHERE
a
>=
6
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
6
;
SELECT
*
FROM
t1
WHERE
a
>=
7
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
7
;
SELECT
*
FROM
t1
WHERE
a
>
1
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
1
;
SELECT
*
FROM
t1
WHERE
a
>
2
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
2
;
SELECT
*
FROM
t1
WHERE
a
>
3
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
3
;
SELECT
*
FROM
t1
WHERE
a
>
4
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
4
;
SELECT
*
FROM
t1
WHERE
a
>
5
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
5
;
SELECT
*
FROM
t1
WHERE
a
>
6
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
6
;
SELECT
*
FROM
t1
WHERE
a
>
7
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
7
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INT
PRIMARY
KEY
)
PARTITION
BY
RANGE
(
a
)
(
PARTITION
p0
VALUES
LESS
THAN
(
1
),
PARTITION
p1
VALUES
LESS
THAN
(
2
),
PARTITION
p2
VALUES
LESS
THAN
(
3
),
PARTITION
p3
VALUES
LESS
THAN
(
4
),
PARTITION
p4
VALUES
LESS
THAN
(
5
),
PARTITION
max
VALUES
LESS
THAN
MAXVALUE
);
INSERT
INTO
t1
VALUES
(
-
1
),(
0
),(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
);
SELECT
*
FROM
t1
WHERE
a
<
1
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
1
;
SELECT
*
FROM
t1
WHERE
a
<
2
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
2
;
SELECT
*
FROM
t1
WHERE
a
<
3
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
3
;
SELECT
*
FROM
t1
WHERE
a
<
4
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
4
;
SELECT
*
FROM
t1
WHERE
a
<
5
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
5
;
SELECT
*
FROM
t1
WHERE
a
<
6
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<
6
;
SELECT
*
FROM
t1
WHERE
a
<=
1
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
1
;
SELECT
*
FROM
t1
WHERE
a
<=
2
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
2
;
SELECT
*
FROM
t1
WHERE
a
<=
3
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
3
;
SELECT
*
FROM
t1
WHERE
a
<=
4
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
4
;
SELECT
*
FROM
t1
WHERE
a
<=
5
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
5
;
SELECT
*
FROM
t1
WHERE
a
<=
6
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
<=
6
;
SELECT
*
FROM
t1
WHERE
a
=
1
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
1
;
SELECT
*
FROM
t1
WHERE
a
=
2
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
2
;
SELECT
*
FROM
t1
WHERE
a
=
3
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
3
;
SELECT
*
FROM
t1
WHERE
a
=
4
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
4
;
SELECT
*
FROM
t1
WHERE
a
=
5
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
5
;
SELECT
*
FROM
t1
WHERE
a
=
6
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
=
6
;
SELECT
*
FROM
t1
WHERE
a
>=
1
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
1
;
SELECT
*
FROM
t1
WHERE
a
>=
2
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
2
;
SELECT
*
FROM
t1
WHERE
a
>=
3
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
3
;
SELECT
*
FROM
t1
WHERE
a
>=
4
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
4
;
SELECT
*
FROM
t1
WHERE
a
>=
5
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
5
;
SELECT
*
FROM
t1
WHERE
a
>=
6
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>=
6
;
SELECT
*
FROM
t1
WHERE
a
>
1
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
1
;
SELECT
*
FROM
t1
WHERE
a
>
2
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
2
;
SELECT
*
FROM
t1
WHERE
a
>
3
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
3
;
SELECT
*
FROM
t1
WHERE
a
>
4
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
4
;
SELECT
*
FROM
t1
WHERE
a
>
5
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
5
;
SELECT
*
FROM
t1
WHERE
a
>
6
;
EXPLAIN
PARTITIONS
SELECT
*
FROM
t1
WHERE
a
>
6
;
DROP
TABLE
t1
;
#
#
# Bug#20577: Partitions: use of to_days() function leads to selection failures
# Bug#20577: Partitions: use of to_days() function leads to selection failures
#
#
...
...
sql/log_event.cc
View file @
9181dbd5
...
@@ -8854,24 +8854,6 @@ static bool record_compare(TABLE *table)
...
@@ -8854,24 +8854,6 @@ static bool record_compare(TABLE *table)
}
}
}
}
/**
Check if we are using MyISAM.
If this is a myisam table, then we cannot do a memcmp
right away because some NULL fields can still contain
an old value in the row - they are not shown to the user
because the null bit is set, however, the contents are
not cleared. As such, plain memory comparison cannot be
assured to work. See: BUG#49482 and BUG#49481.
On top of this, we do not store field contents for null
fields in the binlog, so this is extra important when
comparing records fetched from binlog and from storage
engine.
*/
if
(
table
->
file
->
ht
->
db_type
==
DB_TYPE_MYISAM
)
goto
record_compare_field_by_field
;
if
(
table
->
s
->
blob_fields
+
table
->
s
->
varchar_fields
==
0
)
if
(
table
->
s
->
blob_fields
+
table
->
s
->
varchar_fields
==
0
)
{
{
result
=
cmp_record
(
table
,
record
[
1
]);
result
=
cmp_record
(
table
,
record
[
1
]);
...
@@ -8887,33 +8869,14 @@ static bool record_compare(TABLE *table)
...
@@ -8887,33 +8869,14 @@ static bool record_compare(TABLE *table)
goto
record_compare_exit
;
goto
record_compare_exit
;
}
}
record_compare_field_by_field:
/* Compare updated fields */
/* Compare updated fields */
for
(
Field
**
ptr
=
table
->
field
;
*
ptr
;
ptr
++
)
for
(
Field
**
ptr
=
table
->
field
;
*
ptr
;
ptr
++
)
{
{
Field
*
f
=
*
ptr
;
if
((
*
ptr
)
->
cmp_binary_offset
(
table
->
s
->
rec_buff_length
))
/* if just one of the fields is null then there is no match */
if
((
f
->
is_null_in_record
(
table
->
record
[
0
]))
==
!
(
f
->
is_null_in_record
(
table
->
record
[
1
])))
{
{
result
=
TRUE
;
result
=
TRUE
;
goto
record_compare_exit
;
goto
record_compare_exit
;
}
}
/* if both fields are not null then we can compare */
if
(
!
(
f
->
is_null_in_record
(
table
->
record
[
0
]))
&&
!
(
f
->
is_null_in_record
(
table
->
record
[
1
])))
{
if
(
f
->
cmp_binary_offset
(
table
->
s
->
rec_buff_length
))
{
result
=
TRUE
;
goto
record_compare_exit
;
}
}
/* if both fields are null then there is a match. compare next field */
}
}
record_compare_exit:
record_compare_exit:
...
...
sql/log_event_old.cc
View file @
9181dbd5
...
@@ -330,24 +330,6 @@ static bool record_compare(TABLE *table)
...
@@ -330,24 +330,6 @@ static bool record_compare(TABLE *table)
}
}
}
}
/**
Check if we are using MyISAM.
If this is a myisam table, then we cannot do a memcmp
right away because some NULL fields can still contain
an old value in the row - they are not shown to the user
because the null bit is set, however, the contents are
not cleared. As such, plain memory comparison cannot be
assured to work. See: BUG#49482 and BUG#49481.
On top of this, we do not store field contents for null
fields in the binlog, so this is extra important when
comparing records fetched from binlog and from storage
engine.
*/
if
(
table
->
file
->
ht
->
db_type
==
DB_TYPE_MYISAM
)
goto
record_compare_field_by_field
;
if
(
table
->
s
->
blob_fields
+
table
->
s
->
varchar_fields
==
0
)
if
(
table
->
s
->
blob_fields
+
table
->
s
->
varchar_fields
==
0
)
{
{
result
=
cmp_record
(
table
,
record
[
1
]);
result
=
cmp_record
(
table
,
record
[
1
]);
...
@@ -363,35 +345,16 @@ static bool record_compare(TABLE *table)
...
@@ -363,35 +345,16 @@ static bool record_compare(TABLE *table)
goto
record_compare_exit
;
goto
record_compare_exit
;
}
}
record_compare_field_by_field:
/* Compare updated fields */
/* Compare updated fields */
for
(
Field
**
ptr
=
table
->
field
;
*
ptr
;
ptr
++
)
for
(
Field
**
ptr
=
table
->
field
;
*
ptr
;
ptr
++
)
{
{
Field
*
f
=
*
ptr
;
if
((
*
ptr
)
->
cmp_binary_offset
(
table
->
s
->
rec_buff_length
))
/* if just one of the fields is null then there is no match */
if
((
f
->
is_null_in_record
(
table
->
record
[
0
]))
==
!
(
f
->
is_null_in_record
(
table
->
record
[
1
])))
{
result
=
TRUE
;
goto
record_compare_exit
;
}
/* if both fields are not null then we can compare */
if
(
!
(
f
->
is_null_in_record
(
table
->
record
[
0
]))
&&
!
(
f
->
is_null_in_record
(
table
->
record
[
1
])))
{
if
(
f
->
cmp_binary_offset
(
table
->
s
->
rec_buff_length
))
{
{
result
=
TRUE
;
result
=
TRUE
;
goto
record_compare_exit
;
goto
record_compare_exit
;
}
}
}
}
/* if both fields are null then there is a match. compare next field */
}
record_compare_exit:
record_compare_exit:
/*
/*
Restore the saved bytes.
Restore the saved bytes.
...
...
sql/sql_partition.cc
View file @
9181dbd5
...
@@ -3360,16 +3360,13 @@ int get_partition_id_range(partition_info *part_info,
...
@@ -3360,16 +3360,13 @@ int get_partition_id_range(partition_info *part_info,
part_func_value
-=
0x8000000000000000ULL
;
part_func_value
-=
0x8000000000000000ULL
;
while
(
max_part_id
>
min_part_id
)
while
(
max_part_id
>
min_part_id
)
{
{
loc_part_id
=
(
max_part_id
+
min_part_id
+
1
)
>>
1
;
loc_part_id
=
(
max_part_id
+
min_part_id
)
/
2
;
if
(
range_array
[
loc_part_id
]
<=
part_func_value
)
if
(
range_array
[
loc_part_id
]
<=
part_func_value
)
min_part_id
=
loc_part_id
+
1
;
min_part_id
=
loc_part_id
+
1
;
else
else
max_part_id
=
loc_part_id
-
1
;
max_part_id
=
loc_part_id
;
}
}
loc_part_id
=
max_part_id
;
loc_part_id
=
max_part_id
;
if
(
part_func_value
>=
range_array
[
loc_part_id
])
if
(
loc_part_id
!=
max_partition
)
loc_part_id
++
;
*
part_id
=
(
uint32
)
loc_part_id
;
*
part_id
=
(
uint32
)
loc_part_id
;
if
(
loc_part_id
==
max_partition
&&
if
(
loc_part_id
==
max_partition
&&
part_func_value
>=
range_array
[
loc_part_id
]
&&
part_func_value
>=
range_array
[
loc_part_id
]
&&
...
@@ -3443,6 +3440,7 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
...
@@ -3443,6 +3440,7 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
bool
include_endpoint
)
bool
include_endpoint
)
{
{
longlong
*
range_array
=
part_info
->
range_int_array
;
longlong
*
range_array
=
part_info
->
range_int_array
;
longlong
part_end_val
;
uint
max_partition
=
part_info
->
num_parts
-
1
;
uint
max_partition
=
part_info
->
num_parts
-
1
;
uint
min_part_id
=
0
,
max_part_id
=
max_partition
,
loc_part_id
;
uint
min_part_id
=
0
,
max_part_id
=
max_partition
,
loc_part_id
;
/* Get the partitioning function value for the endpoint */
/* Get the partitioning function value for the endpoint */
...
@@ -3476,46 +3474,45 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
...
@@ -3476,46 +3474,45 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
}
}
}
}
if
(
unsigned_flag
)
if
(
unsigned_flag
)
part_func_value
-=
0x8000000000000000ULL
;
part_func_value
-=
0x8000000000000000ULL
;
if
(
left_endpoint
&&
!
include_endpoint
)
if
(
left_endpoint
&&
!
include_endpoint
)
part_func_value
++
;
part_func_value
++
;
/*
Search for the partition containing part_func_value
(including the right endpoint).
*/
while
(
max_part_id
>
min_part_id
)
while
(
max_part_id
>
min_part_id
)
{
{
loc_part_id
=
(
max_part_id
+
min_part_id
+
1
)
>>
1
;
loc_part_id
=
(
max_part_id
+
min_part_id
)
/
2
;
if
(
range_array
[
loc_part_id
]
<
=
part_func_value
)
if
(
range_array
[
loc_part_id
]
<
part_func_value
)
min_part_id
=
loc_part_id
+
1
;
min_part_id
=
loc_part_id
+
1
;
else
else
max_part_id
=
loc_part_id
-
1
;
max_part_id
=
loc_part_id
;
}
}
loc_part_id
=
max_part_id
;
loc_part_id
=
max_part_id
;
if
(
loc_part_id
<
max_partition
&&
part_func_value
>=
range_array
[
loc_part_id
+
1
])
/* Adjust for endpoints */
{
part_end_val
=
range_array
[
loc_part_id
];
loc_part_id
++
;
}
if
(
left_endpoint
)
if
(
left_endpoint
)
{
{
longlong
bound
=
range_array
[
loc_part_id
];
/*
/*
In case of PARTITION p VALUES LESS THAN MAXVALUE
In case of PARTITION p VALUES LESS THAN MAXVALUE
the maximum value is in the current partition.
the maximum value is in the current partition.
*/
*/
if
(
part_func_value
>
bound
||
if
(
part_func_value
==
part_end_val
&&
(
part_func_value
==
bound
&&
(
loc_part_id
<
max_partition
||
!
part_info
->
defined_max_value
))
(
!
part_info
->
defined_max_value
||
loc_part_id
<
max_partition
)))
loc_part_id
++
;
loc_part_id
++
;
}
}
else
else
{
{
if
(
loc_part_id
<
max_partition
)
/* if 'WHERE <= X' and partition is LESS THAN (X) include next partition */
{
if
(
include_endpoint
&&
loc_part_id
<
max_partition
&&
if
(
part_func_value
==
range_array
[
loc_part_id
])
part_func_value
==
part_end_val
)
loc_part_id
+=
test
(
include_endpoint
);
else
if
(
part_func_value
>
range_array
[
loc_part_id
])
loc_part_id
++
;
loc_part_id
++
;
}
/* Right endpoint, set end after correct partition */
loc_part_id
++
;
loc_part_id
++
;
}
}
DBUG_RETURN
(
loc_part_id
);
DBUG_RETURN
(
loc_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