diff --git a/ChangeLog b/ChangeLog index 2adcd330c..857d39817 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-03-28 Alexander M. Turek + * libraries/information_schema_relations.lib.php, + libraries/relation.lib.php: information_schema relations. + 2005-03-27 Alexander M. Turek * libraries/defines.lib.php, themes/*/info.inc.php: Marked 2.6.0 / 2.6.1 themes as imcompatible because of recent changes. diff --git a/libraries/information_schema_relations.lib.php b/libraries/information_schema_relations.lib.php new file mode 100644 index 000000000..c4501cb25 --- /dev/null +++ b/libraries/information_schema_relations.lib.php @@ -0,0 +1,129 @@ + array( + 'DEFAULT_COLLATE_NAME' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'COLLATIONS', + 'foreign_field' => 'COLLATION_NAME' + ) + ), + 'COLLATIONS' => array( + 'CHARACTER_SET_NAME' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'CHARACTER_SETS', + 'foreign_field' => 'CHARACTER_SET_NAME' + ) + ), + 'COLLATION_CHARACTER_SET_APPLICABILITY' => array( + 'CHARACTER_SET_NAME' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'CHARACTER_SETS', + 'foreign_field' => 'CHARACTER_SET_NAME' + ), + 'COLLATION_NAME' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'COLLATIONS', + 'foreign_field' => 'COLLATION_NAME' + ) + ), + 'COLUMNS' => array( + 'TABLE_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ), + 'CHARACTER_SET_NAME' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'CHARACTER_SETS', + 'foreign_field' => 'CHARACTER_SET_NAME' + ), + 'COLLATION_NAME' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'COLLATIONS', + 'foreign_field' => 'COLLATION_NAME' + ) + ), + 'COLUMN_PRIVILEGES' => array( + 'TABLE_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ) + ), + 'KEY_COLUMN_USAGE' => array( + 'CONSTRAINT_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ), + 'TABLE_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ) + ), + 'ROUTINES' => array( + 'ROUTINE_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ) + ), + 'SCHEMATA' => array( + 'DEFAULT_CHARACTER_SET_NAME' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'CHARACTER_SETS', + 'foreign_field' => 'CHARACTER_SET_NAME' + ) + ), + 'SCHEMA_PRIVILEGES' => array( + 'TABLE_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ) + ), + 'TABLES' => array( + 'TABLE_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ), + 'TABLE_COLLATION' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'COLLATIONS', + 'foreign_field' => 'COLLATION_NAME' + ) + ), + 'TABLE_CONSTRAINTS' => array( + 'CONSTRAINT_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ), + 'TABLE_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ) + ), + 'TABLE_PRIVILEGES' => array( + 'TABLE_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ) + ), + 'VIEWS' => array( + 'TABLE_SCHEMA' => array( + 'foreign_db' => 'information_schema', + 'foreign_table' => 'SCHEMATA', + 'foreign_field' => 'SCHEMA_NAME' + ) + ) +); + +?> diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index 2a7609dbe..ff0530863 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -349,37 +349,23 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') { */ if (PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema' && ($source == 'internal' || $source == 'both')) { - $foreign = array(); - switch ($table) { - case 'COLLATION_CHARACTER_SET_APPLICABILITY': - if ((empty($column) || $column == 'CHARACTER_SET_NAME') && !isset($foreign['CHARACTER_SET_NAME'])) { - $foreign['CHARACTER_SET_NAME'] = array( - 'foreign_db' => 'information_schema', - 'foreign_table' => 'CHARACTER_SETS', - 'foreign_field' => 'CHARACTER_SET_NAME' - ); + + require_once('./libraries/information_schema_relations.lib.php'); + + if (!isset($foreign)) { + $foreign = array(); + } + + if (isset($GLOBALS['information_schema_relations'][$table])) { + foreach ($GLOBALS['information_schema_relations'][$table] as $field => $relations) { + if ((empty($column) || $column == $field) && empty($foreign[$field])) { + $foreign[$field] = $relations; } - if ((empty($column) || $column == 'COLLATION_NAME') && !isset($foreign['COLLATION_NAME'])) { - $foreign['COLLATION_NAME'] = array( - 'foreign_db' => 'information_schema', - 'foreign_table' => 'COLLATIONS', - 'foreign_field' => 'COLLATION_NAME' - ); - } - break; - case 'SCHEMATA': - if ((empty($column) || $column == 'DEFAULT_CHARACTER_SET_NAME') && !isset($foreign['DEFAULT_CHARACTER_SET_NAME'])) { - $foreign['DEFAULT_CHARACTER_SET_NAME'] = array( - 'foreign_db' => 'information_schema', - 'foreign_table' => 'CHARACTER_SETS', - 'foreign_field' => 'CHARACTER_SET_NAME' - ); - } - break; + } } } - if (isset($foreign) && is_array($foreign)) { + if (!empty($foreign) && is_array($foreign)) { return $foreign; } else { return FALSE;