diff options
author | Karthik Kamath <karthik.kamath@oracle.com> | 2017-10-23 10:56:20 +0530 |
---|---|---|
committer | Karthik Kamath <karthik.kamath@oracle.com> | 2017-10-23 10:56:20 +0530 |
commit | a542209b9e70e28e88ba60d2e4441a8c2d3e746c (patch) | |
tree | f3ab1a82dac5f9aaa1fce939649d58e9898c1fe6 | |
parent | 84c32cdbe746fdabc33988fc17b1f11b08fd22e0 (diff) | |
download | mariadb-git-a542209b9e70e28e88ba60d2e4441a8c2d3e746c.tar.gz |
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).
-rw-r--r-- | sql/unireg.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc index d77a6b06275..788046cfae4 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify 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, keybuff=(uchar*) my_malloc(key_buff_length, MYF(0)); key_info_length= pack_keys(keybuff, keys, key_info, data_offset); + /* key_info_length is currently stored in 2 bytes */ + if (key_info_length > 65535U) + { + char *real_table_name= (char*) table; + List_iterator<Create_field> it(create_fields); + Create_field *field; + while ((field=it++)) + { + if (field->field && field->field->table && + (real_table_name= field->field->table->s->table_name.str)) + break; + } + my_printf_error(ER_UNKNOWN_ERROR, + "Index information size for the table %s.%s exceeds the " + "maximum limit (Max: 2 bytes). Please recreate indexes " + "accordingly.", MYF(0), db, real_table_name); + goto err; + } + /* Ensure that there are no forms in this newly created form file. Even if the form file exists, create_frm must truncate it to |