Skip to content

Commit

Permalink
Oracle: Use correct DB in db_size, fix typo (thanks to Shirai Takashi)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrana committed Feb 10, 2021
1 parent fd1dd4e commit 29e2475
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions adminer/drivers/oracle.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
if (extension_loaded("oci8")) {
class Min_DB {
var $extension = "oci8", $_link, $_result, $server_info, $affected_rows, $errno, $error;
var $_current_db;

function _error($errno, $error) {
if (ini_bool("html_errors")) {
Expand All @@ -31,6 +32,7 @@ function quote($string) {
}

function select_db($database) {
$this->_current_db = $database;
return true;
}

Expand All @@ -51,6 +53,7 @@ function query($query, $unbuffered = false) {
return new Min_Result($result);
}
$this->affected_rows = oci_num_rows($result);
oci_free_statement($result);
}
return $return;
}
Expand Down Expand Up @@ -118,13 +121,15 @@ function __destruct() {
} elseif (extension_loaded("pdo_oci")) {
class Min_DB extends Min_PDO {
var $extension = "PDO_OCI";
var $_current_db;

function connect($server, $username, $password) {
$this->dsn("oci:dbname=//$server;charset=AL32UTF8", $username, $password);
return true;
}

function select_db($database) {
$this->_current_db = $database;
return true;
}
}
Expand Down Expand Up @@ -211,6 +216,13 @@ function logged_user() {
return $connection->result("SELECT USER FROM DUAL");
}

function get_current_db() {
global $connection;
$db = $connection->_current_db ? $connection->_current_db : DB;
unset($connection->_current_db);
return $db;
}

function where_owner($prefix, $owner = "owner") {
if (!$_GET["ns"]) {
return '';
Expand Down Expand Up @@ -244,9 +256,10 @@ function count_tables($databases) {
function table_status($name = "") {
$return = array();
$search = q($name);
$db = get_current_db();
$view = views_table("view_name");
$owner = where_owner(" AND ");
foreach (get_rows('SELECT table_name "Name", \'table\' "Engine", avg_row_len * num_rows "Data_length", num_rows "Rows" FROM all_tables WHERE tablespace_name = ' . q(DB) . $owner . ($name != "" ? " AND table_name = $search" : "") . "
foreach (get_rows('SELECT table_name "Name", \'table\' "Engine", avg_row_len * num_rows "Data_length", num_rows "Rows" FROM all_tables WHERE tablespace_name = ' . q($db) . $owner . ($name != "" ? " AND table_name = $search" : "") . "
UNION SELECT view_name, 'view', 0, 0 FROM $view" . ($name != "" ? " WHERE view_name = $search" : "") . "
ORDER BY 1"
) as $row) {
Expand Down Expand Up @@ -488,7 +501,7 @@ function unconvert_field($field, $return) {
}

function support($feature) {
return preg_match('~^(columns|database|drop_col|indexes|descidx|processlist|scheme|sql|status|table|variables|view$~', $feature); //!
return preg_match('~^(columns|database|drop_col|indexes|descidx|processlist|scheme|sql|status|table|variables|view)$~', $feature); //!
}

function driver_config() {
Expand Down

0 comments on commit 29e2475

Please sign in to comment.