bug 776789 FK in another db
This commit is contained in:
parent
5f397a7fbb
commit
bfac313494
@ -7,6 +7,8 @@ $Source$
|
||||
|
||||
2003-07-25 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* header.inc.php3: XHTML compatibility
|
||||
* libraries/sqlparser.lib.php3, /relation.lib.php3: bug 776789,
|
||||
unable to insert record with FK in another db
|
||||
|
||||
2003-07-24 Garvin Hicking <me@supergarv.de>
|
||||
* libraries/sqlparser.lib.php3 - Confirmation is also needed on
|
||||
|
||||
@ -311,21 +311,21 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){
|
||||
$show_create_table_res = PMA_mysql_query($show_create_table_query);
|
||||
list(,$show_create_table) = PMA_mysql_fetch_row($show_create_table_res);
|
||||
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
|
||||
|
||||
while (list(,$one_key) = each ($analyzed_sql[0]['foreign_keys'])) {
|
||||
|
||||
// the analyzer may return more than one column name in the
|
||||
// index list or the ref_index_list
|
||||
while (list($i,$field) = each($one_key['index_list'])) {
|
||||
|
||||
// TODO: SHOW CREATE TABLE does not return the db name in
|
||||
// the REFERENCES, so we assume the same db as master
|
||||
|
||||
// If a foreign key is defined in the 'internal' source (pmadb)
|
||||
// and in 'innodb', we won't get it twice if $source='both'
|
||||
// because we use $field as key
|
||||
|
||||
$foreign[$field]['foreign_db'] = $db;
|
||||
if (isset($one_key['ref_db_name'])) {
|
||||
$foreign[$field]['foreign_db'] = $one_key['ref_db_name'];
|
||||
} else {
|
||||
$foreign[$field]['foreign_db'] = $db;
|
||||
}
|
||||
$foreign[$field]['foreign_table'] = $one_key['ref_table_name'];
|
||||
$foreign[$field]['foreign_field'] = $one_key['ref_index_list'][$i];
|
||||
}
|
||||
|
||||
@ -1394,7 +1394,6 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
if ($seen_foreign && $in_bracket) {
|
||||
// remove backquotes
|
||||
$identifier = str_replace('`','',$arr[$i]['data']);
|
||||
//$foreign_key_number++;
|
||||
$foreign[$foreign_key_number]['index_list'][] = $identifier;
|
||||
}
|
||||
|
||||
@ -1403,7 +1402,14 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||
if ($in_bracket) {
|
||||
$foreign[$foreign_key_number]['ref_index_list'][] = $identifier;
|
||||
} else {
|
||||
$foreign[$foreign_key_number]['ref_table_name'] = $identifier;
|
||||
// identifier can be table or db.table
|
||||
$db_table = explode('.',$identifier);
|
||||
if (isset($db_table[1])) {
|
||||
$foreign[$foreign_key_number]['ref_db_name'] = $db_table[0];
|
||||
$foreign[$foreign_key_number]['ref_table_name'] = $db_table[1];
|
||||
} else {
|
||||
$foreign[$foreign_key_number]['ref_table_name'] = $db_table[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user