Commit 70f53b1a authored by Narayanan V's avatar Narayanan V

Bug#44337 Select query using index merge fails with MCH3601

The storage engine was not correctly handling the case in 
which rnd_pos is executed for a handler without a preceding
rnd_next or index read operation. As a result, an unitialized
file handle was sometimes being passed to the QMY_READ API.

The fix clears the rrnAssocHandle at the beginning of each
read operation and then checks to see whether it has been
set to a valid handle value before attempting to use it
in rnd_pos. If rrnAssocHandle has not been set by a previous
read operation, rnd_pos instead falls back to the use of the
currently active handle.

storage/ibmdb2i/ha_ibmdb2i.cc:
  Bug#44337 Select query using index merge fails with MCH3601
  
  - clear the rrnAssocHandle at the beginning of each
    read operation 
  - checks to see whether it has been set to a valid
    handle value before attempting to use it in rnd_pos
parent e7c4b2df
......@@ -898,6 +898,8 @@ int ha_ibmdb2i::index_init(uint idx, bool sorted)
releaseIndexFile(idx);
}
rrnAssocHandle= 0;
DBUG_RETURN(rc);
}
......@@ -1154,6 +1156,8 @@ int ha_ibmdb2i::rnd_init(bool scan)
releaseDataFile();
}
rrnAssocHandle= 0;
DBUG_RETURN(0); // MySQL sometimes does not check the return code, causing
// an assert in ha_rnd_end later on if we return a non-zero
// value here.
......@@ -1251,7 +1255,8 @@ int ha_ibmdb2i::rnd_pos(uchar * buf, uchar *pos)
int rc = 0;
if (activeHandle != rrnAssocHandle)
if (rrnAssocHandle &&
(activeHandle != rrnAssocHandle))
{
if (activeHandle) releaseActiveHandle();
rc = useFileByHandle(QMY_UPDATABLE, rrnAssocHandle);
......
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