Commit 98b18c59 authored by Annamalai Gurusami's avatar Annamalai Gurusami

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.
parent ffa7ae1c
/***************************************************************************** /*****************************************************************************
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( ...@@ -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( ...@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment