From e04be3a996900bb278a23468e030a7db00892cda Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Wed, 29 May 2013 17:24:27 -0700 Subject: [PATCH] Handle timestamp PostgreSQL types (bug #3614086) --- adminer/drivers/pgsql.inc.php | 11 +++++++++-- adminer/include/functions.inc.php | 2 +- changes.txt | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index e82e2f7b..3cbe23b4 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -227,6 +227,10 @@ AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema( function fields($table) { $return = array(); + $aliases = array( + 'timestamp without time zone' => 'timestamp', + 'timestamp with time zone' => 'timestamptz', + ); foreach (get_rows("SELECT a.attname AS field, format_type(a.atttypid, a.atttypmod) AS full_type, d.adsrc AS default, a.attnotnull::int, col_description(c.oid, a.attnum) AS comment FROM pg_class c JOIN pg_namespace n ON c.relnamespace = n.oid @@ -239,8 +243,11 @@ AND a.attnum > 0 ORDER BY a.attnum" ) as $row) { //! collation, primary - ereg('(.*)(\\((.*)\\))?', $row["full_type"], $match); - list(, $row["type"], , $row["length"]) = $match; + $type = $row["full_type"]; + if (ereg('(.+)\\((.*)\\)$', $row["full_type"], $match)) { + list(, $type, $row["length"]) = $match; + } + $row["type"] = ($aliases[$type] ? $aliases[$type] : $type); $row["full_type"] = $row["type"] . ($row["length"] ? "($row[length])" : ""); $row["null"] = !$row["attnotnull"]; $row["auto_increment"] = eregi("^nextval\\(", $row["default"]); diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index db4c0dc5..63128027 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -789,7 +789,7 @@ function input($field, $value, $function) { } else { // int(3) is only a display hint $maxlength = (!ereg('int', $field["type"]) && preg_match('~^(\\d+)(,(\\d+))?$~', $field["length"], $match) ? ((ereg("binary", $field["type"]) ? 2 : 1) * $match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0)); - if ($connection->server_info >= 5.6 && ereg('time', $field["type"])) { + if ($jush == 'sql' && $connection->server_info >= 5.6 && ereg('time', $field["type"])) { $maxlength += 7; // microtime } // type='date' and type='time' display localized value which may be confusing, type='datetime' uses 'T' as date and time separator diff --git a/changes.txt b/changes.txt index 3f67d7af..3912df7d 100644 --- a/changes.txt +++ b/changes.txt @@ -4,6 +4,7 @@ Use shadow for highlighting default button Don't use LIMIT 1 if inline updating unique row Order table list by name PostgreSQL: Fix detecting oid column in PDO +PostgreSQL: Handle timestamp types (bug #3614086) Adminer 3.7.0 (released 2013-05-19): Allow more SQL files to be uploaded at the same time