summaryrefslogtreecommitdiff
path: root/sql/filesort.cc
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2002-09-15 01:23:01 +0300
committerunknown <monty@mashka.mysql.fi>2002-09-15 01:23:01 +0300
commit20ec6183fe860601d10dee2b0277e6c9a039b7f6 (patch)
tree238747caeb6d780bfb24e31af82bb68fcaf86ea2 /sql/filesort.cc
parent6a06c4c534ac68f9d0469f31c869fe1d20b1e463 (diff)
downloadmariadb-git-20ec6183fe860601d10dee2b0277e6c9a039b7f6.tar.gz
Fixed core dump bug in ORDER BY ... LIMIT
Docs/manual.texi: Changelog
Diffstat (limited to 'sql/filesort.cc')
-rw-r--r--sql/filesort.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 86c95395965..ee87d508dd3 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -378,13 +378,18 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
if (indexpos >= *maxbuffer ||
write_keys(param,sort_keys,idx,buffpek+indexpos,tempfile))
DBUG_RETURN(HA_POS_ERROR);
- idx=0; indexpos++;
+ idx=0;
if (param->ref_length == param->sort_length &&
my_b_tell(tempfile)/param->sort_length >= param->max_rows)
{
+ /*
+ We are writing the result index file and have found all
+ rows that we need. Abort the sort and return the result.
+ */
error=HA_ERR_END_OF_FILE;
break; /* Found enough records */
}
+ indexpos++;
}
make_sortkey(param,sort_keys[idx++],ref_pos);
}
@@ -399,7 +404,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
file->print_error(error,MYF(ME_ERROR | ME_WAITTANG)); /* purecov: inspected */
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
}
- if (indexpos)
+ if (indexpos && idx)
if (indexpos >= *maxbuffer ||
write_keys(param,sort_keys,idx,buffpek+indexpos,tempfile))
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */