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) . ")"
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() : '') : '')
$params['NextToken'] = $this->next;
}
$result = sdb_request_all('Select', 'Item', $params, $this->timeout); //! respect $unbuffered
+ $this->timeout = 0;
if ($result === false) {
return $result;
}
function rollback() {
return false;
}
+
+ function slowQuery($query, $timeout) {
+ $this->_conn->timeout = $timeout;
+ return $query;
+ }
}
return queries("ROLLBACK");
}
+ /** Return query with a timeout
+ * @param string
+ * @param int seconds
+ * @return string or null if the driver doesn't support query timeouts
+ */
+ function slowQuery($query, $timeout) {
+ }
+
/** Convert column to be searchable
* @param string escaped column name
* @param array array("op" => , "val" => )
/** Get keys from first column and values from second
* @param string
* @param Min_DB
-* @param float
* @param bool
* @return array
*/
-function get_key_vals($query, $connection2 = null, $timeout = 0, $set_keys = true) {
+function get_key_vals($query, $connection2 = null, $set_keys = true) {
global $connection;
if (!is_object($connection2)) {
$connection2 = $connection;
}
$return = array();
- $connection2->timeout = $timeout;
$result = $connection2->query($query);
- $connection2->timeout = 0;
if (is_object($result)) {
while ($row = $result->fetch_row()) {
if ($set_keys) {
* @return array of strings
*/
function slow_query($query) {
- global $adminer, $token;
+ global $adminer, $token, $driver;
$db = $adminer->database();
$timeout = $adminer->queryTimeout();
- if (support("kill") && is_object($connection2 = connect()) && ($db == "" || $connection2->select_db($db))) {
+ $slow_query = $driver->slowQuery($query, $timeout);
+ if (!$slow_query && support("kill") && is_object($connection2 = connect()) && ($db == "" || $connection2->select_db($db))) {
$kill = $connection2->result(connection_id()); // MySQL and MySQLi can use thread_id but it's not in PDO_MySQL
?>
<script<?php echo nonce(); ?>>
}
ob_flush();
flush();
- $return = @get_key_vals($query, $connection2, $timeout, false); // @ - may be killed
+ $return = @get_key_vals(($slow_query ? $slow_query : $query), $connection2, false); // @ - may be killed
if ($connection2) {
echo script("clearTimeout(timeout);");
ob_flush();
Adminer 4.6.3-dev:
Stop session before connecting
+Simplify running slow queries
Fix displaying info about non-alphabetical objects (bug #599)
PDO: Support binary fields download
MySQL: Use CONVERT() only when searching for non-ASCII (bug #603)