? cvs_get_vanilla.sh
? drupal-head-revisions_43+pgsql_2.diff
? database/.updates.inc.swp
? database/updates.inc-1.114
? database/updates.inc-pgsql_fix4.diff
Index: database/database.pgsql
===================================================================
RCS file: /cvs/drupal/drupal/database/database.pgsql,v
retrieving revision 1.140
diff -u -p -r1.140 database.pgsql
--- database/database.pgsql	18 Oct 2005 14:41:26 -0000	1.140
+++ database/database.pgsql	27 Oct 2005 21:15:15 -0000
@@ -522,7 +522,7 @@ CREATE TABLE url_alias (
   PRIMARY KEY (pid)
 );
 CREATE INDEX url_alias_dst_idx ON url_alias(dst);
-CREATE INDEX url_alias_src ON url_alias(src);
+CREATE INDEX url_alias_src_idx ON url_alias(src);
 --
 -- Table structure for permission
 --
Index: database/updates.inc
===================================================================
RCS file: /cvs/drupal/drupal/database/updates.inc,v
retrieving revision 1.140
diff -u -p -r1.140 updates.inc
--- database/updates.inc	22 Oct 2005 15:14:46 -0000	1.140
+++ database/updates.inc	27 Oct 2005 21:15:15 -0000
@@ -519,7 +519,7 @@ function update_129() {
     $ret[] = update_sql("ALTER TABLE {vocabulary} ADD tags tinyint(3) unsigned default '0' NOT NULL");
   }
   elseif ($GLOBALS['db_type'] == 'pgsql') {
-    $ret[] = update_sql("ALTER TABLE {vocabulary} ADD tags smallint default '0' NOT NULL");
+    db_add_column($ret, 'vocabulary', 'tags', 'smallint', array('unsigned' => true, 'default' => 0, 'not null' => true));
   }
 
   return $ret;
@@ -528,10 +528,10 @@ function update_129() {
 function update_130() {
   $ret = array();
   if ($GLOBALS['db_type'] == 'mysql') {
-    $ret[] = update_sql("ALTER TABLE {sessions} ADD cache int(11) NOT NULL default '0' AFTER timestamp");
+    $ret[] = update_sql("ALTER TABLE {sessions} ADD cache int(11) NOT NULL default '0'"); // It is said that we should not depend on column orders thus removing "AFTER column" 
   }
   elseif ($GLOBALS['db_type'] == 'pgsql') {
-    $ret[] = update_sql("ALTER TABLE {sessions} ADD cache int(11) NOT NULL default '0' AFTER timestamp");
+    db_add_column($ret, 'sessions', 'cache', 'int', array('default' => 0, 'not null' => true));
   }
   return $ret;
 }
@@ -541,11 +541,10 @@ function update_131() {
 
   if ($GLOBALS['db_type'] == 'mysql') {
     $ret[] = update_sql("ALTER TABLE {boxes} DROP INDEX title");
-    $ret[] = update_sql("ALTER TABLE {boxes} ADD INDEX title (title)");
+    // Removed recreation of the index, which is not present in the db schema
   }
   elseif ($GLOBALS['db_type'] == 'pgsql') {
-    $ret[] = update_sql("DROP INDEX boxes_title_idx");;
-    $ret[] = update_sql("CREATE INDEX title ON {boxes} (title)");
+    $ret[] = update_sql("ALTER TABLE {boxes} DROP CONSTRAINT {boxes}_title_key;");
   }
 
   return $ret;
@@ -575,25 +574,28 @@ function update_132() {
 }
 
 function update_133() {
-  $ret[] = update_sql("CREATE TABLE {contact} (
-    subject varchar(255) NOT NULL default '',
-    recipients longtext NOT NULL default '',
-    reply longtext NOT NULL default ''
-    )");
-
+  $ret = array();
+  
   if ($GLOBALS['db_type'] == 'mysql') {
+    $ret[] = update_sql("CREATE TABLE {contact} (
+      subject varchar(255) NOT NULL default '',
+      recipients longtext NOT NULL default '',
+      reply longtext NOT NULL default ''
+      )");
     $ret[] = update_sql("ALTER TABLE {users} ADD login int(11) NOT NULL default '0'");
   }
   elseif ($GLOBALS['db_type'] == 'pgsql') {
-    $ret[] = update_sql("ALTER TABLE {users} ADD login integer");
-    $ret[] = update_sql("ALTER TABLE {users} ALTER COLUMN login SET NOT NULL");
-    $ret[] = update_sql("ALTER TABLE {users} ALTER COLUMN login SET DEFAULT '0'");
+    // Table {contact} is changed in update_143() so I have moved it's creation there.
+    // It was never created here for postgres because of errors.
+    
+    db_add_column($ret, 'users', 'login', 'int', array('default' => 0, 'not null' => true));
   }
 
   return $ret;
 }
 
 function update_134() {
+  $ret = array();
   if ($GLOBALS['db_type'] == 'mysql') {
     $ret[] = update_sql('ALTER TABLE {blocks} DROP types');
   }
@@ -615,7 +617,19 @@ function update_135() {
 
 function update_136() {
   $ret = array();
-  $ret[] = update_sql("ALTER TABLE {users} CHANGE COLUMN changed access int(11) NOT NULL default '0'");
+  
+  switch ($GLOBALS['db_type']) {
+    case 'pgsql':      
+      $ret[] = update_sql("DROP INDEX {users}_changed_idx"); // We drop the index first because it won't be renamed
+      $ret[] = update_sql("ALTER TABLE {users} RENAME changed TO access");
+      db_add_key($ret, 'users', 'access'); // Re-add the index
+      break;
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("ALTER TABLE {users} CHANGE COLUMN changed access int(11) NOT NULL default '0'");
+      break;
+  }
+  
   $ret[] = update_sql('UPDATE {users} SET access = login WHERE login > created');
   $ret[] = update_sql('UPDATE {users} SET access = created WHERE access = 0');
   return $ret;
@@ -628,12 +642,7 @@ function update_137() {
     $ret[] = update_sql("ALTER TABLE {locales_source} CHANGE location location varchar(255) NOT NULL default ''");
   }
   elseif ($GLOBALS['db_type'] == 'pgsql') {
-    $ret[] = update_sql("ALTER TABLE {locales_source} RENAME location TO location_old");
-    $ret[] = update_sql("ALTER TABLE {locales_source} ADD location varchar(255)");
-    $ret[] = update_sql("UPDATE {locales_source} SET location = location_old");
-    $ret[] = update_sql("ALTER TABLE {locales_source} ALTER location SET NOT NULL");
-    $ret[] = update_sql("ALTER TABLE {locales_source} ALTER location SET DEFAULT ''");
-    $ret[] = update_sql("ALTER TABLE {locales_source} DROP location_old");
+    db_change_column($ret, 'locales_source', 'location', 'location', 'varchar(255)', array('not null' => true, 'default' => ''));
   }
   return $ret;
 }
@@ -647,7 +656,7 @@ function update_138() {
 
 function update_139() {
   $ret = array();
-  $ret[] = update_sql("ALTER TABLE {accesslog} ADD timer int(10) unsigned NOT NULL default '0'");
+  db_add_column($ret, 'accesslog', 'timer', 'int', array('unsigned' => true, 'not null' => true, 'default' => 0));
   return $ret;
 }
 
@@ -658,7 +667,7 @@ function update_140() {
     $ret[] = update_sql("ALTER TABLE {url_alias} ADD INDEX (src)");
   }
   elseif ($GLOBALS['db_type'] == 'pgsql') {
-    $ret[] = update_sql("CREATE INDEX url_alias_src ON {url_alias}(src)");
+    db_add_key($ret, 'url_alias', 'src');
   }
   return $ret;
 }
@@ -673,7 +682,7 @@ function update_141() {
 
 function update_142() {
   $ret = array();
-  $ret[] = update_sql("ALTER TABLE {watchdog} ADD COLUMN referer varchar(128) NOT NULL");
+  db_add_column($ret, 'watchdog', 'referer', 'varchar(128)', array('not null' => true, 'default' => ''));
   return $ret;
 }
 
@@ -682,11 +691,16 @@ function update_143() {
 
   if ($GLOBALS['db_type'] == 'mysql') {
     $ret[] = update_sql("ALTER TABLE {contact} CHANGE subject category VARCHAR(255) NOT NULL ");
+    $ret[] = update_sql("ALTER TABLE {contact} ADD PRIMARY KEY (category)");
   }
   elseif ($GLOBALS['db_type'] == 'pgsql') {
-    $ret[] = update_sql("ALTER TABLE {contact} RENAME COLUMN subject TO category");
+    // Why the table is created here? See update_133().
+    $ret[] = update_sql("CREATE TABLE contact (
+      category varchar(255) NOT NULL default '',
+      recipients text NOT NULL default '',
+      reply text NOT NULL default '',
+      PRIMARY KEY (category))");
   }
-  $ret[] = update_sql("ALTER TABLE {contact} ADD PRIMARY KEY (category)");
 
   return $ret;
 }
