mirror of
https://github.com/vrana/adminer.git
synced 2025-08-18 04:11:27 +02:00
Simplify running slow queries
This commit is contained in:
@@ -298,6 +298,16 @@ if (!defined("DRIVER")) {
|
||||
return queries($prefix . implode(",\n", $values) . $suffix);
|
||||
}
|
||||
|
||||
function slowQuery($query, $timeout) {
|
||||
if (min_version('5.7.8', '10.1.2')) {
|
||||
if (preg_match('~MariaDB~', $this->_conn->server_info)) {
|
||||
return "SET STATEMENT max_statement_time=$timeout FOR $query";
|
||||
} elseif (preg_match('~^(SELECT\b)(.+)~is', $query, $match)) {
|
||||
return "$match[1] /*+ MAX_EXECUTION_TIME(" . ($timeout * 1000) . ") */ $match[2]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function convertSearch($idf, $val, $field) {
|
||||
return (preg_match('~char|text|enum|set~', $field["type"]) && !preg_match("~^utf8~", $field["collation"]) && preg_match('~[\x80-\xFF]~', $val['val'])
|
||||
? "CONVERT($idf USING " . charset($this->_conn) . ")"
|
||||
|
@@ -193,6 +193,11 @@ if (isset($_GET["pgsql"])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function slowQuery($query, $timeout) {
|
||||
// BEGIN, COMMIT - automatically wrapped into a transaction by pg_query but not by PDO
|
||||
return "BEGIN; SET LOCAL statement_timeout = " . (1000 * $timeout) . "; $query; COMMIT";
|
||||
}
|
||||
|
||||
function convertSearch($idf, $val, $field) {
|
||||
return (preg_match('~char|text'
|
||||
. (!preg_match('~LIKE~', $val["op"]) ? '|date|time(stamp)?' . (is_numeric($val["val"]) ? '|' . number_type() : '') : '')
|
||||
|
@@ -19,6 +19,7 @@ if (isset($_GET["simpledb"])) {
|
||||
$params['NextToken'] = $this->next;
|
||||
}
|
||||
$result = sdb_request_all('Select', 'Item', $params, $this->timeout); //! respect $unbuffered
|
||||
$this->timeout = 0;
|
||||
if ($result === false) {
|
||||
return $result;
|
||||
}
|
||||
@@ -236,6 +237,11 @@ if (isset($_GET["simpledb"])) {
|
||||
function rollback() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function slowQuery($query, $timeout) {
|
||||
$this->_conn->timeout = $timeout;
|
||||
return $query;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user