Commit c499df92 authored by Mattias Jonsson's avatar Mattias Jonsson

Bug#35745: SELECT COUNT(*) is not correct for some partitioned tables.

problem was that ha_partition::records was not implemented, thus
using the default handler::records, which is not correct if the engine
does not support HA_STATS_RECORDS_IS_EXACT.
Solution was to implement ha_partition::records as a wrapper around
the underlying partitions records.

The rows column in explain partitions will now include the total
number of records in the partitioned table.

(recommit after removing out-commented code)
parent 0a638f6b
...@@ -1131,7 +1131,7 @@ NULL ...@@ -1131,7 +1131,7 @@ NULL
2 2
explain partitions select * from t1 where a is null or a < 0 or a > 1; explain partitions select * from t1 where a is null or a < 0 or a > 1;
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 t1 pn,p2 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 pn,p2 ALL NULL NULL NULL NULL 4 Using where
drop table t1; drop table t1;
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, name VARCHAR(20)) CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, name VARCHAR(20))
ENGINE=MyISAM DEFAULT CHARSET=latin1 ENGINE=MyISAM DEFAULT CHARSET=latin1
......
...@@ -69,25 +69,25 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -69,25 +69,25 @@ 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 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); 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 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 1 SIMPLE t1 p0,p2,p3 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a is null; explain partitions select * from t1 where a is null;
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 t1 p0 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a is not null; explain partitions select * from t1 where a is not null;
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 t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where 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; 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 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 1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a >= 3 and a <= 5; 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 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 1 SIMPLE t1 p1,p2 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a > 2 and a < 4; 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 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 1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a > 3 and a <= 6; 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 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 1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a > 5; explain partitions select * from t1 where 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 t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where 1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where
......
This diff is collapsed.
...@@ -57,13 +57,13 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -57,13 +57,13 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull system NULL NULL NULL NULL 1 1 SIMPLE t1 pnull system NULL NULL NULL NULL 1
explain partitions select * from t1 where a >= 0; explain partitions select * from t1 where a >= 0;
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 t1 p0,p1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t1 where a < 0; explain partitions select * from t1 where a < 0;
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
explain partitions select * from t1 where a <= 0; explain partitions select * from t1 where a <= 0;
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 t1 pnull,p0 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 pnull,p0 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t1 where a > 1; explain partitions select * from t1 where a > 1;
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
...@@ -96,16 +96,16 @@ select * from t1 where a > 1; ...@@ -96,16 +96,16 @@ select * from t1 where a > 1;
a b a b
explain partitions select * from t1 where a is null; explain partitions select * from t1 where a is null;
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 t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 6 Using where
explain partitions select * from t1 where a >= 0; explain partitions select * from t1 where a >= 0;
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 t1 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 6 Using where
explain partitions select * from t1 where a < 0; explain partitions select * from t1 where a < 0;
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 t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 6 Using where
explain partitions select * from t1 where a <= 0; explain partitions select * from t1 where a <= 0;
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 t1 pnull_pnullsp0,pnull_pnullsp1,p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1,p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 6 Using where
explain partitions select * from t1 where a > 1; explain partitions select * from t1 where a > 1;
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
......
...@@ -134,7 +134,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -134,7 +134,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 part1 ALL NULL NULL NULL NULL 7 Using where 1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -153,7 +153,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -153,7 +153,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p0 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -169,7 +169,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -169,7 +169,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p0 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -197,7 +197,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -197,7 +197,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p6 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -212,7 +212,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -212,7 +212,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p4 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -227,7 +227,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -227,7 +227,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p0 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -242,7 +242,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -242,7 +242,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p0 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -257,7 +257,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -257,7 +257,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 part1 ALL NULL NULL NULL NULL 7 Using where 1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -272,7 +272,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -272,7 +272,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p0 ALL NULL NULL NULL NULL 10 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -391,7 +391,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -391,7 +391,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 part7 ALL NULL NULL NULL NULL 7 Using where 1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -410,7 +410,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -410,7 +410,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 part7 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -429,7 +429,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -429,7 +429,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 p6 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -455,7 +455,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -455,7 +455,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 p0 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -473,7 +473,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -473,7 +473,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 part7 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -491,7 +491,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -491,7 +491,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 p4 ALL NULL NULL NULL NULL 10 Using where 1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 23 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -509,7 +509,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -509,7 +509,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 part7 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -527,7 +527,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -527,7 +527,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 part7 ALL NULL NULL NULL NULL 7 Using where 1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -545,7 +545,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -545,7 +545,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 p0 ALL NULL NULL NULL NULL 10 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
......
...@@ -148,7 +148,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -148,7 +148,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 part1 ALL NULL NULL NULL NULL 7 Using where 1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -175,7 +175,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -175,7 +175,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p0 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -207,7 +207,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -207,7 +207,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p0 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -249,7 +249,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -249,7 +249,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p6 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -276,7 +276,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -276,7 +276,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p4 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -301,7 +301,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -301,7 +301,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p0 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -324,7 +324,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -324,7 +324,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p0 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -345,7 +345,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -345,7 +345,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 part1 ALL NULL NULL NULL NULL 7 Using where 1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -364,7 +364,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -364,7 +364,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
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 t1 p0 ALL NULL NULL NULL NULL 10 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -491,7 +491,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -491,7 +491,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 part7 ALL NULL NULL NULL NULL 7 Using where 1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -518,7 +518,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -518,7 +518,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 part7 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -553,7 +553,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -553,7 +553,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 p6 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -593,7 +593,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -593,7 +593,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 p0 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -623,7 +623,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -623,7 +623,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 part7 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -651,7 +651,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -651,7 +651,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 p4 ALL NULL NULL NULL NULL 10 Using where 1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -677,7 +677,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -677,7 +677,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 part7 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -701,7 +701,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -701,7 +701,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 part7 ALL NULL NULL NULL NULL 7 Using where 1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
...@@ -723,7 +723,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm ...@@ -723,7 +723,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
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 t1 p0 ALL NULL NULL NULL NULL 10 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1 # check read single success: 1
# check read all success: 1 # check read all success: 1
# check read row by row success: 1 # check read row by row success: 1
......
...@@ -5364,6 +5364,34 @@ ha_rows ha_partition::estimate_rows_upper_bound() ...@@ -5364,6 +5364,34 @@ ha_rows ha_partition::estimate_rows_upper_bound()
} }
/**
Number of rows in table. see handler.h
SYNOPSIS
records()
RETURN VALUE
Number of total rows in a partitioned table.
*/
ha_rows ha_partition::records()
{
ha_rows rows, tot_rows= 0;
handler **file;
DBUG_ENTER("ha_partition::records");
file= m_file;
do
{
rows= (*file)->records();
if (rows == HA_POS_ERROR)
DBUG_RETURN(HA_POS_ERROR);
tot_rows+= rows;
} while (*(++file));
DBUG_RETURN(tot_rows);
}
/* /*
Is it ok to switch to a new engine for this table Is it ok to switch to a new engine for this table
......
...@@ -531,6 +531,7 @@ public: ...@@ -531,6 +531,7 @@ public:
underlying handlers must have the same implementation for it to work. underlying handlers must have the same implementation for it to work.
*/ */
virtual uint8 table_cache_type(); virtual uint8 table_cache_type();
virtual ha_rows records();
/* /*
------------------------------------------------------------------------- -------------------------------------------------------------------------
......
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