]> git.joonet.de Git - adminer.git/commitdiff
Handle timestamp PostgreSQL types (bug #3614086)
authorJakub Vrana <jakub@vrana.cz>
Thu, 30 May 2013 00:24:27 +0000 (17:24 -0700)
committerJakub Vrana <jakub@vrana.cz>
Thu, 30 May 2013 00:24:27 +0000 (17:24 -0700)
adminer/drivers/pgsql.inc.php
adminer/include/functions.inc.php
changes.txt

index e82e2f7b8b7ae3cf0abd37f99f6a623bd8072a5c..3cbe23b4c499da908b7d097e6099127a2331e87d 100644 (file)
@@ -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"]);
index db4c0dc5aa72fa13f4d4e8dc439ab93e280d0372..631280271373754e9bec1b182570888f9cf04b51 100644 (file)
@@ -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
index 3f67d7aff7f7869038d24d499a89f229525ff705..3912df7dff4fcfa19372298c1f085ccd827ad7fd 100644 (file)
@@ -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