summaryrefslogtreecommitdiff
path: root/modules/system/system.install
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-08-02 18:44:36 +0000
committerDries Buytaert <dries@buytaert.net>2008-08-02 18:44:36 +0000
commita859eb3668d583bc8dd4fc33ed8663db1b4927ac (patch)
tree1ce32f8152e597871bd041729dd865d7d7e67eb4 /modules/system/system.install
parent7f965d0b4bfc1e5dfdbd73b44fe77d91d3be8c2a (diff)
downloadbrdo-a859eb3668d583bc8dd4fc33ed8663db1b4927ac.tar.gz
brdo-a859eb3668d583bc8dd4fc33ed8663db1b4927ac.tar.bz2
- Patch #257009 by bjaspan, mustafu, Freso, Dries et al: fixed simpletest exceptions on PostgreSQL.
Diffstat (limited to 'modules/system/system.install')
-rw-r--r--modules/system/system.install18
1 files changed, 15 insertions, 3 deletions
diff --git a/modules/system/system.install b/modules/system/system.install
index 55eb7b10d..ec85200ae 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -304,10 +304,22 @@ function system_requirements($phase) {
*/
function system_install() {
if ($GLOBALS['db_type'] == 'pgsql') {
+ // We create some custom types and functions using global names instead of
+ // prefixing them like we do with table names. If this function is ever
+ // called again (for example, by the test framework when creating prefixed
+ // test databases), the global names will already exist. We therefore avoid
+ // trying to create them again in that case.
+
// Create unsigned types.
- db_query("CREATE DOMAIN int_unsigned integer CHECK (VALUE >= 0)");
- db_query("CREATE DOMAIN smallint_unsigned smallint CHECK (VALUE >= 0)");
- db_query("CREATE DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0)");
+ if (!db_result(db_query("SELECT COUNT(*) FROM pg_constraint WHERE conname = 'int_unsigned_check'"))) {
+ db_query("CREATE DOMAIN int_unsigned integer CHECK (VALUE >= 0)");
+ }
+ if (!db_result(db_query("SELECT COUNT(*) FROM pg_constraint WHERE conname = 'smallint_unsigned_check'"))) {
+ db_query("CREATE DOMAIN smallint_unsigned smallint CHECK (VALUE >= 0)");
+ }
+ if (!db_result(db_query("SELECT COUNT(*) FROM pg_constraint WHERE conname = 'bigint_unsigned_check'"))) {
+ db_query("CREATE DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0)");
+ }
// Create functions.
db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric) RETURNS numeric AS