summaryrefslogtreecommitdiff
path: root/sql/uniques.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-07-12 19:20:52 +0200
committerSergei Golubchik <serg@mariadb.org>2017-07-12 19:20:52 +0200
commite7f51e5d269ba8adb917226724564274a57d07b3 (patch)
tree0fc76e75f3893aeb28b39faedb24fa073b486a69 /sql/uniques.cc
parent181d9d2892739629382727cf956364106c947ea2 (diff)
downloadmariadb-git-e7f51e5d269ba8adb917226724564274a57d07b3.tar.gz
MDEV-12136 SELECT COUNT(DISTINCT) returns the wrong value when tmp_table_size is limited
use the correct value for the merge_buffer size, max_in_memory_size is too small and merge_walk() fails. also: remove a cast.
Diffstat (limited to 'sql/uniques.cc')
-rw-r--r--sql/uniques.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/sql/uniques.cc b/sql/uniques.cc
index fe3e329cda6..f80117065dd 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -461,7 +461,7 @@ C_MODE_END
<> 0 error
*/
-static bool merge_walk(uchar *merge_buffer, ulong merge_buffer_size,
+static bool merge_walk(uchar *merge_buffer, size_t merge_buffer_size,
uint key_length, BUFFPEK *begin, BUFFPEK *end,
tree_walk_action walk_action, void *walk_action_arg,
qsort_cmp2 compare, void *compare_arg,
@@ -470,7 +470,7 @@ static bool merge_walk(uchar *merge_buffer, ulong merge_buffer_size,
BUFFPEK_COMPARE_CONTEXT compare_context = { compare, compare_arg };
QUEUE queue;
if (end <= begin ||
- merge_buffer_size < (ulong) (key_length * (end - begin + 1)) ||
+ merge_buffer_size < (size_t) (key_length * (end - begin + 1)) ||
init_queue(&queue, (uint) (end - begin), offsetof(BUFFPEK, key), 0,
buffpek_compare, &compare_context, 0, 0))
return 1;
@@ -615,7 +615,7 @@ bool Unique::walk(TABLE *table, tree_walk_action action, void *walk_action_arg)
if (!res)
{
- res= merge_walk(merge_buffer, (ulong) max_in_memory_size, full_size,
+ res= merge_walk(merge_buffer, buff_sz, full_size,
(BUFFPEK *) file_ptrs.buffer,
(BUFFPEK *) file_ptrs.buffer + file_ptrs.elements,
action, walk_action_arg,