bug #3412862 [relation] Relations/constraints are dropped/created on every change

This commit is contained in:
Madhura Jayaratne
2011-09-27 21:06:21 +05:30
parent f29ba65b70
commit 2e101cc733
2 changed files with 12 additions and 18 deletions

View File

@@ -14,6 +14,7 @@ phpMyAdmin - ChangeLog
- bug #3411633 [core] Call to undefined function PMA_isSuperuser() - bug #3411633 [core] Call to undefined function PMA_isSuperuser()
- bug #3413743 [interface] Display options link missing after search - bug #3413743 [interface] Display options link missing after search
- bug #3324161 [core] CSP policy causing designer JS buttons to fail - bug #3324161 [core] CSP policy causing designer JS buttons to fail
- bug #3412862 [relation] Relations/constraints are dropped/created on every change
3.4.5.0 (2011-09-14) 3.4.5.0 (2011-09-14)
- bug #3375325 [interface] Page list in navigation frame looks odd - bug #3375325 [interface] Page list in navigation frame looks odd

View File

@@ -216,24 +216,17 @@ if (isset($_REQUEST['destination_foreign'])) {
} elseif (PMA_backquote($existrel_foreign[$master_field]['foreign_db']) != $foreign_db } elseif (PMA_backquote($existrel_foreign[$master_field]['foreign_db']) != $foreign_db
|| PMA_backquote($existrel_foreign[$master_field]['foreign_table']) != $foreign_table || PMA_backquote($existrel_foreign[$master_field]['foreign_table']) != $foreign_table
|| PMA_backquote($existrel_foreign[$master_field]['foreign_field']) != $foreign_field || PMA_backquote($existrel_foreign[$master_field]['foreign_field']) != $foreign_field
|| ($_REQUEST['on_delete'][$master_field_md5] != (!empty($existrel_foreign[$master_field]['on_delete']) ? $existrel_foreign[$master_field]['on_delete'] : '')) || ($_REQUEST['on_delete'][$master_field_md5] != (!empty($existrel_foreign[$master_field]['on_delete']) ? $existrel_foreign[$master_field]['on_delete'] : 'RESTRICT'))
|| ($_REQUEST['on_update'][$master_field_md5] != (!empty($existrel_foreign[$master_field]['on_update']) ? $existrel_foreign[$master_field]['on_update'] : '')) || ($_REQUEST['on_update'][$master_field_md5] != (!empty($existrel_foreign[$master_field]['on_update']) ? $existrel_foreign[$master_field]['on_update'] : 'RESTRICT'))
) { ) {
// another foreign key is already defined for this field // another foreign key is already defined for this field
// or // or
// an option has been changed for ON DELETE or ON UPDATE // an option has been changed for ON DELETE or ON UPDATE
// remove existing key // remove existing key and add the new one
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) $sql_query = 'ALTER TABLE ' . PMA_backquote($table)
. ' DROP FOREIGN KEY ' . ' DROP FOREIGN KEY '
. PMA_backquote($existrel_foreign[$master_field]['constraint']) . ';'; . PMA_backquote($existrel_foreign[$master_field]['constraint']) . ', '
// I tried to send both in one query but it failed
PMA_DBI_query($sql_query);
$display_query .= $sql_query . "\n";
// add another
$sql_query = 'ALTER TABLE ' . PMA_backquote($table)
. 'ADD FOREIGN KEY (' . 'ADD FOREIGN KEY ('
. PMA_backquote($master_field) . ')' . PMA_backquote($master_field) . ')'
. ' REFERENCES ' . ' REFERENCES '