diff options
author | igor@rurik.mysql.com <> | 2005-01-22 02:40:27 -0800 |
---|---|---|
committer | igor@rurik.mysql.com <> | 2005-01-22 02:40:27 -0800 |
commit | 8527f256c0688a4ecbd79b60534184a92b5d755f (patch) | |
tree | 90460d8fd1c844f7b11a3d231d91cb3d16e21035 /sql/sql_select.cc | |
parent | 32155507358c25178b026af48f72fc8c14fd56db (diff) | |
download | mariadb-git-8527f256c0688a4ecbd79b60534184a92b5d755f.tar.gz |
select_found.result, select_found.test:
Added a test case for bug #7945.
sql_select.cc:
Fixed bug #7945. If DISTINCT is used only with constants
in a query with GROUP BY, we can apply an optimization
that set LIMIT to 1 only in the case when there is
no SQL_CALC_FOUND_ROWS.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index eda4ce73186..468cdf05d36 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2114,9 +2114,15 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, x = used key parts (1 <= x <= c) */ double rec_per_key; +#if 0 if (!(rec_per_key=(double) keyinfo->rec_per_key[keyinfo->key_parts-1])) rec_per_key=(double) s->records/rec+1; +#else + rec_per_key= keyinfo->rec_per_key[keyinfo->key_parts-1] ? + (double) keyinfo->rec_per_key[keyinfo->key_parts-1] : + (double) s->records/rec+1; +#endif if (!s->records) tmp=0; @@ -6276,13 +6282,14 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having) field_count++; } - if (!field_count) - { // only const items + if (!field_count && !(join->select_options & OPTION_FOUND_ROWS)) + { // only const items with no OPTION_FOUND_ROWS join->thd->select_limit=1; // Only send first row DBUG_RETURN(0); } Field **first_field=entry->field+entry->fields - field_count; - offset=entry->field[entry->fields - field_count]->offset(); + offset= field_count ? + entry->field[entry->fields - field_count]->offset() : 0; reclength=entry->reclength-offset; free_io_cache(entry); // Safety |