Skip to content

Commit a542209

Browse files
BUG#26529369: CREATE INDEX WITH LONG COMMENT CAUSE
UNEXPECTED ERROR ANALYSIS: ========= Creating many indexes with large amount of index information causes a server exit. FIX: ==== A appropriate error is reported when the cumulative index information length exceeds the 2 byte range (i.e 65535).
1 parent 84c32cd commit a542209

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

sql/unireg.cc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -283,6 +283,25 @@ bool mysql_create_frm(THD *thd, const char *file_name,
283283
keybuff=(uchar*) my_malloc(key_buff_length, MYF(0));
284284
key_info_length= pack_keys(keybuff, keys, key_info, data_offset);
285285

286+
/* key_info_length is currently stored in 2 bytes */
287+
if (key_info_length > 65535U)
288+
{
289+
char *real_table_name= (char*) table;
290+
List_iterator<Create_field> it(create_fields);
291+
Create_field *field;
292+
while ((field=it++))
293+
{
294+
if (field->field && field->field->table &&
295+
(real_table_name= field->field->table->s->table_name.str))
296+
break;
297+
}
298+
my_printf_error(ER_UNKNOWN_ERROR,
299+
"Index information size for the table %s.%s exceeds the "
300+
"maximum limit (Max: 2 bytes). Please recreate indexes "
301+
"accordingly.", MYF(0), db, real_table_name);
302+
goto err;
303+
}
304+
286305
/*
287306
Ensure that there are no forms in this newly created form file.
288307
Even if the form file exists, create_frm must truncate it to

0 commit comments

Comments
 (0)