mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Merge of the mwl106 tree into the latest 5.3 tree.
Resolved conflicts. Adjusted some test results
This commit is contained in:
@@ -74,10 +74,12 @@ static int maxmin_in_range(bool max_fl, Field* field, COND *cond);
|
||||
# Multiplication of number of rows in all tables
|
||||
*/
|
||||
|
||||
static ulonglong get_exact_record_count(TABLE_LIST *tables)
|
||||
static ulonglong get_exact_record_count(List<TABLE_LIST> &tables)
|
||||
{
|
||||
ulonglong count= 1;
|
||||
for (TABLE_LIST *tl= tables; tl; tl= tl->next_leaf)
|
||||
TABLE_LIST *tl;
|
||||
List_iterator<TABLE_LIST> ti(tables);
|
||||
while ((tl= ti++))
|
||||
{
|
||||
ha_rows tmp= tl->table->file->records();
|
||||
if ((tmp == HA_POS_ERROR))
|
||||
@@ -110,9 +112,11 @@ static ulonglong get_exact_record_count(TABLE_LIST *tables)
|
||||
HA_ERR_... if a deadlock or a lock wait timeout happens, for example
|
||||
*/
|
||||
|
||||
int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
|
||||
int opt_sum_query(List<TABLE_LIST> &tables, List<Item> &all_fields,COND *conds)
|
||||
{
|
||||
List_iterator_fast<Item> it(all_fields);
|
||||
List_iterator<TABLE_LIST> ti(tables);
|
||||
TABLE_LIST *tl;
|
||||
int const_result= 1;
|
||||
bool recalc_const_item= 0;
|
||||
ulonglong count= 1;
|
||||
@@ -120,7 +124,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
|
||||
table_map removed_tables= 0, outer_tables= 0, used_tables= 0;
|
||||
table_map where_tables= 0;
|
||||
Item *item;
|
||||
int error;
|
||||
int error= 0;
|
||||
|
||||
if (conds)
|
||||
where_tables= conds->used_tables();
|
||||
@@ -129,7 +133,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
|
||||
Analyze outer join dependencies, and, if possible, compute the number
|
||||
of returned rows.
|
||||
*/
|
||||
for (TABLE_LIST *tl= tables; tl; tl= tl->next_leaf)
|
||||
while ((tl= ti++))
|
||||
{
|
||||
TABLE_LIST *embedded;
|
||||
for (embedded= tl ; embedded; embedded= embedded->embedding)
|
||||
@@ -170,6 +174,14 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
|
||||
is_exact_count= FALSE;
|
||||
count= 1; // ensure count != 0
|
||||
}
|
||||
else if (tl->is_materialized_derived())
|
||||
{
|
||||
/*
|
||||
Can't remove a derived table as it's number of rows is just an
|
||||
estimate.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
error= tl->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
|
||||
|
Reference in New Issue
Block a user