Bug #20442523 CRASH WHEN CREATE TABLE VIOLATES FOREIGN KEY CONSTRAINT

Problem:

This is a coding mistake during error handling.  When the specified foreign
key constraint is wrong because of data type mismatch, the resulting
foreign key object will not have valid foreign->id (it will be NULL.)

Solution:

While removing the foreign key object from dictionary cache during error
handling, ensure that foreign->id is not null before using it.

rb#8204 approved by Sunny.
This commit is contained in:
Annamalai Gurusami 2015-03-03 17:57:08 +05:30
commit 98b18c5971

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under 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 the Free Software the terms of the GNU General Public License as published by the Free Software
@ -2530,7 +2530,7 @@ dict_foreign_remove_from_cache(
rbt = foreign->referenced_table->referenced_rbt; rbt = foreign->referenced_table->referenced_rbt;
if (rbt != NULL) { if (rbt != NULL && foreign->id != NULL) {
const ib_rbt_node_t* node const ib_rbt_node_t* node
= rbt_lookup(rbt, foreign->id); = rbt_lookup(rbt, foreign->id);
dict_foreign_t* val = *(dict_foreign_t**) node->value; dict_foreign_t* val = *(dict_foreign_t**) node->value;
@ -2549,7 +2549,7 @@ dict_foreign_remove_from_cache(
foreign); foreign);
rbt = foreign->foreign_table->foreign_rbt; rbt = foreign->foreign_table->foreign_rbt;
if (rbt != NULL) { if (rbt != NULL && foreign->id != NULL) {
const ib_rbt_node_t* node const ib_rbt_node_t* node
= rbt_lookup(rbt, foreign->id); = rbt_lookup(rbt, foreign->id);
dict_foreign_t* val = *(dict_foreign_t**) node->value; dict_foreign_t* val = *(dict_foreign_t**) node->value;