fixed bug #1459418 Add foreign key fail on column with ' in name
This commit is contained in:
@@ -9,12 +9,13 @@ $Source$
|
|||||||
* Documentation.html: clarification about config.default.php
|
* Documentation.html: clarification about config.default.php
|
||||||
|
|
||||||
2006-04-11 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
2006-04-11 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
* index.php, libraries\Table.class.php, libraries\auth\cookie.auth.lib.php,
|
* tbl_relation.php:
|
||||||
|
fixed bug #1459418 Add foreign key fail on column with ' in name
|
||||||
|
* index.php, libraries\auth\cookie.auth.lib.php,
|
||||||
libraries\auth\http.auth.lib.php, libraries\common.lib.php,
|
libraries\auth\http.auth.lib.php, libraries\common.lib.php,
|
||||||
libraries\footer.inc.php, libraries\fpdf\fpdf.php,
|
libraries\footer.inc.php, libraries\fpdf\fpdf.php,
|
||||||
libraries\grab_globals.lib.php, libraries\header.inc.php,
|
libraries\grab_globals.lib.php, libraries\header.inc.php,
|
||||||
libraries\ip_allow_deny.lib.php, libraries\select_lang.lib.php,
|
libraries\ip_allow_deny.lib.php, libraries\select_lang.lib.php,
|
||||||
server_privileges.php, tbl_properties_operations.php,
|
|
||||||
libraries\Config.class.php:
|
libraries\Config.class.php:
|
||||||
use PMA_getenv()
|
use PMA_getenv()
|
||||||
* libraries\Config.class.php:
|
* libraries\Config.class.php:
|
||||||
|
@@ -123,8 +123,8 @@ if (isset($destination) && $cfgRelation['relwork']) {
|
|||||||
// u p d a t e s f o r I n n o D B
|
// u p d a t e s f o r I n n o D B
|
||||||
// ( for now, one index name only; we keep the definitions if the
|
// ( for now, one index name only; we keep the definitions if the
|
||||||
// foreign db is not the same)
|
// foreign db is not the same)
|
||||||
if (isset($destination_innodb)) {
|
if (isset($_REQUEST['destination_innodb'])) {
|
||||||
foreach ($destination_innodb AS $master_field => $foreign_string) {
|
foreach ($_REQUEST['destination_innodb'] as $master_field => $foreign_string) {
|
||||||
if ($foreign_string != 'nix') {
|
if ($foreign_string != 'nix') {
|
||||||
list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string);
|
list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string);
|
||||||
if (!isset($existrel_innodb[$master_field])) {
|
if (!isset($existrel_innodb[$master_field])) {
|
||||||
@@ -138,24 +138,24 @@ if (isset($destination_innodb)) {
|
|||||||
|
|
||||||
$upd_query = 'ALTER TABLE ' . PMA_backquote($table)
|
$upd_query = 'ALTER TABLE ' . PMA_backquote($table)
|
||||||
. ' ADD FOREIGN KEY ('
|
. ' ADD FOREIGN KEY ('
|
||||||
. PMA_backquote(PMA_sqlAddslashes($master_field)) . ')'
|
. PMA_backquote($master_field) . ')'
|
||||||
. ' REFERENCES '
|
. ' REFERENCES '
|
||||||
. PMA_backquote(PMA_sqlAddslashes($foreign_db) . '.'
|
. PMA_backquote($foreign_db) . '.'
|
||||||
. PMA_sqlAddslashes($foreign_table)) . '('
|
. PMA_backquote($foreign_table) . '('
|
||||||
. PMA_backquote(PMA_sqlAddslashes($foreign_field)) . ')';
|
. PMA_backquote($foreign_field) . ')';
|
||||||
|
|
||||||
if (${$master_field . '_on_delete'} != 'nix') {
|
if ($_REQUEST['on_delete'][$master_field] != 'nix') {
|
||||||
$upd_query .= ' ON DELETE ' . $options_array[${$master_field . '_on_delete'}];
|
$upd_query .= ' ON DELETE ' . $options_array[$_REQUEST['on_delete'][$master_field]];
|
||||||
}
|
}
|
||||||
if (${$master_field . '_on_update'} != 'nix') {
|
if ($_REQUEST['on_update'][$master_field] != 'nix') {
|
||||||
$upd_query .= ' ON UPDATE ' . $options_array[${$master_field . '_on_update'}];
|
$upd_query .= ' ON UPDATE ' . $options_array[$_REQUEST['on_update'][$master_field]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// end repeated code
|
// end repeated code
|
||||||
|
|
||||||
} elseif (($existrel_innodb[$master_field]['foreign_db'] . '.' .$existrel_innodb[$master_field]['foreign_table'] . '.' . $existrel_innodb[$master_field]['foreign_field'] != $foreign_string)
|
} elseif (($existrel_innodb[$master_field]['foreign_db'] . '.' .$existrel_innodb[$master_field]['foreign_table'] . '.' . $existrel_innodb[$master_field]['foreign_field'] != $foreign_string)
|
||||||
|| ( ${$master_field . '_on_delete'} != (!empty($existrel_innodb[$master_field]['on_delete']) ? $existrel_innodb[$master_field]['on_delete'] : ''))
|
|| ( $_REQUEST['on_delete'][$master_field] != (!empty($existrel_innodb[$master_field]['on_delete']) ? $existrel_innodb[$master_field]['on_delete'] : ''))
|
||||||
|| ( ${$master_field . '_on_update'} != (!empty($existrel_innodb[$master_field]['on_update']) ? $existrel_innodb[$master_field]['on_update'] : ''))
|
|| ( $_REQUEST['on_update'][$master_field] != (!empty($existrel_innodb[$master_field]['on_update']) ? $existrel_innodb[$master_field]['on_update'] : ''))
|
||||||
) {
|
) {
|
||||||
// another foreign key is already defined for this field
|
// another foreign key is already defined for this field
|
||||||
// or
|
// or
|
||||||
@@ -174,17 +174,19 @@ if (isset($destination_innodb)) {
|
|||||||
// add another
|
// add another
|
||||||
$upd_query = 'ALTER TABLE ' . PMA_backquote($table)
|
$upd_query = 'ALTER TABLE ' . PMA_backquote($table)
|
||||||
. ' ADD FOREIGN KEY ('
|
. ' ADD FOREIGN KEY ('
|
||||||
. PMA_backquote(PMA_sqlAddslashes($master_field)) . ')'
|
. PMA_backquote($master_field) . ')'
|
||||||
. ' REFERENCES '
|
. ' REFERENCES '
|
||||||
. PMA_backquote(PMA_sqlAddslashes($foreign_db) . '.'
|
. PMA_backquote($foreign_db) . '.'
|
||||||
. PMA_sqlAddslashes($foreign_table)) . '('
|
. PMA_backquote($foreign_table) . '('
|
||||||
. PMA_backquote(PMA_sqlAddslashes($foreign_field)) . ')';
|
. PMA_backquote($foreign_field) . ')';
|
||||||
|
|
||||||
if (${$master_field . '_on_delete'} != 'nix') {
|
if ($_REQUEST['on_delete'][$master_field] != 'nix') {
|
||||||
$upd_query .= ' ON DELETE ' . $options_array[${$master_field . '_on_delete'}];
|
$upd_query .= ' ON DELETE '
|
||||||
|
. $options_array[$_REQUEST['on_delete'][$master_field]];
|
||||||
}
|
}
|
||||||
if (${$master_field . '_on_update'} != 'nix') {
|
if ($_REQUEST['on_update'][$master_field] != 'nix') {
|
||||||
$upd_query .= ' ON UPDATE ' . $options_array[${$master_field . '_on_update'}];
|
$upd_query .= ' ON UPDATE '
|
||||||
|
. $options_array[$_REQUEST['on_update'][$master_field]];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end if... else....
|
} // end if... else....
|
||||||
@@ -204,10 +206,10 @@ if (isset($destination_innodb)) {
|
|||||||
echo PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
|
echo PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
|
||||||
}
|
}
|
||||||
if (substr($tmp_error, 1, 4) == '1005') {
|
if (substr($tmp_error, 1, 4) == '1005') {
|
||||||
echo '<p class="warning">' . $strNoIndex . ' (' . $master_field .')</p>' . PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
|
echo '<p class="warning">' . $strNoIndex . ' (' . $master_field
|
||||||
|
.')</p>' . PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
|
||||||
}
|
}
|
||||||
unset($upd_query);
|
unset($upd_query, $tmp_error);
|
||||||
unset($tmp_error);
|
|
||||||
}
|
}
|
||||||
} // end while
|
} // end while
|
||||||
} // end if isset($destination_innodb)
|
} // end if isset($destination_innodb)
|
||||||
@@ -476,7 +478,7 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) {
|
|||||||
<span class="formelement">
|
<span class="formelement">
|
||||||
<?php
|
<?php
|
||||||
PMA_generate_dropdown('ON DELETE',
|
PMA_generate_dropdown('ON DELETE',
|
||||||
htmlspecialchars($save_row[$i]['Field']) . '_on_delete',
|
'on_delete[' . htmlspecialchars($save_row[$i]['Field']) . ']',
|
||||||
$options_array,
|
$options_array,
|
||||||
isset($existrel_innodb[$myfield]['on_delete']) ? $existrel_innodb[$myfield]['on_delete']: '' );
|
isset($existrel_innodb[$myfield]['on_delete']) ? $existrel_innodb[$myfield]['on_delete']: '' );
|
||||||
|
|
||||||
@@ -484,7 +486,7 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) {
|
|||||||
.'<span class="formelement">' . "\n";
|
.'<span class="formelement">' . "\n";
|
||||||
|
|
||||||
PMA_generate_dropdown('ON UPDATE',
|
PMA_generate_dropdown('ON UPDATE',
|
||||||
htmlspecialchars($save_row[$i]['Field']) . '_on_update',
|
'on_update[' . htmlspecialchars($save_row[$i]['Field']) . ']',
|
||||||
$options_array,
|
$options_array,
|
||||||
isset($existrel_innodb[$myfield]['on_update']) ? $existrel_innodb[$myfield]['on_update']: '' );
|
isset($existrel_innodb[$myfield]['on_update']) ? $existrel_innodb[$myfield]['on_update']: '' );
|
||||||
echo '</span>' . "\n";
|
echo '</span>' . "\n";
|
||||||
|
Reference in New Issue
Block a user