Commit 9f62dcfd authored by unknown's avatar unknown

Make index_merge code call handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) if it

will call handler::position() during key scan. 
Undo the previous, less efficient fix (cset 2004-11-30 19:56:25+02:00, heikki@hundin.mysql.fi)


innobase/include/row0mysql.h:
  undo cset 1.1698.1.2
sql/ha_innodb.cc:
  undo cset 1.1698.1.2
sql/opt_range.cc:
  Make index_merge code call file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) if file->position() will be called.
  Also fixed a typo and added a couple of error checks.
parent 640287b3
...@@ -549,10 +549,7 @@ struct row_prebuilt_struct { ...@@ -549,10 +549,7 @@ struct row_prebuilt_struct {
format */ format */
ulint hint_need_to_fetch_extra_cols; ulint hint_need_to_fetch_extra_cols;
/* normally this is set to 0; if this /* normally this is set to 0; if this
is set to ROW_RETRIEVE_PRIMARY_KEY is set to ROW_RETRIEVE_PRIMARY_KEY,
(that value is obsolete starting from
5.0.2, because we always fetch the
primary key cols),
then we should at least retrieve all then we should at least retrieve all
columns in the primary key; if this columns in the primary key; if this
is set to ROW_RETRIEVE_ALL_COLS, then is set to ROW_RETRIEVE_ALL_COLS, then
...@@ -625,9 +622,6 @@ struct row_prebuilt_struct { ...@@ -625,9 +622,6 @@ struct row_prebuilt_struct {
/* Values for hint_need_to_fetch_extra_cols */ /* Values for hint_need_to_fetch_extra_cols */
#define ROW_RETRIEVE_PRIMARY_KEY 1 #define ROW_RETRIEVE_PRIMARY_KEY 1
/* value 1 is obsolete starting from
5.0.2, because we always fetch the
primary key cols */
#define ROW_RETRIEVE_ALL_COLS 2 #define ROW_RETRIEVE_ALL_COLS 2
......
...@@ -2275,13 +2275,7 @@ build_template( ...@@ -2275,13 +2275,7 @@ build_template(
ulint n_fields; ulint n_fields;
ulint n_requested_fields = 0; ulint n_requested_fields = 0;
ibool fetch_all_in_key = FALSE; ibool fetch_all_in_key = FALSE;
ibool fetch_primary_key_cols = TRUE; /* The ROR code in ibool fetch_primary_key_cols = FALSE;
opt_range.cc assumes that the
primary key cols are always
retrieved. Starting from
MySQL-5.0.2, let us always
fetch them, even though it
wastes some CPU. */
ulint i; ulint i;
if (prebuilt->select_lock_type == LOCK_X) { if (prebuilt->select_lock_type == LOCK_X) {
......
...@@ -897,7 +897,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler) ...@@ -897,7 +897,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
{ {
DBUG_PRINT("info", ("Reusing handler %p", file)); DBUG_PRINT("info", ("Reusing handler %p", file));
if (file->extra(HA_EXTRA_KEYREAD) || if (file->extra(HA_EXTRA_KEYREAD) ||
file->extra(HA_EXTRA_RETRIEVE_ALL_COLS) | file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) ||
init() || reset()) init() || reset())
{ {
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -922,7 +922,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler) ...@@ -922,7 +922,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
} }
if (file->extra(HA_EXTRA_KEYREAD) || if (file->extra(HA_EXTRA_KEYREAD) ||
file->extra(HA_EXTRA_RETRIEVE_ALL_COLS) || file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) ||
init() || reset()) init() || reset())
{ {
file->close(); file->close();
...@@ -5600,7 +5600,8 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() ...@@ -5600,7 +5600,8 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::prepare_unique"); DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::prepare_unique");
/* We're going to just read rowids. */ /* We're going to just read rowids. */
head->file->extra(HA_EXTRA_KEYREAD); if (head->file->extra(HA_EXTRA_KEYREAD))
DBUG_RETURN(1);
/* /*
Make innodb retrieve all PK member fields, so Make innodb retrieve all PK member fields, so
...@@ -5609,7 +5610,8 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() ...@@ -5609,7 +5610,8 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
(This also creates a deficiency - it is possible that we will retrieve (This also creates a deficiency - it is possible that we will retrieve
parts of key that are not used by current query at all.) parts of key that are not used by current query at all.)
*/ */
head->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); if (head->file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY))
DBUG_RETURN(1);
cur_quick_it.rewind(); cur_quick_it.rewind();
cur_quick= cur_quick_it++; cur_quick= cur_quick_it++;
......
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