From 1da3ca544aad6d5a1a53c113555390106d7c2704 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Fri, 6 May 2011 18:04:03 +0200 Subject: [PATCH] Display indexes in Oracle (thanks to Marcello Verona) --- adminer/drivers/mssql.inc.php | 4 ---- adminer/drivers/mysql.inc.php | 4 ---- adminer/drivers/oracle.inc.php | 12 +++++++++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index e779adda..d926ff7b 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -334,10 +334,6 @@ WHERE o.schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND o.type IN ('S', 'U', } function indexes($table, $connection2 = null) { - global $connection; - if (!is_object($connection2)) { - $connection2 = $connection; - } $return = array(); // sp_statistics doesn't return information about primary key foreach (get_rows("SELECT i.name, key_ordinal, is_unique, is_primary_key, c.name AS column_name diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index ba8359ce..0eb2202f 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -425,10 +425,6 @@ if (!defined("DRIVER")) { * @return array array($key_name => array("type" => , "columns" => array(), "lengths" => array())) */ function indexes($table, $connection2 = null) { - global $connection; - if (!is_object($connection2)) { // use the main connection if the separate connection is unavailable - $connection2 = $connection; - } $return = array(); foreach (get_rows("SHOW INDEX FROM " . table($table), $connection2) as $row) { $return[$row["Key_name"]]["type"] = ($row["Key_name"] == "PRIMARY" ? "PRIMARY" : ($row["Index_type"] == "FULLTEXT" ? "FULLTEXT" : ($row["Non_unique"] ? "INDEX" : "UNIQUE"))); diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index 75bc9613..1844e084 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -232,7 +232,17 @@ UNION SELECT view_name, 'view' FROM user_views" . ($name != "" ? " WHERE view_na } function indexes($table, $connection2 = null) { - return array(); //! + $return = array(); + foreach (get_rows("SELECT uic.*, uc.constraint_type +FROM user_ind_columns uic +LEFT JOIN user_constraints uc ON uic.index_name = uc.constraint_name AND uic.table_name = uc.table_name +WHERE uic.table_name = " . q($table) . " +ORDER BY uc.constraint_type, uic.column_position", $connection2) as $row) { + $return[$row["INDEX_NAME"]]["type"] = ($row["CONSTRAINT_TYPE"] == "P" ? "PRIMARY" : ($row["CONSTRAINT_TYPE"] == "U" ? "UNIQUE" : "INDEX")); + $return[$row["INDEX_NAME"]]["columns"][] = $row["COLUMN_NAME"]; + $return[$row["INDEX_NAME"]]["lengths"][] = ($row["CHAR_LENGTH"] && $row["CHAR_LENGTH"] != $row["COLUMN_LENGTH"] ? $row["CHAR_LENGTH"] : null); + } + return $return; } function view($name) {