Commit f3fa6cc
BUG#25126722 FOREIGN KEY CONSTRAINT NAME IS NULL IN INFORMATION_SCHEMA
AFTER RESTART Problem : --------- Information_Schema.referential_constraints (UNIQUE_CONSTRAINT_NAME) shows NULL for a foreign key constraint after restarting the server. If any dml or query (select/insert/update/delete) is done on referenced table, then the constraint name is correctly shown. Solution : ---------- UNIQUE_CONSTRAINT_NAME column is the key name of the referenced table. In innodb, FK reference is stored as a list of columns in referenced table in INNODB_SYS_FOREIGN and INNODB_SYS_FOREIGN_COLS. The referenced column must have at least one index/key with the referenced column as prefix but the key name itself is not included in FK metadata. For this reason, the UNIQUE_CONSTRAINT_NAME is only filled up when the referenced table is actually loaded in innodb dictionary cache. The information_schema view calls handler::get_foreign_key_list() on foreign key table to read the FK metadata. The UNIQUE_CONSTRAINT_NAME information shows NULL based on whether the referenced table is already loaded or not. One way to fix this issue is to load the referenced table while reading the FK metadata information, if needed. Reviewed-by: Sunny Bains <sunny.bains@oracle.com> RB: 14654 (cherry picked from commit dc55bc8de77539b846200c0baa2f2a5715779dd9)1 parent 8b7f92a commit f3fa6cc
File tree
3 files changed
+75
-0
lines changed- mysql-test/suite/innodb
- r
- t
- storage/innobase/handler
3 files changed
+75
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14753 | 14753 | | |
14754 | 14754 | | |
14755 | 14755 | | |
| 14756 | + | |
| 14757 | + | |
| 14758 | + | |
| 14759 | + | |
| 14760 | + | |
| 14761 | + | |
| 14762 | + | |
| 14763 | + | |
| 14764 | + | |
| 14765 | + | |
| 14766 | + | |
| 14767 | + | |
| 14768 | + | |
| 14769 | + | |
| 14770 | + | |
| 14771 | + | |
| 14772 | + | |
| 14773 | + | |
| 14774 | + | |
| 14775 | + | |
| 14776 | + | |
| 14777 | + | |
14756 | 14778 | | |
14757 | 14779 | | |
14758 | 14780 | | |
| |||
0 commit comments