From fd979ea10bf8d6d74380741894b7b427f8c47d1b Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 24 Jul 2003 12:59:28 +0000 Subject: [PATCH] bug 772765 --- ChangeLog | 4 ++++ libraries/get_foreign.lib.php3 | 3 ++- libraries/relation.lib.php3 | 13 +++++++------ libraries/sqlparser.lib.php3 | 8 ++++---- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1add11852..038ddfd87 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2003-07-24 Marc Delisle + * libraries/sqlparser.lib.php3 /relation.lib.php3 /get_foreign.lib.php3: + bug 772765, InnoDB and multi-columns foreign key + 2003-07-23 Alexander M. Turek * libraries/mysql_charsets.lib.php3: - better method for retrieving the supported MySQL charsets; diff --git a/libraries/get_foreign.lib.php3 b/libraries/get_foreign.lib.php3 index ee450fe6c..c4558e8d6 100755 --- a/libraries/get_foreign.lib.php3 +++ b/libraries/get_foreign.lib.php3 @@ -31,11 +31,12 @@ if ($the_total < 200) { // foreign_display can be FALSE if no display field defined: + $foreign_display = PMA_getDisplayField($foreign_db, $foreign_table); $dispsql = 'SELECT ' . PMA_backquote($foreign_field) . (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display)) . ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table) - . ' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display); + . (($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display)); $disp = PMA_mysql_query($dispsql); } else { diff --git a/libraries/relation.lib.php3 b/libraries/relation.lib.php3 index 92c2524db..37e13fb92 100644 --- a/libraries/relation.lib.php3 +++ b/libraries/relation.lib.php3 @@ -314,9 +314,9 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){ while (list(,$one_key) = each ($analyzed_sql[0]['foreign_keys'])) { - // TODO: the analyzer may return more than one column name in the - // index list or the ref_index_list but for now we take the first - $field = $one_key['index_list'][0]; + // 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 @@ -325,9 +325,10 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){ // and in 'innodb', we won't get it twice if $source='both' // because we use $field as key - $foreign[$field]['foreign_db'] = $db; - $foreign[$field]['foreign_table'] = $one_key['ref_table_name']; - $foreign[$field]['foreign_field'] = $one_key['ref_index_list'][0]; + $foreign[$field]['foreign_db'] = $db; + $foreign[$field]['foreign_table'] = $one_key['ref_table_name']; + $foreign[$field]['foreign_field'] = $one_key['ref_index_list'][$i]; + } } } diff --git a/libraries/sqlparser.lib.php3 b/libraries/sqlparser.lib.php3 index cdc076343..acba37d4a 100644 --- a/libraries/sqlparser.lib.php3 +++ b/libraries/sqlparser.lib.php3 @@ -699,7 +699,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { * I create all sub-values empty, even if they are * not present (for example no select_expression alias). * - * There is a debug section at the end of the main loop, if you want to + * There is a debug section at the end of loop #1, if you want to * see the exact contents of select_expr and table_ref * * lem9: queryflags @@ -1183,7 +1183,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { $in_from = FALSE; for ($i = 0; $i < $size; $i++) { - //echo "trace loop2 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; + //DEBUG echo "trace loop2 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; // need_confirm // @@ -1369,6 +1369,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { if ($upper_data == 'FOREIGN') { $seen_foreign = TRUE; $seen_references = FALSE; + $foreign_key_number++; } if ($upper_data == 'REFERENCES') { $seen_foreign = FALSE; @@ -1392,8 +1393,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { if ($seen_foreign && $in_bracket) { // remove backquotes $identifier = str_replace('`','',$arr[$i]['data']); - // new foreign key - $foreign_key_number++; + //$foreign_key_number++; $foreign[$foreign_key_number]['index_list'][] = $identifier; }