summaryrefslogtreecommitdiff
path: root/storage/myisammrg
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@host.loc>2008-04-26 02:45:58 +0500
committerunknown <gshchepa/uchum@host.loc>2008-04-26 02:45:58 +0500
commitbbcf9847073db9e8c6fb331095668466fb115120 (patch)
tree168fdf05aa71e4176ac8753ebb98afdbd5b05dca /storage/myisammrg
parent88837ab608c4eb5143210db6134222261a54ada0 (diff)
downloadmariadb-git-bbcf9847073db9e8c6fb331095668466fb115120.tar.gz
Fixed bug#36006: Optimizer does table scan for SELECT COUNT(*)
for ENGINE=MRG_MYISAM (should be optimized out). Before WL#3281 MERGE engine had the HA_NOT_EXACT_COUNT flag unset, and it worked with COUNT optimization as desired. After the removal of the HA_NOT_EXACT_COUNT flag neither HA_STATS_RECORDS_IS_EXACT (opposite to former HA_NOT_EXACT_COUNT flag) nor modern HA_HAS_RECORDS flag were not added to MERGE table flag mask. 1. The HA_HAS_RECORDS table flag has been set. 2. The ha_myisammrg::records method has been overridden to calculate total number of records in underlying tables. storage/myisammrg/myrg_records.c: Fixed bug#36006: Optimizer does table scan for select count(*). The myrg_records function has been added to calculate total number of records in underlying tables. include/myisammrg.h: Fixed bug#36006: Optimizer does table scan for select count(*). The myrg_records function declaration has been added. mysql-test/r/merge.result: Added test case for bug#36006. mysql-test/t/merge.test: Added test case for bug#36006. storage/myisammrg/CMakeLists.txt: Fixed bug#36006: Optimizer does table scan for select count(*). New myrg_records.c file has been added. storage/myisammrg/Makefile.am: Fixed bug#36006: Optimizer does table scan for select count(*). New myrg_records.c file has been added. storage/myisammrg/ha_myisammrg.cc: Fixed bug#36006: Optimizer does table scan for select count(*). The ha_myisammrg::records method has been overridden. storage/myisammrg/ha_myisammrg.h: Fixed bug#36006: Optimizer does table scan for select count(*). 1. The HA_HAS_RECORDS table flag has been set. 2. The ha_myisammrg::records method has been overridden.
Diffstat (limited to 'storage/myisammrg')
-rwxr-xr-xstorage/myisammrg/CMakeLists.txt2
-rw-r--r--storage/myisammrg/Makefile.am2
-rw-r--r--storage/myisammrg/ha_myisammrg.cc6
-rw-r--r--storage/myisammrg/ha_myisammrg.h2
-rw-r--r--storage/myisammrg/myrg_records.c27
5 files changed, 37 insertions, 2 deletions
diff --git a/storage/myisammrg/CMakeLists.txt b/storage/myisammrg/CMakeLists.txt
index 403ca6c2776..1c94e2bd50c 100755
--- a/storage/myisammrg/CMakeLists.txt
+++ b/storage/myisammrg/CMakeLists.txt
@@ -26,7 +26,7 @@ SET(MYISAMMRG_SOURCES myrg_close.c myrg_create.c myrg_delete.c myrg_extra.c myr
myrg_locking.c myrg_open.c myrg_panic.c myrg_queue.c myrg_range.c
myrg_rfirst.c myrg_rkey.c myrg_rlast.c myrg_rnext.c myrg_rnext_same.c
myrg_rprev.c myrg_rrnd.c myrg_rsame.c myrg_static.c myrg_update.c
- myrg_write.c)
+ myrg_write.c myrg_records.c)
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(myisammrg ${MYISAMMRG_SOURCES})
diff --git a/storage/myisammrg/Makefile.am b/storage/myisammrg/Makefile.am
index e058dfdbb5e..1ca51bc9d03 100644
--- a/storage/myisammrg/Makefile.am
+++ b/storage/myisammrg/Makefile.am
@@ -35,7 +35,7 @@ libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \
ha_myisammrg.cc \
- myrg_rnext_same.c
+ myrg_rnext_same.c myrg_records.c
EXTRA_DIST = CMakeLists.txt plug.in
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index ea7021325e3..956f0e421cc 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -1154,6 +1154,12 @@ int ha_myisammrg::check(THD* thd, HA_CHECK_OPT* check_opt)
}
+ha_rows ha_myisammrg::records()
+{
+ return myrg_records(file);
+}
+
+
extern int myrg_panic(enum ha_panic_function flag);
int myisammrg_panic(handlerton *hton, ha_panic_function flag)
{
diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h
index 977c45d1435..4e7ddebb836 100644
--- a/storage/myisammrg/ha_myisammrg.h
+++ b/storage/myisammrg/ha_myisammrg.h
@@ -42,6 +42,7 @@ class ha_myisammrg: public handler
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED |
HA_ANY_INDEX_MAY_BE_UNIQUE | HA_CAN_BIT_FIELD |
+ HA_HAS_RECORDS |
HA_NO_COPY_ON_ALTER);
}
ulong index_flags(uint inx, uint part, bool all_parts) const
@@ -94,4 +95,5 @@ class ha_myisammrg: public handler
TABLE *table_ptr() { return table; }
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
int check(THD* thd, HA_CHECK_OPT* check_opt);
+ ha_rows records();
};
diff --git a/storage/myisammrg/myrg_records.c b/storage/myisammrg/myrg_records.c
new file mode 100644
index 00000000000..03815d934a8
--- /dev/null
+++ b/storage/myisammrg/myrg_records.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2008 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include "myrg_def.h"
+
+ha_rows myrg_records(MYRG_INFO *info)
+{
+ ha_rows records=0;
+ MYRG_TABLE *file;
+ DBUG_ENTER("myrg_records");
+
+ for (file=info->open_tables ; file != info->end_table ; file++)
+ records+= file->table->s->state.state.records;
+ DBUG_RETURN(records);
+}