]> git.joonet.de Git - adminer.git/commitdiff
MySQL: Display warnings in SQL command
authorJakub Vrana <jakub@vrana.cz>
Wed, 31 Jan 2018 16:28:12 +0000 (17:28 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 31 Jan 2018 16:28:12 +0000 (17:28 +0100)
adminer/drivers/mysql.inc.php
adminer/include/driver.inc.php
adminer/include/functions.inc.php
adminer/include/version.inc.php
adminer/lang/cs.inc.php
adminer/lang/xx.inc.php
adminer/sql.inc.php
changes.txt

index cbeda2c897273b2e57cec8289605745deecd68ef..8eba872cec61ec7fcee1c3d17f627976ea6df3fb 100644 (file)
@@ -276,6 +276,10 @@ if (!defined("DRIVER")) {
                        }
                        return queries($prefix . implode(",\n", $values) . $suffix);
                }
+               
+               function warnings() {
+                       return $this->_conn->query("SHOW WARNINGS");
+               }
 
        }
 
index 3be05dff722ce0ee6f23f6aeb8994721a90a9732..37ef47e55bf0359c176d18dcf6d6a15feb584004 100644 (file)
                return queries("BEGIN");
        }
        
+       /** Commit transaction
+       * @return bool
+       */
        function commit() {
                return queries("COMMIT");
        }
        
+       /** Rollback transaction
+       * @return bool
+       */
        function rollback() {
                return queries("ROLLBACK");
        }
        
+       /** Get warnings about the last command
+       * @return resource or false
+       */
+       function warnings() {
+               return false;
+       }
+       
 }
index 5bff85c5aa0fddd1de2153152c84d4f7dabfd17e..30eb1e91f36f740c2df5b76af961ba2a2d5c2699 100644 (file)
@@ -415,7 +415,7 @@ function get_key_vals($query, $connection2 = null, $timeout = 0, $set_keys = tru
 * @param string
 * @param Min_DB
 * @param string
-* @return array associative
+* @return array of associative arrays
 */
 function get_rows($query, $connection2 = null, $error = "<p class='error'>") {
        global $connection;
index e1a68694f667992814349434c639e991b7a30668..d622ca07033dd9ca25a25c193c37302e0c623df2 100644 (file)
@@ -1,2 +1,2 @@
 <?php
-$VERSION = "4.5.1-dev";
+$VERSION = "4.6.0-dev";
index 56cae3b0da1b3dbbe24bf282e3845bcde36be79e..037f98e21c3a39fc0fa30035b85a8cdc3df60654 100644 (file)
@@ -52,6 +52,7 @@ $translations = array(
        'Query executed OK, %d row(s) affected.' => array('Příkaz proběhl v pořádku, byl změněn %d záznam.', 'Příkaz proběhl v pořádku, byly změněny %d záznamy.', 'Příkaz proběhl v pořádku, bylo změněno %d záznamů.'),
        'No commands to execute.' => 'Žádné příkazy k vykonání.',
        'Error in query' => 'Chyba v dotazu',
+       'Warnings' => 'Varování',
        'ATTACH queries are not supported.' => 'Dotazy ATTACH nejsou podporované.',
        'Execute' => 'Provést',
        'Stop on error' => 'Zastavit při chybě',
index cad1d58e9f6be6f3df687530910b7c1b7c0e85bf..987e09cbc76cb57a89d4adacf003309d67f37f02 100644 (file)
@@ -52,6 +52,7 @@ $translations = array(
        'Query executed OK, %d row(s) affected.' => array('Xx, %d.', 'Xx, %d.'),
        'No commands to execute.' => 'Xx.',
        'Error in query' => 'Xx',
+       'Warnings' => 'Xx',
        'ATTACH queries are not supported.' => 'Xx.',
        'Execute' => 'Xx',
        'Stop on error' => 'Xx',
index 408ac5913d91ca468b5e75d4e33f8753d77b4ce8..c7ca3d50e718453b8cec8830583041cebb2fa47b 100644 (file)
@@ -117,9 +117,6 @@ if (!$error && $_POST) {
 
                                                        do {
                                                                $result = $connection->store_result();
-                                                               $time = " <span class='time'>(" . format_time($start) . ")</span>"
-                                                                       . (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : "") // 1000 - maximum length of encoded URL in IE is 2083 characters
-                                                               ;
 
                                                                if ($connection->error) {
                                                                        echo ($_POST["only_errors"] ? $print : "");
@@ -129,41 +126,56 @@ if (!$error && $_POST) {
                                                                                break 2;
                                                                        }
 
-                                                               } elseif (is_object($result)) {
-                                                                       $limit = $_POST["limit"];
-                                                                       $orgtables = select($result, $connection2, array(), $limit);
-                                                                       if (!$_POST["only_errors"]) {
-                                                                               echo "<form action='' method='post'>\n";
-                                                                               $num_rows = $result->num_rows;
-                                                                               echo "<p>" . ($num_rows ? ($limit && $num_rows > $limit ? lang('%d / ', $limit) : "") . lang('%d row(s)', $num_rows) : "");
-                                                                               echo $time;
-                                                                               $id = "export-$commands";
-                                                                               $export = ", <a href='#$id'>" . lang('Export') . "</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "") . "<span id='$id' class='hidden'>: "
-                                                                                       . html_select("output", $adminer->dumpOutput(), $adminer_export["output"]) . " "
-                                                                                       . html_select("format", $dump_format, $adminer_export["format"])
-                                                                                       . "<input type='hidden' name='query' value='" . h($q) . "'>"
-                                                                                       . " <input type='submit' name='export' value='" . lang('Export') . "'><input type='hidden' name='token' value='$token'></span>\n"
-                                                                               ;
-                                                                               if ($connection2 && preg_match("~^($space|\\()*+SELECT\\b~i", $q) && ($explain = explain($connection2, $q))) {
-                                                                                       $id = "explain-$commands";
-                                                                                       echo ", <a href='#$id'>EXPLAIN</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "") . $export;
-                                                                                       echo "<div id='$id' class='hidden'>\n";
-                                                                                       select($explain, $connection2, $orgtables);
-                                                                                       echo "</div>\n";
-                                                                               } else {
-                                                                                       echo $export;
-                                                                               }
-                                                                               echo "</form>\n";
+                                                               } else {
+                                                                       $time = " <span class='time'>(" . format_time($start) . ")</span>"
+                                                                               . (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : "") // 1000 - maximum length of encoded URL in IE is 2083 characters
+                                                                       ;
+                                                                       $warnings = $driver->warnings();
+                                                                       $warnings_id = "warnings-$commands";
+                                                                       if ($warnings && $warnings->num_rows) {
+                                                                               $time .= ", <a href='#$warnings_id'>" . lang('Warnings') . "</a>" . script("qsl('a').onclick = partial(toggle, '$warnings_id');", "");
                                                                        }
+                                                                       if (is_object($result)) {
+                                                                               $limit = $_POST["limit"];
+                                                                               $orgtables = select($result, $connection2, array(), $limit);
+                                                                               if (!$_POST["only_errors"]) {
+                                                                                       echo "<form action='' method='post'>\n";
+                                                                                       $num_rows = $result->num_rows;
+                                                                                       echo "<p>" . ($num_rows ? ($limit && $num_rows > $limit ? lang('%d / ', $limit) : "") . lang('%d row(s)', $num_rows) : "");
+                                                                                       echo $time;
+                                                                                       $id = "export-$commands";
+                                                                                       $export = ", <a href='#$id'>" . lang('Export') . "</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "") . "<span id='$id' class='hidden'>: "
+                                                                                               . html_select("output", $adminer->dumpOutput(), $adminer_export["output"]) . " "
+                                                                                               . html_select("format", $dump_format, $adminer_export["format"])
+                                                                                               . "<input type='hidden' name='query' value='" . h($q) . "'>"
+                                                                                               . " <input type='submit' name='export' value='" . lang('Export') . "'><input type='hidden' name='token' value='$token'></span>\n"
+                                                                                       ;
+                                                                                       if ($connection2 && preg_match("~^($space|\\()*+SELECT\\b~i", $q) && ($explain = explain($connection2, $q))) {
+                                                                                               $id = "explain-$commands";
+                                                                                               echo ", <a href='#$id'>EXPLAIN</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "") . $export;
+                                                                                               echo "<div id='$id' class='hidden'>\n";
+                                                                                               select($explain, $connection2, $orgtables);
+                                                                                               echo "</div>\n";
+                                                                                       } else {
+                                                                                               echo $export;
+                                                                                       }
+                                                                                       echo "</form>\n";
+                                                                               }
 
-                                                               } else {
-                                                                       if (preg_match("~^$space*+(CREATE|DROP|ALTER)$space++(DATABASE|SCHEMA)\\b~i", $q)) {
-                                                                               restart_session();
-                                                                               set_session("dbs", null); // clear cache
-                                                                               stop_session();
+                                                                       } else {
+                                                                               if (preg_match("~^$space*+(CREATE|DROP|ALTER)$space++(DATABASE|SCHEMA)\\b~i", $q)) {
+                                                                                       restart_session();
+                                                                                       set_session("dbs", null); // clear cache
+                                                                                       stop_session();
+                                                                               }
+                                                                               if (!$_POST["only_errors"]) {
+                                                                                       echo "<p class='message' title='" . h($connection->info) . "'>" . lang('Query executed OK, %d row(s) affected.', $connection->affected_rows) . "$time\n";
+                                                                               }
                                                                        }
-                                                                       if (!$_POST["only_errors"]) {
-                                                                               echo "<p class='message' title='" . h($connection->info) . "'>" . lang('Query executed OK, %d row(s) affected.', $connection->affected_rows) . "$time\n";
+                                                                       if ($warnings && $warnings->num_rows && (!$_POST["only_errors"] || is_object($result))) {
+                                                                               echo "<div id='$warnings_id' class='hidden'>\n";
+                                                                               select($warnings);
+                                                                               echo "</div>\n";
                                                                        }
                                                                }
 
index 9c7ac54cce429b7ae04e79eceb64bfc4ddeeacf6..1cc6ea064b9b6be285ea09deb03cdbf0a5c9a939 100644 (file)
@@ -1,8 +1,9 @@
-Adminer 4.5.1-dev:
+Adminer 4.6.0-dev:
 Fix counting selected rows after going back to select page
 PHP <5.3 compatibility even with Elasticsearch enabled
 Fully support functions in default values
 Stop redirecting links via adminer.org
+MySQL: Display warnings in SQL command
 MariaDB: Support JSON since MariaDB 10.2
 PostgreSQL: Support functions
 PostgreSQL: Allow editing views with uppercase letters (bug #467)