Skip to content

Commit 241a723

Browse files
author
Arun Kuruvila
committed
Merge branch 'mysql-5.6' into mysql-5.7
2 parents 06f91f5 + ffe1610 commit 241a723

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

storage/heap/hp_create.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -92,7 +92,14 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
9292
/* Fall through. */
9393
case HA_KEYTYPE_VARTEXT1:
9494
keyinfo->flag|= HA_VAR_LENGTH_KEY;
95-
length+= 2;
95+
/*
96+
For BTREE algorithm, key length, greater than or equal
97+
to 255, is packed on 3 bytes.
98+
*/
99+
if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
100+
length+= size_to_store_key_length(keyinfo->seg[j].length);
101+
else
102+
length+= 2;
96103
/* Save number of bytes used to store length */
97104
keyinfo->seg[j].bit_start= 1;
98105
break;
@@ -101,7 +108,14 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
101108
/* fall_through */
102109
case HA_KEYTYPE_VARTEXT2:
103110
keyinfo->flag|= HA_VAR_LENGTH_KEY;
104-
length+= 2;
111+
/*
112+
For BTREE algorithm, key length, greater than or equal
113+
to 255, is packed on 3 bytes.
114+
*/
115+
if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
116+
length+= size_to_store_key_length(keyinfo->seg[j].length);
117+
else
118+
length+= 2;
105119
/* Save number of bytes used to store length */
106120
keyinfo->seg[j].bit_start= 2;
107121
/*

0 commit comments

Comments
 (0)