[development] Error when install two Drupal 6.2 with PGSQL and table prefix (and patch)

Saint-Genest Gwenael gwenael.saint-genest at makina-corpus.com
Thu Jun 19 14:13:16 UTC 2008


Hi,

   Today, i've tried to install two sets of datas into a drupal 6.2
database (with pgsql). With a table prefix i've take an error like :

Warning: pg_query() [function.pg-query]: Query failed: ERROR: type
"int_unsigned" already exists in
/var/www/xxxxxx/drupal-6.2/includes/database.pgsql.inc on line 138
Warning: ERROR: type "int_unsigned" already exists query: CREATE DOMAIN
int_unsigned integer CHECK (VALUE >= 0) in
/var/www/xxxxxx/drupal-6.2/includes/database.pgsql.inc on line 159
Warning: pg_query() [function.pg-query]: Query failed: ERROR: type
"smallint_unsigned" already exists in
/var/www/xxxxxx/drupal-6.2/includes/database.pgsql.inc on line 138
Warning: ERROR: type "smallint_unsigned" already exists query: CREATE
DOMAIN smallint_unsigned smallint CHECK (VALUE >= 0) in
/var/www/xxxxxx/drupal-6.2/includes/database.pgsql.inc on line 159
Warning: pg_query() [function.pg-query]: Query failed: ERROR: type
"bigint_unsigned" already exists in
/var/www/xxxxxx/drupal-6.2/includes/database.pgsql.inc on line 138
Warning: ERROR: type "bigint_unsigned" already exists query: CREATE
DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0) in
/var/www/xxxxxx/drupal-6.2/includes/database.pgsql.inc on line 159

   Ok ... Drupal try to create data types two times ... and crash :(

   If anyone else has the same error, this patch can solve this problem :

--=={ snip }==--
--- drupal-6.2-ref/modules/system/system.install        2008-06-19
10:19:36.000000000 +0200
+++ drupal-6.2/modules/system/system.install    2008-06-19
15:53:28.000000000 +0200
@@ -302,9 +302,15 @@
  function system_install() {
    if ($GLOBALS['db_type'] == 'pgsql') {
      // 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_type WHERE typname
= 'int_unsigned'"))) {
+      db_query("CREATE DOMAIN int_unsigned integer CHECK (VALUE >= 0)");
+    }
+    if (!db_result(db_query("SELECT COUNT(*) FROM pg_type WHERE typname
= 'smallint_unsigned'"))) {
+      db_query("CREATE DOMAIN smallint_unsigned smallint CHECK (VALUE
>= 0)");
+    }
+    if (!db_result(db_query("SELECT COUNT(*) FROM pg_type WHERE typname
= 'bigint_unsigned'"))) {
+      db_query("CREATE DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0)");
+    }

      // Create functions.
      db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric)
RETURNS numeric AS
--=={ snip }==--


Gwen

-- 
Gwenael Saint-Genest
MAKINA CORPUS - www.makina-corpus.com
44 boulevard des Pas Enchantés FR-44230 Saint Sébastien sur Loire
Tel : +33 (0) 2 40 94 96 08


More information about the development mailing list