Commit 8cc97511 authored by Jan Lindström's avatar Jan Lindström

MDEV-7538: Wrong constraint (TINYINT or MEDIUMINT and INT)

causes server crash

Analysis: If wrong data types used on foreign constraint there
was possibility that foreign->id is NULL when incorrect
foreign constraint was removed from the dictionary cache.

Fix: Add guard foreign->id != NULL before trying to lookup
or remove the foreign constraint from dictionary cache.

Tested using user database where problem was repeatable.
parent 422ffe99
......@@ -2530,7 +2530,7 @@ dict_foreign_remove_from_cache(
rbt = foreign->referenced_table->referenced_rbt;
if (rbt != NULL) {
if (rbt != NULL && foreign->id != NULL) {
const ib_rbt_node_t* node
= rbt_lookup(rbt, foreign->id);
dict_foreign_t* val = *(dict_foreign_t**) node->value;
......@@ -2549,7 +2549,7 @@ dict_foreign_remove_from_cache(
foreign);
rbt = foreign->foreign_table->foreign_rbt;
if (rbt != NULL) {
if (rbt != NULL && foreign->id != NULL) {
const ib_rbt_node_t* node
= rbt_lookup(rbt, foreign->id);
dict_foreign_t* val = *(dict_foreign_t**) node->value;
......
......@@ -2650,10 +2650,16 @@ dict_foreign_remove_from_cache(
foreign);
rbt = foreign->referenced_table->referenced_rbt;
if (rbt != NULL) {
if (rbt != NULL && foreign->id != NULL) {
const ib_rbt_node_t* node
= rbt_lookup(rbt, foreign->id);
dict_foreign_t* val = *(dict_foreign_t**) node->value;
if (val == foreign) {
rbt_delete(rbt, foreign->id);
}
}
}
if (foreign->foreign_table) {
ib_rbt_t* rbt;
......@@ -2663,10 +2669,16 @@ dict_foreign_remove_from_cache(
foreign);
rbt = foreign->foreign_table->foreign_rbt;
if (rbt != NULL) {
if (rbt != NULL && foreign->id != NULL) {
const ib_rbt_node_t* node
= rbt_lookup(rbt, foreign->id);
dict_foreign_t* val = *(dict_foreign_t**) node->value;
if (val == foreign) {
rbt_delete(rbt, foreign->id);
}
}
}
dict_foreign_free(foreign);
......
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