Commit fe40de6f authored by unknown's avatar unknown

Fix for BUG#10244:

Make get_quick_select_for_ref() accept estimated # records as parameter and 
set QUICK_RANGE_SELECT::records, as this value is used to allocate buffers 
in Multi-Range Read. 


sql/opt_range.cc:
  Make get_quick_select_for_ref() accept estimated # records as parameter and 
  set QUICK_RANGE_SELECT::records, as this value is used to allocate buffers 
  in Multi-Range Read.
sql/opt_range.h:
  Added "records" parameter to get_quick_select_for_ref()
sql/sql_select.cc:
  Added "records" parameter to get_quick_select_for_ref()
parent 2ea08720
...@@ -5513,14 +5513,26 @@ bool QUICK_ROR_UNION_SELECT::check_if_keys_used(List<Item> *fields) ...@@ -5513,14 +5513,26 @@ bool QUICK_ROR_UNION_SELECT::check_if_keys_used(List<Item> *fields)
} }
/**************************************************************************** /*
Create a QUICK RANGE based on a key Create quick select from ref/ref_or_null scan.
This allocates things in a new memory root, as this may be called many times SYNOPSIS
during a query. get_quick_select_for_ref()
****************************************************************************/ thd Thread handle
table Table to access
ref ref[_or_null] scan parameters
records Estimate of number of records (needed only to construct
quick select)
NOTES
This allocates things in a new memory root, as this may be called many
times during a query.
RETURN
Quick select that retrieves the same rows as passed ref scan
NULL on error.
*/
QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
TABLE_REF *ref) TABLE_REF *ref, ha_rows records)
{ {
MEM_ROOT *old_root= thd->mem_root; MEM_ROOT *old_root= thd->mem_root;
/* The following call may change thd->mem_root */ /* The following call may change thd->mem_root */
...@@ -5537,6 +5549,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, ...@@ -5537,6 +5549,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
delete quick; delete quick;
goto err; goto err;
} }
quick->records= records;
if (cp_buffer_from_ref(thd,ref) && thd->is_fatal_error || if (cp_buffer_from_ref(thd,ref) && thd->is_fatal_error ||
!(range= new QUICK_RANGE())) !(range= new QUICK_RANGE()))
......
...@@ -281,7 +281,8 @@ protected: ...@@ -281,7 +281,8 @@ protected:
friend class TRP_ROR_INTERSECT; friend class TRP_ROR_INTERSECT;
friend friend
QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
struct st_table_ref *ref); struct st_table_ref *ref,
ha_rows records);
friend bool get_quick_keys(struct st_qsel_param *param, friend bool get_quick_keys(struct st_qsel_param *param,
QUICK_RANGE_SELECT *quick,KEY_PART *key, QUICK_RANGE_SELECT *quick,KEY_PART *key,
SEL_ARG *key_tree, SEL_ARG *key_tree,
...@@ -709,5 +710,6 @@ public: ...@@ -709,5 +710,6 @@ public:
}; };
QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
struct st_table_ref *ref); struct st_table_ref *ref,
ha_rows records);
#endif #endif
...@@ -10971,7 +10971,8 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, ...@@ -10971,7 +10971,8 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
*/ */
if (!(select->quick= (tab->type == JT_FT ? if (!(select->quick= (tab->type == JT_FT ?
new FT_SELECT(thd, table, tab->ref.key) : new FT_SELECT(thd, table, tab->ref.key) :
get_quick_select_for_ref(thd, table, &tab->ref)))) get_quick_select_for_ref(thd, table, &tab->ref,
tab->found_records))))
goto err; goto err;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment