aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r--phpBB/includes/db/mssql.php30
-rw-r--r--phpBB/includes/db/mssql_odbc.php30
-rw-r--r--phpBB/includes/db/postgres.php30
3 files changed, 90 insertions, 0 deletions
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index 3a750a2847..0e7ee89196 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -351,6 +351,36 @@ class dbal_mssql extends dbal
switch ($mode)
{
case 'start':
+ $explain_query = $query;
+ if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m))
+ {
+ $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2];
+ }
+ else if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m))
+ {
+ $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2];
+ }
+
+ if (preg_match('/^SELECT/', $explain_query))
+ {
+ $html_table = false;
+ @mssql_query("SET SHOWPLAN_TEXT ON;", $this->db_connect_id);
+ if ($result = @mssql_query($explain_query, $this->db_connect_id))
+ {
+ @mssql_next_result($result);
+ while ($row = @mssql_fetch_row($result))
+ {
+ $html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
+ }
+ }
+ @mssql_query("SET SHOWPLAN_TEXT OFF;", $this->db_connect_id);
+ @mssql_free_result($result);
+
+ if ($html_table)
+ {
+ $this->html_hold .= '</table>';
+ }
+ }
break;
case 'fromcache':
diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php
index bfefa04bf1..1e219f985e 100644
--- a/phpBB/includes/db/mssql_odbc.php
+++ b/phpBB/includes/db/mssql_odbc.php
@@ -347,6 +347,36 @@ class dbal_mssql_odbc extends dbal
switch ($mode)
{
case 'start':
+ $explain_query = $query;
+ if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m))
+ {
+ $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2];
+ }
+ else if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m))
+ {
+ $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2];
+ }
+
+ if (preg_match('/^SELECT/', $explain_query))
+ {
+ $html_table = false;
+ @odbc_exec($this->db_connect_id, "SET SHOWPLAN_TEXT ON;");
+ if ($result = @odbc_exec($this->db_connect_id, $explain_query))
+ {
+ @odbc_next_result($result);
+ while ($row = @odbc_fetch_array($result))
+ {
+ $html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
+ }
+ }
+ @odbc_exec($this->db_connect_id, "SET SHOWPLAN_TEXT OFF;");
+ @odbc_free_result($result);
+
+ if ($html_table)
+ {
+ $this->html_hold .= '</table>';
+ }
+ }
break;
case 'fromcache':
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index 55f4e27eff..eb8c931fa5 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -368,6 +368,36 @@ class dbal_postgres extends dbal
switch ($mode)
{
case 'start':
+
+ $explain_query = $query;
+ if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m))
+ {
+ $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2];
+ }
+ else if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m))
+ {
+ $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2];
+ }
+
+ if (preg_match('/^SELECT/', $explain_query))
+ {
+ $html_table = false;
+
+ if ($result = @pg_query($this->db_connect_id, "EXPLAIN $explain_query"))
+ {
+ while ($row = @pg_fetch_assoc($result, NULL))
+ {
+ $html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
+ }
+ }
+ @pg_free_result($result);
+
+ if ($html_table)
+ {
+ $this->html_hold .= '</table>';
+ }
+ }
+
break;
case 'fromcache':