summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorunknown <igor@olga.mysql.com>2007-02-10 23:55:56 -0800
committerunknown <igor@olga.mysql.com>2007-02-10 23:55:56 -0800
commit3e4f834dfbe4b7be9a53f8207bab7b9e59496ba1 (patch)
tree58b088ea256ea395eff1cb3e1489b63bd9c9aa51 /sql/opt_range.cc
parentce8c0ec29b85f336567cbf183008db89575f1fc8 (diff)
downloadmariadb-git-3e4f834dfbe4b7be9a53f8207bab7b9e59496ba1.tar.gz
Fixed bug #26159.
A wrong order of statements in QUICK_GROUP_MIN_MAX_SELECT::reset caused a crash when a query with DISTINCT was executed by a loose scan for an InnoDB table that had been emptied. mysql-test/r/innodb_mysql.result: Added a test case for bug #26159. mysql-test/t/innodb_mysql.test: Added a test case for bug #26159. sql/opt_range.cc: Fixed bug #26159. A wrong order of statements in QUICK_GROUP_MIN_MAX_SELECT::reset caused a crash when a query with DISTINCT was executed by a loose scan for an InnoDB table that had been emptied. For an empty table quick_prefix_select->reset() was not called at all and thus some important initialization steps were missing.
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 744d222b833..32cf6860d5c 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -8765,14 +8765,13 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void)
DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::reset");
file->extra(HA_EXTRA_KEYREAD); /* We need only the key attributes */
- result= file->ha_index_init(index);
- result= file->index_last(record);
- if (result == HA_ERR_END_OF_FILE)
- DBUG_RETURN(0);
- if (result)
+ if ((result= file->ha_index_init(index)))
DBUG_RETURN(result);
if (quick_prefix_select && quick_prefix_select->reset())
DBUG_RETURN(1);
+ result= file->index_last(record);
+ if (result == HA_ERR_END_OF_FILE)
+ DBUG_RETURN(0);
/* Save the prefix of the last group. */
key_copy(last_prefix, record, index_info, group_prefix_len);