Permalink
Browse files

PostgreSQL hidden columns support

  • Loading branch information...
vrana committed May 21, 2010
1 parent 3308856 commit 4c2268d38184537bcf9def0cda51c95003c13cb6
@@ -308,7 +308,7 @@ function fk_support($table_status) {
return true;
}
- function fields($table) {
+ function fields($table, $hidden = false) {
global $connection;
$return = array();
$result = $connection->query("SELECT c.*, t.name type, d.definition [default]
@@ -380,9 +380,10 @@ function fk_support($table_status) {
/** Get information about fields
* @param string
+ * @param bool display hidden table columns
* @return array array($name => array("field" => , "full_type" => , "type" => , "length" => , "unsigned" => , "default" => , "null" => , "auto_increment" => , "on_update" => , "collation" => , "privileges" => , "comment" => , "primary" => ))
*/
- function fields($table) {
+ function fields($table, $hidden = false) {
global $connection;
$return = array();
$result = $connection->query("SHOW FULL COLUMNS FROM " . table($table));
@@ -201,7 +201,7 @@ function fk_support($table_status) {
return true;
}
- function fields($table) {
+ function fields($table, $hidden = false) {
global $connection;
$return = array();
$result = $connection->query("SELECT * FROM all_tab_columns WHERE table_name = " . $connection->quote($table) . " ORDER BY column_id");
@@ -217,7 +217,7 @@ function fk_support($table_status) {
return true;
}
- function fields($table) {
+ function fields($table, $hidden = false) {
global $connection;
$return = array();
$result = $connection->query("SELECT a.attname AS field, format_type(a.atttypid, a.atttypmod) AS full_type, d.adsrc AS default, a.attnotnull, col_description(c.oid, a.attnum) AS comment
@@ -227,8 +227,10 @@ function fields($table) {
LEFT JOIN pg_attrdef d ON c.oid = d.adrelid AND a.attnum = d.adnum
WHERE c.relname = " . $connection->quote($table) . "
AND n.nspname = current_schema()
-AND a.attnum > 0
-ORDER BY a.attnum");
+AND NOT a.attisdropped
+" . ($hidden ? "" : "AND a.attnum > 0") . "
+ORDER BY a.attnum < 0, a.attnum"
+ );
if ($result) {
while ($row = $result->fetch_assoc()) {
//! collation, primary
@@ -267,7 +267,7 @@ function fk_support($table_status) {
return !$connection->result("SELECT sqlite_compileoption_used('OMIT_FOREIGN_KEY')");
}
- function fields($table) {
+ function fields($table, $hidden = false) {
global $connection;
$return = array();
$result = $connection->query("PRAGMA table_info(" . table($table) . ")");
View
@@ -2,7 +2,7 @@
$TABLE = $_GET["select"];
$table_status = table_status($TABLE);
$indexes = indexes($TABLE);
-$fields = fields($TABLE);
+$fields = fields($TABLE, 1); // 1 - hidden
$foreign_keys = column_foreign_keys($TABLE);
$rights = array(); // privilege => 0
@@ -12,7 +12,7 @@
$name = $adminer->fieldName($field);
if (isset($field["privileges"]["select"]) && $name != "") {
$columns[$key] = html_entity_decode(strip_tags($name));
- if (ereg('text|blob', $field["type"])) {
+ if (ereg('text|clob|blob', $field["type"])) {
$text_length = $adminer->selectLengthProcess();
}
}

0 comments on commit 4c2268d

Please sign in to comment.