Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Utilize oids in PostgreSQL

  • Loading branch information...
commit 37d814649a46e5280718d086c6a46d7ed1cbb8e6 1 parent 741b19b
Jakub Vrána authored
2  adminer/drivers/pgsql.inc.php
@@ -196,7 +196,7 @@ function count_tables($databases) {
196 196
197 197 function table_status($name = "") {
198 198 $return = array();
199   - 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\"
  199 + 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\"
200 200 FROM pg_class
201 201 WHERE relkind IN ('r','v')
202 202 AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema())"
27 adminer/select.inc.php
@@ -4,6 +4,9 @@
4 4 $indexes = indexes($TABLE);
5 5 $fields = fields($TABLE);
6 6 $foreign_keys = column_foreign_keys($TABLE);
  7 +if ($table_status["Oid"] == "t") {
  8 + $indexes[] = array("type" => "PRIMARY", "columns" => array("oid"));
  9 +}
7 10
8 11 $rights = array(); // privilege => 0
9 12 $columns = array(); // selectable columns
@@ -23,7 +26,7 @@
23 26 $where = $adminer->selectSearchProcess($fields, $indexes);
24 27 $order = $adminer->selectOrderProcess($fields, $indexes);
25 28 $limit = $adminer->selectLimitProcess();
26   -$from = ($select ? implode(", ", $select) : "*") . "\nFROM " . table($TABLE);
  29 +$from = ($select ? implode(", ", $select) : ($table_status["Oid"] == "t" ? "oid, " : "") . "*") . "\nFROM " . table($TABLE);
27 30 $group_by = ($group && count($group) < count($select) ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : "");
28 31
29 32 if ($_GET["val"] && is_ajax()) {
@@ -258,17 +261,19 @@
258 261 reset($select);
259 262 $rank = 1;
260 263 foreach ($rows[0] as $key => $val) {
261   - $val = $_GET["columns"][key($select)];
262   - $field = $fields[$select ? $val["col"] : $key];
263   - $name = ($field ? $adminer->fieldName($field, $rank) : "*");
264   - if ($name != "") {
265   - $rank++;
266   - $names[$key] = $name;
267   - $column = idf_escape($key);
268   - echo '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key) . ($order[0] == $column || $order[0] == $key || (!$order && $group[0] == $column) ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; // $order[0] == $key - COUNT(*) //! columns looking like functions
  264 + if ($table_status["Oid"] != "t" || $key != "oid") {
  265 + $val = $_GET["columns"][key($select)];
  266 + $field = $fields[$select ? $val["col"] : $key];
  267 + $name = ($field ? $adminer->fieldName($field, $rank) : "*");
  268 + if ($name != "") {
  269 + $rank++;
  270 + $names[$key] = $name;
  271 + $column = idf_escape($key);
  272 + echo '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key) . ($order[0] == $column || $order[0] == $key || (!$order && $group[0] == $column) ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; // $order[0] == $key - COUNT(*) //! columns looking like functions
  273 + }
  274 + $functions[$key] = $val["fun"];
  275 + next($select);
269 276 }
270   - $functions[$key] = $val["fun"];
271   - next($select);
272 277 }
273 278 $lengths = array();
274 279 if ($_GET["modify"]) {
1  changes.txt
@@ -13,6 +13,7 @@ SQLite: display 0
13 13 Create table default data type: int
14 14 Focus upper/lower fields by Ctrl+Up/Ctrl+Down
15 15 Hide credentials for SQLite
  16 +Utilize oids in PostgreSQL
16 17 Homepage customization
17 18 Use IN for search in numeric fields (Editor)
18 19 Use password input for _md5 and _sha1 fields (Editor)

0 comments on commit 37d8146

Please sign in to comment.
Something went wrong with that request. Please try again.