summaryrefslogtreecommitdiff
path: root/includes/database/pgsql
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-06-15 16:12:06 +0000
committerDries Buytaert <dries@buytaert.net>2010-06-15 16:12:06 +0000
commit5f5c024b6d4730f1b052de2714a02839c251bd1a (patch)
tree3863f0a7d500f2d2ae89b455aa50d950080def7b /includes/database/pgsql
parent75442c9675cc2c2656f382431320b54696cd7dfc (diff)
downloadbrdo-5f5c024b6d4730f1b052de2714a02839c251bd1a.tar.gz
brdo-5f5c024b6d4730f1b052de2714a02839c251bd1a.tar.bz2
- Patch #515310 by Josh Waihi, marcvangend: inserting &gt;PHP_INT_MAX into BIGINT fails on PostgreSQL.
Diffstat (limited to 'includes/database/pgsql')
-rw-r--r--includes/database/pgsql/install.inc32
1 files changed, 32 insertions, 0 deletions
diff --git a/includes/database/pgsql/install.inc b/includes/database/pgsql/install.inc
index 7f63f6cc3..e953b91e8 100644
--- a/includes/database/pgsql/install.inc
+++ b/includes/database/pgsql/install.inc
@@ -18,6 +18,10 @@ class DatabaseTasks_pgsql extends DatabaseTasks {
'arguments' => array(),
);
$this->tasks[] = array(
+ 'function' => 'checkPHPVersion',
+ 'arguments' => array(),
+ );
+ $this->tasks[] = array(
'function' => 'initializeDatabase',
'arguments' => array(),
);
@@ -51,6 +55,34 @@ class DatabaseTasks_pgsql extends DatabaseTasks {
}
/**
+ * Check PHP version.
+ *
+ * There is a bug in PHP versions < 5.2.11 and < 5.3.1 that prevents
+ * PostgreSQL from inserting integer values into numeric columns that exceed
+ * the PHP_INT_MAX value (value varies dependant on 32 or 64 bit CPU).
+ */
+ function checkPHPVersion() {
+ try {
+ $txn = db_transaction();
+ db_query("CREATE TABLE test_php_version ( test_int INT NOT NULL )");
+ // See http://bugs.php.net/bug.php?id=48924 as to why this query may
+ // fail. The error will throw an Exception so there is no need to test to
+ // see if the row inserted or not.
+ db_query("INSERT INTO test_php_version ( test_int ) VALUES (:big_int)", array(':big_int' => PHP_INT_MAX + 1));
+ db_query("DROP TABLE test_php_version");
+ $this->pass(st('PHP is at the correct version to run on PostgreSQL.'));
+ }
+ catch (Exception $e) {
+ // Failing is not fatal but the user should still be warned of the
+ // limitations of running PostgreSQL on the current version of PHP.
+ $text = 'The version of PHP you are using has known issues with PostgreSQL. You can see more at ';
+ $text .= l('http://drupal.org/node/515310', 'http://drupal.org/node/515310') . '. ';
+ $text .= 'We suggest you upgrade PHP to 5.2.11, 5.3.1 or greater. Failing to do so may result in serious data corruption later.';
+ drupal_set_message(st($text), 'warning');
+ }
+ }
+
+ /**
* Make PostgreSQL Drupal friendly.
*/
function initializeDatabase() {