Skip to content

Commit

Permalink
PostgreSQL, Oracle: Set schema for EXPLAIN queries in SQL command (bu…
Browse files Browse the repository at this point in the history
…g #706)
  • Loading branch information
vrana committed Nov 11, 2019
1 parent 0678ce1 commit a4e997f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion adminer/drivers/mysql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,10 @@ function get_schema() {

/** Set current schema
* @param string
* @param Min_DB
* @return bool
*/
function set_schema($schema) {
function set_schema($schema, $connection2 = null) {
return true;
}

Expand Down
7 changes: 5 additions & 2 deletions adminer/drivers/oracle.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,12 @@ function get_schema() {
return $connection->result("SELECT sys_context('USERENV', 'SESSION_USER') FROM dual");
}

function set_schema($scheme) {
function set_schema($scheme, $connection2 = null) {
global $connection;
return $connection->query("ALTER SESSION SET CURRENT_SCHEMA = " . idf_escape($scheme));
if (!$connection2) {
$connection2 = $connection;
}
return $connection2->query("ALTER SESSION SET CURRENT_SCHEMA = " . idf_escape($scheme));
}

function show_variables() {
Expand Down
7 changes: 5 additions & 2 deletions adminer/drivers/pgsql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,12 @@ function get_schema() {
return $connection->result("SELECT current_schema()");
}

function set_schema($schema) {
function set_schema($schema, $connection2 = null) {
global $connection, $types, $structured_types;
$return = $connection->query("SET search_path TO " . idf_escape($schema));
if (!$connection2) {
$connection2 = $connection;
}
$return = $connection2->query("SET search_path TO " . idf_escape($schema));
foreach (types() as $type) { //! get types from current_schemas('t')
if (!isset($types[$type])) {
$types[$type] = 0;
Expand Down
2 changes: 1 addition & 1 deletion adminer/include/version.inc.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
$VERSION = "4.7.4";
$VERSION = "4.7.5-dev";
3 changes: 3 additions & 0 deletions adminer/sql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
$connection2 = connect(); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error
if (is_object($connection2) && DB != "") {
$connection2->select_db(DB);
if ($_GET["ns"] != "") {
set_schema($_GET["ns"], $connection2);
}
}
$commands = 0;
$errors = array();
Expand Down
3 changes: 3 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Adminer 4.7.5-dev:
PostgreSQL, Oracle: Set schema for EXPLAIN queries in SQL command (bug #706)

Adminer 4.7.4 (released 2019-10-22):
Fix XSS if Adminer is accessible at URL /data:

Expand Down

0 comments on commit a4e997f

Please sign in to comment.