From 37d814649a46e5280718d086c6a46d7ed1cbb8e6 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 1 Feb 2011 16:19:39 +0100 Subject: [PATCH] Utilize oids in PostgreSQL --- adminer/drivers/pgsql.inc.php | 2 +- adminer/select.inc.php | 27 ++++++++++++++++----------- changes.txt | 1 + 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 30a25218..b9c2148d 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -196,7 +196,7 @@ if (isset($_GET["pgsql"])) { function table_status($name = "") { $return = array(); - foreach (get_rows("SELECT relname AS \"Name\", CASE relkind WHEN 'r' THEN '' ELSE 'view' END AS \"Engine\", pg_relation_size(oid) AS \"Data_length\", pg_total_relation_size(oid) - pg_relation_size(oid) AS \"Index_length\", obj_description(oid, 'pg_class') AS \"Comment\" + foreach (get_rows("SELECT relname AS \"Name\", CASE relkind WHEN 'r' THEN '' ELSE 'view' END AS \"Engine\", pg_relation_size(oid) AS \"Data_length\", pg_total_relation_size(oid) - pg_relation_size(oid) AS \"Index_length\", obj_description(oid, 'pg_class') AS \"Comment\", relhasoids AS \"Oid\" FROM pg_class WHERE relkind IN ('r','v') AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema())" diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 0ce59734..d9f56214 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -4,6 +4,9 @@ $table_status = table_status($TABLE); $indexes = indexes($TABLE); $fields = fields($TABLE); $foreign_keys = column_foreign_keys($TABLE); +if ($table_status["Oid"] == "t") { + $indexes[] = array("type" => "PRIMARY", "columns" => array("oid")); +} $rights = array(); // privilege => 0 $columns = array(); // selectable columns @@ -23,7 +26,7 @@ list($select, $group) = $adminer->selectColumnsProcess($columns, $indexes); $where = $adminer->selectSearchProcess($fields, $indexes); $order = $adminer->selectOrderProcess($fields, $indexes); $limit = $adminer->selectLimitProcess(); -$from = ($select ? implode(", ", $select) : "*") . "\nFROM " . table($TABLE); +$from = ($select ? implode(", ", $select) : ($table_status["Oid"] == "t" ? "oid, " : "") . "*") . "\nFROM " . table($TABLE); $group_by = ($group && count($group) < count($select) ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : ""); if ($_GET["val"] && is_ajax()) { @@ -258,17 +261,19 @@ if (!$columns) { reset($select); $rank = 1; foreach ($rows[0] as $key => $val) { - $val = $_GET["columns"][key($select)]; - $field = $fields[$select ? $val["col"] : $key]; - $name = ($field ? $adminer->fieldName($field, $rank) : "*"); - if ($name != "") { - $rank++; - $names[$key] = $name; - $column = idf_escape($key); - echo '' . apply_sql_function($val["fun"], $name) . ""; // $order[0] == $key - COUNT(*) //! columns looking like functions + if ($table_status["Oid"] != "t" || $key != "oid") { + $val = $_GET["columns"][key($select)]; + $field = $fields[$select ? $val["col"] : $key]; + $name = ($field ? $adminer->fieldName($field, $rank) : "*"); + if ($name != "") { + $rank++; + $names[$key] = $name; + $column = idf_escape($key); + echo '' . apply_sql_function($val["fun"], $name) . ""; // $order[0] == $key - COUNT(*) //! columns looking like functions + } + $functions[$key] = $val["fun"]; + next($select); } - $functions[$key] = $val["fun"]; - next($select); } $lengths = array(); if ($_GET["modify"]) { diff --git a/changes.txt b/changes.txt index ecab7ccc..d20f7ff0 100644 --- a/changes.txt +++ b/changes.txt @@ -13,6 +13,7 @@ SQLite: display 0 Create table default data type: int Focus upper/lower fields by Ctrl+Up/Ctrl+Down Hide credentials for SQLite +Utilize oids in PostgreSQL Homepage customization Use IN for search in numeric fields (Editor) Use password input for _md5 and _sha1 fields (Editor)