summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-01-23 19:21:44 +0200
committerMonty <monty@mariadb.org>2018-01-24 00:09:34 +0200
commitb3c7cf81e3578fef828aa749de4c75258c3fbd76 (patch)
tree4272441997be7c44e2c06a581f254f7a07c97ebc /sql/sql_table.cc
parenta4663af05c1d1bd3abb537205df070ed2158e702 (diff)
downloadmariadb-git-b3c7cf81e3578fef828aa749de4c75258c3fbd76.tar.gz
Fix for MDEV-14141 Crash in print_keydup_error()
May also fix: MDEV-14970 "MariaDB crashed with signal 11 and Aria table" I am not able to reproduce a crash, however there was no protection in print_keydup_error() if the storage engine reported the wrong key number. This patch adds such a protection and should stop any further crashes in this case. Other things: - Added extra protection in Aria to not set errkey to more than number of keys. (Don't think this is cause of this crash, but better safe than sorry) - Extend test_if_equal_repl_errors() to handle different cases of ER_DUP_ENTRY. This is just mainly precaution for the future.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 7d37c559e20..2d346a64613 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -9612,12 +9612,13 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
if ((int) key_nr >= 0)
{
const char *err_msg= ER(ER_DUP_ENTRY_WITH_KEY_NAME);
- if (key_nr == 0 &&
+ if (key_nr == 0 && to->s->keys > 0 &&
(to->key_info[0].key_part[0].field->flags &
AUTO_INCREMENT_FLAG))
err_msg= ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE);
- print_keydup_error(to, key_nr == MAX_KEY ? NULL :
- &to->key_info[key_nr],
+ print_keydup_error(to,
+ key_nr >= to->s->keys ? NULL :
+ &to->key_info[key_nr],
err_msg, MYF(0));
}
else