1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fixed bug mdev-487.

The function collect_statistics_for_table() when scanning a table
did not take into account that the handler function ha_rnd_next
could return the code HA_ERR_RECORD_DELETE that should not be
considered as an indication of an error.
Also fixed a potential memory leak in this function.
This commit is contained in:
Igor Babaev
2012-08-27 14:19:25 -07:00
parent f4631d6f71
commit d0ad93fbc7
4 changed files with 65 additions and 6 deletions

View File

@ -179,6 +179,7 @@ public:
inline void init(THD *thd, Field * table_field);
inline void add(ha_rows rowno);
inline void finish(ha_rows rows);
inline void cleanup();
};
@ -1893,6 +1894,22 @@ void Column_statistics_collected::finish(ha_rows rows)
}
/**
@brief
Clean up auxiliary structures used for aggregation
*/
inline
void Column_statistics_collected::cleanup()
{
if (count_distinct)
{
delete count_distinct;
count_distinct= NULL;
}
}
/**
@brief
Collect statistical data on an index
@ -2047,7 +2064,11 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
break;
if (rc)
{
if (rc == HA_ERR_RECORD_DELETED)
continue;
break;
}
for (field_ptr= table->field; *field_ptr; field_ptr++)
{
@ -2071,14 +2092,17 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
{
table->collected_stats->cardinality_is_null= FALSE;
table->collected_stats->cardinality= rows;
}
for (field_ptr= table->field; *field_ptr; field_ptr++)
{
table_field= *field_ptr;
if (!bitmap_is_set(table->read_set, table_field->field_index))
continue;
for (field_ptr= table->field; *field_ptr; field_ptr++)
{
table_field= *field_ptr;
if (!bitmap_is_set(table->read_set, table_field->field_index))
continue;
if (!rc)
table_field->collected_stats->finish(rows);
}
else
table_field->collected_stats->cleanup();
}
if (!rc)