From d130cef4162bdd0d543395e2c9ff8d47e553d1e2 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 2 May 2014 15:47:50 -0700 Subject: [PATCH] Fixed the problem of mdev-6198: statistics.test fails in valgrind. The problem appeared when a loose scan used a key prefix whose last component called uint3korr in the implementation of the key_cmp virtual function. --- sql/opt_range.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index d4f171321e0..bfba74cf587 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -13755,15 +13755,21 @@ int QUICK_GROUP_MIN_MAX_SELECT::init() { if (group_prefix) /* Already initialized. */ return 0; - - if (!(last_prefix= (uchar*) alloc_root(&alloc, group_prefix_len))) + + /* + We allocate one byte more to serve the case when the last field in + the buffer is compared using uint3korr (e.g. a Field_newdate field) + */ + if (!(last_prefix= (uchar*) alloc_root(&alloc, group_prefix_len+1))) return 1; /* We may use group_prefix to store keys with all select fields, so allocate enough space for it. + We allocate one byte more to serve the case when the last field in + the buffer is compared using uint3korr (e.g. a Field_newdate field) */ if (!(group_prefix= (uchar*) alloc_root(&alloc, - real_prefix_len + min_max_arg_len))) + real_prefix_len+min_max_arg_len+1))) return 1; if (key_infix_len > 0)