From 6a39a4445af0863adea037559e21914887f2ac4b Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 11 Apr 2013 19:50:48 -0400 Subject: [PATCH] bug #3871 Check referential integrity broken across databases --- ChangeLog | 1 + libraries/operations.lib.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19d5088e05..5f24e73694 100644 --- a/ChangeLog +++ b/ChangeLog @@ -103,6 +103,7 @@ underscore - bug #3853 Blowfish implementation might be broken (replace with phpseclib) - bug #3865 Using like operator on each backslash needs 4 backslash protection - bug #3860 Displayed git revision info is not set +- bug #3871 Check referential integrity broken across databases 3.5.9.0 (not yet released) diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php index f83fa302c8..5c45607488 100644 --- a/libraries/operations.lib.php +++ b/libraries/operations.lib.php @@ -1365,7 +1365,10 @@ function PMA_getHtmlForReferentialIntegrityCheck($foreign, $url_params) $join_query = 'SELECT ' . PMA_Util::backquote($GLOBALS['table']) . '.*' . ' FROM ' . PMA_Util::backquote($GLOBALS['table']) - . ' LEFT JOIN ' . PMA_Util::backquote($arr['foreign_table']); + . ' LEFT JOIN ' + . PMA_Util::backquote($arr['foreign_db']) + . '.' + . PMA_Util::backquote($arr['foreign_table']); if ($arr['foreign_table'] == $GLOBALS['table']) { $foreign_table = $GLOBALS['table'] . '1'; $join_query .= ' AS ' . PMA_Util::backquote($foreign_table); @@ -1375,9 +1378,14 @@ function PMA_getHtmlForReferentialIntegrityCheck($foreign, $url_params) $join_query .= ' ON ' . PMA_Util::backquote($GLOBALS['table']) . '.' . PMA_Util::backquote($master) - . ' = ' . PMA_Util::backquote($foreign_table) . '.' + . ' = ' + . PMA_Util::backquote($arr['foreign_db']) + . '.' + . PMA_Util::backquote($foreign_table) . '.' . PMA_Util::backquote($arr['foreign_field']) . ' WHERE ' + . PMA_Util::backquote($arr['foreign_db']) + . '.' . PMA_Util::backquote($foreign_table) . '.' . PMA_Util::backquote($arr['foreign_field']) . ' IS NULL AND '