Index: includes/database/pgsql/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/pgsql/database.inc,v
retrieving revision 1.43
diff -u -p -r1.43 database.inc
--- includes/database/pgsql/database.inc	3 Oct 2010 01:29:41 -0000	1.43
+++ includes/database/pgsql/database.inc	17 Nov 2010 09:52:05 -0000
@@ -55,6 +55,11 @@ class DatabaseConnection_pgsql extends D
 
     // Force PostgreSQL to use the UTF-8 character set by default.
     $this->exec("SET NAMES 'UTF8'");
+
+    // Force PostgreSQL to use the escape bytea output by default.
+//    if (version_compare($this->version(), '9') >= 0) {
+      $this->exec("SET bytea_output = 'escape'");
+//    }
   }
 
   public function query($query, array $args = array(), $options = array()) {
Index: includes/database/pgsql/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/pgsql/schema.inc,v
retrieving revision 1.40
diff -u -p -r1.40 schema.inc
--- includes/database/pgsql/schema.inc	28 Oct 2010 02:27:08 -0000	1.40
+++ includes/database/pgsql/schema.inc	17 Nov 2010 09:52:06 -0000
@@ -489,6 +489,17 @@ class DatabaseSchema_pgsql extends Datab
 
     $this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" TYPE ' . $typecast . ' USING "' . $field . '"::' . $typecast);
 
+    if (isset($spec['not null'])) {
+      if ($spec['not null']) {
+        $nullaction = 'SET NOT NULL';
+      }
+      else {
+        $nullaction = 'DROP NOT NULL';
+      }
+      $this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" ' . $nullaction);
+    }
+
+
     if (in_array($spec['pgsql_type'], array('serial', 'bigserial'))) {
       // Type "serial" is known to PostgreSQL, but *only* during table creation,
       // not when altering. Because of that, the sequence needs to be created
