diff options
author | unknown <sergefp@mysql.com> | 2004-11-28 21:02:30 +0300 |
---|---|---|
committer | unknown <sergefp@mysql.com> | 2004-11-28 21:02:30 +0300 |
commit | 46e12a2b482fbd133920c780042463ed03c790b3 (patch) | |
tree | 37cc761d872fa010824e1bffe1f03a627d58c154 /sql/opt_range.cc | |
parent | d2c7736c59403d8df8029773c3ea70202b27946b (diff) | |
download | mariadb-git-46e12a2b482fbd133920c780042463ed03c790b3.tar.gz |
Fix for division by zero problem:
* Don't try building ROR-intersect if the queried table has zero rows
* Don't ever produce an estimate of zero returned rows.
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ab2eb4fdb72..e92d266ba28 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2716,7 +2716,7 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, double min_cost= read_time; DBUG_ENTER("get_best_ror_intersect"); - if (tree->n_ror_scans < 2) + if ((tree->n_ror_scans < 2) || !param->table->file->records) DBUG_RETURN(NULL); /* @@ -2803,6 +2803,9 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, min_cost= intersect->total_cost; best_rows= (ha_rows)(intersect->records_fract* rows2double(param->table->file->records)); + /* Prevent divisons by zero */ + if (!best_rows) + best_rows= 1; is_best_covering= intersect->is_covering; intersect_scans_best= intersect_scans_end; best_index_scan_costs= intersect->index_scan_costs; @@ -2847,6 +2850,9 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, min_cost= intersect->total_cost; best_rows= (ha_rows)(intersect->records_fract* rows2double(param->table->file->records)); + /* Prevent divisons by zero */ + if (!best_rows) + best_rows= 1; is_best_covering= intersect->is_covering; best_index_scan_costs= intersect->index_scan_costs; } @@ -2866,7 +2872,7 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, trp->last_scan= trp->first_scan + best_num; trp->is_covering= is_best_covering; trp->read_cost= min_cost; - trp->records= best_rows? best_rows : 1; + trp->records= best_rows; trp->index_scan_costs= best_index_scan_costs; trp->cpk_scan= cpk_scan; DBUG_PRINT("info", |