summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc33
1 files changed, 26 insertions, 7 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7e7bd7a21ae..7af39071561 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -13066,7 +13066,8 @@ static int
join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count)
{
reg1 uint i;
- uint length,blobs,size;
+ uint length, blobs;
+ size_t size;
CACHE_FIELD *copy,**blob_ptr;
JOIN_CACHE *cache;
JOIN_TAB *join_tab;
@@ -13182,7 +13183,7 @@ store_record_in_cache(JOIN_CACHE *cache)
length=cache->length;
if (cache->blobs)
length+=used_blob_length(cache->blob_ptr);
- if ((last_record=(length+cache->length > (uint) (cache->end - pos))))
+ if ((last_record= (length + cache->length > (size_t) (cache->end - pos))))
cache->ptr_record=cache->records;
/*
@@ -13228,7 +13229,7 @@ store_record_in_cache(JOIN_CACHE *cache)
}
}
cache->pos=pos;
- return last_record || (uint) (cache->end -pos) < cache->length;
+ return last_record || (size_t) (cache->end - pos) < cache->length;
}
@@ -13901,13 +13902,31 @@ calc_group_buffer(JOIN *join,ORDER *group)
group_item->decimals);
break;
case STRING_RESULT:
+ {
+ enum enum_field_types type= group_item->field_type();
/*
- Group strings are taken as varstrings and require an length field.
- A field is not yet created by create_tmp_field()
- and the sizes should match up.
+ As items represented as DATE/TIME fields in the group buffer
+ have STRING_RESULT result type, we increase the length
+ by 8 as maximum pack length of such fields.
*/
- key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH;
+ if (type == MYSQL_TYPE_TIME ||
+ type == MYSQL_TYPE_DATE ||
+ type == MYSQL_TYPE_DATETIME ||
+ type == MYSQL_TYPE_TIMESTAMP)
+ {
+ key_length+= 8;
+ }
+ else
+ {
+ /*
+ Group strings are taken as varstrings and require an length field.
+ A field is not yet created by create_tmp_field()
+ and the sizes should match up.
+ */
+ key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH;
+ }
break;
+ }
default:
/* This case should never be choosen */
DBUG_ASSERT(0);