summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2005-05-03 07:42:36 +0000
committerunknown <sergefp@mysql.com>2005-05-03 07:42:36 +0000
commite4ecb68d9027f271c8fcf9584e26c5c8d41a9492 (patch)
tree158edff841ba01f792b082ee1fd8cf77addeeae3
parente3d2bb40554d27a4f5d81e5d6e6e48a7aeab174d (diff)
parentf5955f4d872db92ada4574ff761bca732fe8bb41 (diff)
downloadmariadb-git-e4ecb68d9027f271c8fcf9584e26c5c8d41a9492.tar.gz
Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/psergey/mysql-5.0-test-valgrind
-rw-r--r--sql/opt_range.cc25
-rw-r--r--sql/opt_range.h6
-rw-r--r--sql/sql_select.cc3
3 files changed, 25 insertions, 9 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 95fe003770b..7dfee132ea9 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -5513,14 +5513,26 @@ bool QUICK_ROR_UNION_SELECT::check_if_keys_used(List<Item> *fields)
}
-/****************************************************************************
- Create a QUICK RANGE based on a key
- This allocates things in a new memory root, as this may be called many times
- during a query.
-****************************************************************************/
+/*
+ Create quick select from ref/ref_or_null scan.
+ SYNOPSIS
+ 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,
- TABLE_REF *ref)
+ TABLE_REF *ref, ha_rows records)
{
MEM_ROOT *old_root= 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,
delete quick;
goto err;
}
+ quick->records= records;
if (cp_buffer_from_ref(thd,ref) && thd->is_fatal_error ||
!(range= new QUICK_RANGE()))
diff --git a/sql/opt_range.h b/sql/opt_range.h
index 97d646cedbe..71680b5a1fc 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -281,7 +281,8 @@ protected:
friend class TRP_ROR_INTERSECT;
friend
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,
QUICK_RANGE_SELECT *quick,KEY_PART *key,
SEL_ARG *key_tree,
@@ -709,5 +710,6 @@ public:
};
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
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 18172eb1f03..32624bb3305 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -11002,7 +11002,8 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
*/
if (!(select->quick= (tab->type == JT_FT ?
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;
}
}