Commit 9f62dcfd authored by unknown's avatar unknown
Browse files

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
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -549,10 +549,7 @@ struct row_prebuilt_struct {
					format */
	ulint		hint_need_to_fetch_extra_cols;
					/* normally this is set to 0; if this
					is set to ROW_RETRIEVE_PRIMARY_KEY
					(that value is obsolete starting from
					5.0.2, because we always fetch the
					primary key cols),
					is set to ROW_RETRIEVE_PRIMARY_KEY,
					then we should at least retrieve all
					columns in the primary key; if this
					is set to ROW_RETRIEVE_ALL_COLS, then
@@ -625,9 +622,6 @@ struct row_prebuilt_struct {

/* Values for hint_need_to_fetch_extra_cols */
#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


+1 −7
Original line number Diff line number Diff line
@@ -2275,13 +2275,7 @@ build_template(
	ulint		n_fields;
	ulint		n_requested_fields	= 0;
	ibool		fetch_all_in_key	= FALSE;
	ibool		fetch_primary_key_cols	= TRUE; /* The ROR code in
						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. */ 
	ibool		fetch_primary_key_cols	= FALSE;
	ulint		i;

	if (prebuilt->select_lock_type == LOCK_X) {
+6 −4
Original line number Diff line number Diff line
@@ -897,7 +897,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
  {
    DBUG_PRINT("info", ("Reusing handler %p", file));
    if (file->extra(HA_EXTRA_KEYREAD) ||
        file->extra(HA_EXTRA_RETRIEVE_ALL_COLS) |
        file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) ||
        init() || reset())
    {
      DBUG_RETURN(1);
@@ -922,7 +922,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
  }

  if (file->extra(HA_EXTRA_KEYREAD) ||
      file->extra(HA_EXTRA_RETRIEVE_ALL_COLS) ||
      file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) ||
      init() || reset())
  {
    file->close();
@@ -5600,7 +5600,8 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
  DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::prepare_unique");

  /* 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
@@ -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
     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= cur_quick_it++;