aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r--phpBB/includes/db/dbal.php10
-rw-r--r--phpBB/includes/db/firebird.php49
-rw-r--r--phpBB/includes/db/mssqlnative.php10
-rw-r--r--phpBB/includes/db/postgres.php36
4 files changed, 100 insertions, 5 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index 5d8d5fbd47..d7860fc8bc 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -242,6 +242,16 @@ class dbal
}
/**
+ * Returns whether results of a query need to be buffered to run a transaction while iterating over them.
+ *
+ * @return bool Whether buffering is required.
+ */
+ function sql_buffer_nested_transaction()
+ {
+ return false;
+ }
+
+ /**
* SQL Transaction
* @access private
*/
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php
index 6f60dd5dad..7e3f15ed1d 100644
--- a/phpBB/includes/db/firebird.php
+++ b/phpBB/includes/db/firebird.php
@@ -28,6 +28,7 @@ class dbal_firebird extends dbal
var $last_query_text = '';
var $service_handle = false;
var $affected_rows = 0;
+ var $connect_error = '';
/**
* Connect to server
@@ -53,9 +54,35 @@ class dbal_firebird extends dbal
$use_database = $this->server . ':' . $this->dbname;
}
- $this->db_connect_id = ($this->persistency) ? @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3) : @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3);
+ if ($this->persistency)
+ {
+ if (!function_exists('ibase_pconnect'))
+ {
+ $this->connect_error = 'ibase_pconnect function does not exist, is interbase extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3);
+ }
+ else
+ {
+ if (!function_exists('ibase_connect'))
+ {
+ $this->connect_error = 'ibase_connect function does not exist, is interbase extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3);
+ }
- $this->service_handle = (function_exists('ibase_service_attach') && $this->server) ? @ibase_service_attach($this->server, $this->user, $sqlpassword) : false;
+ // Do not call ibase_service_attach if connection failed,
+ // otherwise error message from ibase_(p)connect call will be clobbered.
+ if ($this->db_connect_id && function_exists('ibase_service_attach') && $this->server)
+ {
+ $this->service_handle = @ibase_service_attach($this->server, $this->user, $sqlpassword);
+ }
+ else
+ {
+ $this->service_handle = false;
+ }
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
}
@@ -471,8 +498,24 @@ class dbal_firebird extends dbal
*/
function _sql_error()
{
+ // Need special handling here because ibase_errmsg returns
+ // connection errors, however if the interbase extension
+ // is not installed then ibase_errmsg does not exist and
+ // we cannot call it.
+ if (function_exists('ibase_errmsg'))
+ {
+ $msg = @ibase_errmsg();
+ if (!$msg)
+ {
+ $msg = $this->connect_error;
+ }
+ }
+ else
+ {
+ $msg = $this->connect_error;
+ }
return array(
- 'message' => @ibase_errmsg(),
+ 'message' => $msg,
'code' => (@function_exists('ibase_errcode') ? @ibase_errcode() : '')
);
}
diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php
index 7ed4146f27..8912cda178 100644
--- a/phpBB/includes/db/mssqlnative.php
+++ b/phpBB/includes/db/mssqlnative.php
@@ -259,6 +259,14 @@ class dbal_mssqlnative extends dbal
}
/**
+ * {@inheritDoc}
+ */
+ function sql_buffer_nested_transaction()
+ {
+ return true;
+ }
+
+ /**
* SQL Transaction
* @access private
*/
@@ -628,7 +636,7 @@ class dbal_mssqlnative extends dbal
return false;
}
}
-
+
/**
* Allows setting mssqlnative specific query options passed to sqlsrv_query as 4th parameter.
*/
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index 4360c790a1..bb116e0763 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -18,6 +18,11 @@ if (!defined('IN_PHPBB'))
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
+if (!class_exists('phpbb_error_collector'))
+{
+ include($phpbb_root_path . 'includes/error_collector.' . $phpEx);
+}
+
/**
* PostgreSQL Database Abstraction Layer
* Minimum Requirement is Version 7.3+
@@ -26,6 +31,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
class dbal_postgres extends dbal
{
var $last_query_text = '';
+ var $connect_error = '';
/**
* Connect to server
@@ -81,13 +87,29 @@ class dbal_postgres extends dbal
if ($this->persistency)
{
+ if (!function_exists('pg_pconnect'))
+ {
+ $this->connect_error = 'pg_pconnect function does not exist, is pgsql extension installed?';
+ return $this->sql_error('');
+ }
+ $collector = new phpbb_error_collector;
+ $collector->install();
$this->db_connect_id = (!$new_link) ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW);
}
else
{
+ if (!function_exists('pg_connect'))
+ {
+ $this->connect_error = 'pg_connect function does not exist, is pgsql extension installed?';
+ return $this->sql_error('');
+ }
+ $collector = new phpbb_error_collector;
+ $collector->install();
$this->db_connect_id = (!$new_link) ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW);
}
+ $collector->uninstall();
+
if ($this->db_connect_id)
{
if (version_compare($this->sql_server_info(true), '8.2', '>='))
@@ -102,6 +124,7 @@ class dbal_postgres extends dbal
return $this->db_connect_id;
}
+ $this->connect_error = $collector->format_errors();
return $this->sql_error('');
}
@@ -371,8 +394,19 @@ class dbal_postgres extends dbal
*/
function _sql_error()
{
+ // pg_last_error only works when there is an established connection.
+ // Connection errors have to be tracked by us manually.
+ if ($this->db_connect_id)
+ {
+ $message = @pg_last_error($this->db_connect_id);
+ }
+ else
+ {
+ $message = $this->connect_error;
+ }
+
return array(
- 'message' => (!$this->db_connect_id) ? @pg_last_error() : @pg_last_error($this->db_connect_id),
+ 'message' => $message,
'code' => ''
);
}