mariadb/storage/myisammrg/myrg_records.c
gshchepa/uchum@host.loc 107b84f9bd 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.
2008-04-26 02:45:58 +05:00

27 lines
974 B
C

/* 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);
}