aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2007-06-09 14:58:50 +0000
committerDavid M <davidmj@users.sourceforge.net>2007-06-09 14:58:50 +0000
commitf31c53963a15d09d5fe942c9951e04bd7a655919 (patch)
tree89697ab5323a97ae484997bf6aa2d6bb6b4aea7b /phpBB/includes/db
parent16f60f8838d8f89a14f01051fc5e792e3060ac10 (diff)
downloadforums-f31c53963a15d09d5fe942c9951e04bd7a655919.tar
forums-f31c53963a15d09d5fe942c9951e04bd7a655919.tar.gz
forums-f31c53963a15d09d5fe942c9951e04bd7a655919.tar.bz2
forums-f31c53963a15d09d5fe942c9951e04bd7a655919.tar.xz
forums-f31c53963a15d09d5fe942c9951e04bd7a655919.zip
- Oracle gives us null instead of '', this is now fixed (thanks APTX)
- Oracle can now explain queries git-svn-id: file:///svn/phpbb/trunk@7741 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r--phpBB/includes/db/oracle.php69
1 files changed, 68 insertions, 1 deletions
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index bddf1602b3..ff0a8f53f7 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -386,12 +386,18 @@ class dbal_oracle extends dbal
$result_row = array();
foreach ($row as $key => $value)
{
+ // Oracle treats empty strings as null
+ if (is_null($value))
+ {
+ $value = '';
+ }
+
// OCI->CLOB?
if (is_object($value))
{
$value = $value->load();
}
-
+
$result_row[strtolower($key)] = $value;
}
@@ -550,6 +556,67 @@ class dbal_oracle extends dbal
switch ($mode)
{
case 'start':
+
+ $html_table = false;
+
+ // Grab a plan table, any will do
+ $sql = "SELECT table_name
+ FROM USER_TABLES
+ WHERE table_name LIKE '%PLAN_TABLE%'";
+ $stmt = ociparse($this->db_connect_id, $sql);
+ ociexecute($stmt);
+ $result = array();
+
+ if (ocifetchinto($stmt, $result, OCI_ASSOC + OCI_RETURN_NULLS))
+ {
+ $table = $result['TABLE_NAME'];
+
+ // This is the statement_id that will allow us to track the plan
+ $statement_id = substr(md5($query), 0, 30);
+
+ // Remove any stale plans
+ $stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'");
+ ociexecute($stmt2);
+ ocifreestatement($stmt2);
+
+ // Explain the plan
+ $sql = "EXPLAIN PLAN
+ SET STATEMENT_ID = '$statement_id'
+ FOR $query";
+ $stmt2 = ociparse($this->db_connect_id, $sql);
+ ociexecute($stmt2);
+ ocifreestatement($stmt2);
+
+ // Get the data from the plan
+ $sql = "SELECT operation, options, object_name, object_type, cardinality, cost
+ FROM plan_table
+ START WITH id = 0 AND statement_id = '$statement_id'
+ CONNECT BY PRIOR id = parent_id
+ AND statement_id = '$statement_id'";
+ $stmt2 = ociparse($this->db_connect_id, $sql);
+ ociexecute($stmt2);
+
+ $row = array();
+ while (ocifetchinto($stmt2, $row, OCI_ASSOC + OCI_RETURN_NULLS))
+ {
+ $html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
+ }
+
+ ocifreestatement($stmt2);
+
+ // Remove the plan we just made, we delete them on request anyway
+ $stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'");
+ ociexecute($stmt2);
+ ocifreestatement($stmt2);
+ }
+
+ ocifreestatement($stmt);
+
+ if ($html_table)
+ {
+ $this->html_hold .= '</table>';
+ }
+
break;
case 'fromcache':