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.
2
2
3
3
This program is free software; you can redistribute it and/or modify
4
4
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,
92
92
/* Fall through. */
93
93
case HA_KEYTYPE_VARTEXT1 :
94
94
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 ;
96
103
/* Save number of bytes used to store length */
97
104
keyinfo -> seg [j ].bit_start = 1 ;
98
105
break ;
@@ -101,7 +108,14 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
101
108
/* fall_through */
102
109
case HA_KEYTYPE_VARTEXT2 :
103
110
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 ;
105
119
/* Save number of bytes used to store length */
106
120
keyinfo -> seg [j ].bit_start = 2 ;
107
121
/*
0 commit comments