]> git.joonet.de Git - adminer.git/commitdiff
Don't rely on 't' and 'f' PostgreSQL boolean return values
authorJakub Vrana <jakub@vrana.cz>
Mon, 13 May 2013 15:39:10 +0000 (08:39 -0700)
committerJakub Vrana <jakub@vrana.cz>
Mon, 13 May 2013 15:40:06 +0000 (08:40 -0700)
https://sourceforge.net/projects/adminer/forums/forum/1095138/topic/8119905

adminer/drivers/pgsql.inc.php
changes.txt

index e123311d1d0e5d72c60cd9ac9c0c53da27ea547a..2535c433065d89e722aefc9b24ac2d8c363fbb23 100644 (file)
@@ -227,7 +227,7 @@ AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema(
        
        function fields($table) {
                $return = array();
-               foreach (get_rows("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
+               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
 JOIN pg_attribute a ON c.oid = a.attrelid
@@ -242,7 +242,7 @@ ORDER BY a.attnum"
                        ereg('(.*)(\\((.*)\\))?', $row["full_type"], $match);
                        list(, $row["type"], , $row["length"]) = $match;
                        $row["full_type"] = $row["type"] . ($row["length"] ? "($row[length])" : "");
-                       $row["null"] = ($row["attnotnull"] == "f");
+                       $row["null"] = !$row["attnotnull"];
                        $row["auto_increment"] = eregi("^nextval\\(", $row["default"]);
                        $row["privileges"] = array("insert" => 1, "select" => 1, "update" => 1);
                        if (preg_match('~^(.*)::.+$~', $row["default"], $match)) {
@@ -261,8 +261,8 @@ ORDER BY a.attnum"
                $return = array();
                $table_oid = $connection2->result("SELECT oid FROM pg_class WHERE relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema()) AND relname = " . q($table));
                $columns = get_key_vals("SELECT attnum, attname FROM pg_attribute WHERE attrelid = $table_oid AND attnum > 0", $connection2);
-               foreach (get_rows("SELECT relname, indisunique, indisprimary, indkey FROM pg_index i, pg_class ci WHERE i.indrelid = $table_oid AND ci.oid = i.indexrelid", $connection2) as $row) {
-                       $return[$row["relname"]]["type"] = ($row["indisprimary"] == "t" ? "PRIMARY" : ($row["indisunique"] == "t" ? "UNIQUE" : "INDEX"));
+               foreach (get_rows("SELECT relname, indisunique::int, indisprimary::int, indkey FROM pg_index i, pg_class ci WHERE i.indrelid = $table_oid AND ci.oid = i.indexrelid", $connection2) as $row) {
+                       $return[$row["relname"]]["type"] = ($row["indisprimary"] ? "PRIMARY" : ($row["indisunique"] ? "UNIQUE" : "INDEX"));
                        $return[$row["relname"]]["columns"] = array();
                        foreach (explode(" ", $row["indkey"]) as $indkey) {
                                $return[$row["relname"]]["columns"][] = $columns[$indkey];
index fdac2a94f216a611677f0aa7089df55671bd54cb..382dfc157a68789641d2860df04180d27cf684d4 100644 (file)
@@ -19,6 +19,7 @@ MySQL: Fix handling of POINT data type (bug #3582578)
 MySQL: Don't export binary and geometry columns twice in select
 MySQL: Fix EXPLAIN in MySQL < 5.1, bug since Adminer 3.6.4
 SQLite: Export views
+PostgreSQL: Fix swapped NULL and NOT NULL columns in weird setups
 
 Adminer 3.6.4 (released 2013-04-26):
 Display pagination on a fixed position