summaryrefslogtreecommitdiff
path: root/sql/ha_partition.cc
diff options
context:
space:
mode:
authorMattias Jonsson <mattiasj@mysql.com>2008-07-07 22:42:19 +0200
committerMattias Jonsson <mattiasj@mysql.com>2008-07-07 22:42:19 +0200
commitd11d5cfca87f25cad0f5b0af90616afe9290dece (patch)
treee1224dcd11282eb716f4192d492e0370811a9c4e /sql/ha_partition.cc
parent50853ac31a5f158d02c986a9eec5144cf20d00b9 (diff)
downloadmariadb-git-d11d5cfca87f25cad0f5b0af90616afe9290dece.tar.gz
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)
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r--sql/ha_partition.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 3a78e6601f0..b06e2572f44 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -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