Display warnings in messages

This commit is contained in:
Jakub Vrana 2018-02-01 09:21:50 +01:00
parent ae2ea56681
commit e3346fb0bc
3 changed files with 16 additions and 4 deletions

View file

@ -616,19 +616,30 @@ class Adminer {
* @return string
*/
function messageQuery($query, $time) {
global $jush;
global $jush, $driver;
restart_session();
$history = &get_session("queries");
if (!$history[$_GET["db"]]) {
$history[$_GET["db"]] = array();
}
$id = "sql-" . count($history[$_GET["db"]]);
if (strlen($query) > 1e6) {
$query = preg_replace('~[\x80-\xFF]+$~', '', substr($query, 0, 1e6)) . "\n..."; // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
}
$history[$_GET["db"]][] = array($query, time(), $time); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
return " <span class='time'>" . @date("H:i:s") . "</span>" // @ - time zone may be not set
$return = " <span class='time'>" . @date("H:i:s") . "</span>"; // @ - time zone may be not set
$warnings = $driver->warnings();
$print = "";
if ($warnings && $warnings->num_rows) {
$id = "warnings-" . count($history[$_GET["db"]]);
$return .= " <a href='#$id' class='toggle'>" . lang('Warnings') . "</a>,";
ob_start();
select($warnings); // select() usually needs to print a big table progressively
$print = "<div id='$id' class='hidden'>\n" . ob_get_clean() . "</div>\n";
}
$id = "sql-" . count($history[$_GET["db"]]);
return $return
. " <a href='#$id' class='toggle'>" . lang('SQL command') . "</a>"
. $print
. "<div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></pre>'
. ($time ? " <span class='time'>($time)</span>" : '')
. (support("sql") ? '<p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a>' : '')

View file

@ -37,6 +37,7 @@ input.wayoff { left: -1000px; position: absolute; }
.error { color: red; background: #fee; }
.error b { background: #fff; font-weight: normal; }
.message { color: green; background: #efe; }
.message table { color: #000; background: #fff; }
.error, .message { padding: .5em .8em; margin: 1em 20px 0 0; }
.char { color: #007F00; }
.date { color: #7F007F; }

View file

@ -4,7 +4,7 @@ PHP <5.3 compatibility even with Elasticsearch enabled
Fully support functions in default values
Stop redirecting links via adminer.org
Support X-Forwarded-Prefix
MySQL: Display warnings in SQL command and select
MySQL: Display warnings
MariaDB: Support JSON since MariaDB 10.2
PostgreSQL: Support functions
PostgreSQL: Allow editing views with uppercase letters (bug #467)