mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 07:36:44 +02:00
MySQL, PostgreSQL: Fix queries splitting and string constants
Thanks to alxivnov (https://github.com/vrana/adminer/pull/490).
This commit is contained in:
@@ -630,6 +630,10 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)
|
||||
return array();
|
||||
}
|
||||
|
||||
function is_c_style_escapes() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function show_status() {
|
||||
return array();
|
||||
}
|
||||
|
@@ -1056,6 +1056,18 @@ if (!defined("DRIVER")) {
|
||||
return get_key_vals("SHOW VARIABLES");
|
||||
}
|
||||
|
||||
/** Checks if C-style escapes are supported
|
||||
* @return bool
|
||||
*/
|
||||
function is_c_style_escapes() {
|
||||
static $c_style = null;
|
||||
if ($c_style === null) {
|
||||
$variables = get_key_vals("SHOW VARIABLES LIKE 'sql_mode'");
|
||||
$c_style = strpos($variables["sql_mode"], 'NO_BACKSLASH_ESCAPES') === false;
|
||||
}
|
||||
return $c_style;
|
||||
}
|
||||
|
||||
/** Get process list
|
||||
* @return array ($row)
|
||||
*/
|
||||
|
@@ -479,6 +479,10 @@ AND c_src.TABLE_NAME = " . q($table);
|
||||
return get_key_vals('SELECT name, display_value FROM v$parameter');
|
||||
}
|
||||
|
||||
function is_c_style_escapes() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function process_list() {
|
||||
return get_rows('SELECT sess.process AS "process", sess.username AS "user", sess.schemaname AS "schema", sess.status AS "status", sess.wait_class AS "wait_class", sess.seconds_in_wait AS "seconds_in_wait", sql.sql_text AS "sql_text", sess.machine AS "machine", sess.port AS "port"
|
||||
FROM v$session sess LEFT OUTER JOIN v$sql sql
|
||||
|
@@ -860,6 +860,15 @@ AND typelem = 0"
|
||||
return get_key_vals("SHOW ALL");
|
||||
}
|
||||
|
||||
function is_c_style_escapes() {
|
||||
static $c_style = null;
|
||||
if ($c_style === null) {
|
||||
$vals = get_vals("SHOW standard_conforming_strings");
|
||||
$c_style = $vals[0] == "off";
|
||||
}
|
||||
return $c_style;
|
||||
}
|
||||
|
||||
function process_list() {
|
||||
return get_rows("SELECT * FROM pg_stat_activity ORDER BY " . (min_version(9.2) ? "pid" : "procpid"));
|
||||
}
|
||||
|
@@ -764,6 +764,10 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
function is_c_style_escapes() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function show_status() {
|
||||
$return = array();
|
||||
foreach (get_vals("PRAGMA compile_options") as $option) {
|
||||
|
@@ -81,7 +81,15 @@ if (!$error && $_POST) {
|
||||
$offset = $pos + strlen($found);
|
||||
|
||||
if ($found && rtrim($found) != $delimiter) { // find matching quote or comment end
|
||||
while (preg_match('(' . ($found == '/*' ? '\*/' : ($found == '[' ? ']' : (preg_match('~^-- |^#~', $found) ? "\n" : preg_quote($found) . "|\\\\."))) . '|$)s', $query, $match, PREG_OFFSET_CAPTURE, $offset)) { //! respect sql_mode NO_BACKSLASH_ESCAPES
|
||||
$c_style_escapes = is_c_style_escapes() || ($jush == "pgsql" && ($pos > 0 && strtolower($query[$pos - 1]) == "e"));
|
||||
|
||||
$pattern = ($found == '/*' ? '\*/'
|
||||
: ($found == '[' ? ']'
|
||||
: (preg_match('~^-- |^#~', $found) ? "\n"
|
||||
: preg_quote($found) . ($c_style_escapes ? "|\\\\." : "")
|
||||
)));
|
||||
|
||||
while (preg_match("($pattern|\$)s", $query, $match, PREG_OFFSET_CAPTURE, $offset)) {
|
||||
$s = $match[0][0];
|
||||
if (!$s && $fp && !feof($fp)) {
|
||||
$query .= fread($fp, 1e5);
|
||||
|
Reference in New Issue
Block a user