information_schema relations

This commit is contained in:
Alexander M. Turek
2005-03-27 23:26:00 +00:00
parent a83e858fdf
commit 456a26f636
3 changed files with 146 additions and 27 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$
$Source$
2005-03-28 Alexander M. Turek <me@derrabus.de>
* libraries/information_schema_relations.lib.php,
libraries/relation.lib.php: information_schema relations.
2005-03-27 Alexander M. Turek <me@derrabus.de>
* libraries/defines.lib.php, themes/*/info.inc.php: Marked 2.6.0 / 2.6.1
themes as imcompatible because of recent changes.

View File

@@ -0,0 +1,129 @@
<?php
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
$GLOBALS['information_schema_relations'] = array(
'CHARACTER_SETS' => 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'
)
)
);
?>

View File

@@ -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;