Below is the list of changes that have just been committed into a local
5.1 repository of mattiasj. When mattiasj does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-04-02 14:09:46+02:00, mattiasj@stripped +3 -0
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, including checking pruning.
mysql-test/r/partition_innodb.result@stripped, 2008-04-02 14:09:44+02:00, mattiasj@stripped +1 -1
Bug#35745: SELECT COUNT(*) is not correct for some partitioned tables.
Updated test result due to a more correct version, after adding
ha_partition::records
sql/ha_partition.cc@stripped, 2008-04-02 14:09:45+02:00, mattiasj@stripped +31 -0
Bug#35745: SELECT COUNT(*) is not correct for some partitioned tables.
Added ha_partition::records
sql/ha_partition.h@stripped, 2008-04-02 14:09:45+02:00, mattiasj@stripped +1 -0
Bug#35745: SELECT COUNT(*) is not correct for some partitioned tables.
Added ha_partition::records
diff -Nrup a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result
--- a/mysql-test/r/partition_innodb.result 2008-03-07 22:46:20 +01:00
+++ b/mysql-test/r/partition_innodb.result 2008-04-02 14:09:44 +02:00
@@ -60,7 +60,7 @@ partition p1 values less than (2007));
explain partitions select * from t1
where a between '2006-01-01' and '2007-06-01';
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 1 Using where
drop table t1;
create table t1 (a int)
engine = x
diff -Nrup a/sql/ha_partition.cc b/sql/ha_partition.cc
--- a/sql/ha_partition.cc 2008-03-17 15:56:51 +01:00
+++ b/sql/ha_partition.cc 2008-04-02 14:09:45 +02:00
@@ -5360,6 +5360,37 @@ ha_rows ha_partition::estimate_rows_uppe
}
+/**
+ 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
+ {
+ if (bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+ {
+ rows= (*file)->records();
+ if (rows == HA_POS_ERROR)
+ DBUG_RETURN(rows);
+ tot_rows+= rows;
+ }
+ } while (*(++file));
+ DBUG_RETURN(tot_rows);
+}
+
+
/*
Is it ok to switch to a new engine for this table
diff -Nrup a/sql/ha_partition.h b/sql/ha_partition.h
--- a/sql/ha_partition.h 2007-09-24 15:30:28 +02:00
+++ b/sql/ha_partition.h 2008-04-02 14:09:45 +02:00
@@ -531,6 +531,7 @@ public:
underlying handlers must have the same implementation for it to work.
*/
virtual uint8 table_cache_type();
+ virtual ha_rows records();
/*
-------------------------------------------------------------------------
| Thread |
|---|
| • bk commit into 5.1 tree (mattiasj:1.2576) BUG#35745 | mattiasj | 2 Apr |