=== modified file 'includes/database/mysql/schema.inc'
--- includes/database/mysql/schema.inc	2010-12-08 06:38:59 +0000
+++ includes/database/mysql/schema.inc	2010-12-11 20:07:00 +0000
@@ -159,7 +159,7 @@ class DatabaseSchema_mysql extends Datab
     // $spec['default'] can be NULL, so we explicitly check for the key here.
     if (array_key_exists('default', $spec)) {
       if (is_string($spec['default'])) {
-        $spec['default'] = "'" . $spec['default'] . "'";
+        $spec['default'] = $this->connection->quote($spec['default']);
       }
       elseif (!isset($spec['default'])) {
         $spec['default'] = 'NULL';
@@ -364,7 +364,7 @@ class DatabaseSchema_mysql extends Datab
       $default = 'NULL';
     }
     else {
-      $default = is_string($default) ? "'$default'" : $default;
+      $default = is_string($default) ? $this->connection->quote($default) : $default;
     }
 
     $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` SET DEFAULT ' . $default);

=== modified file 'includes/database/pgsql/schema.inc'
--- includes/database/pgsql/schema.inc	2010-10-28 02:27:08 +0000
+++ includes/database/pgsql/schema.inc	2010-12-11 20:00:44 +0000
@@ -169,7 +169,7 @@ class DatabaseSchema_pgsql extends Datab
       }
     }
     if (isset($spec['default'])) {
-      $default = is_string($spec['default']) ? "'" . $spec['default'] . "'" : $spec['default'];
+      $default = is_string($spec['default']) ? $this->connection->quote($spec['default']) : $spec['default'];
       $sql .= " default $default";
     }
 
@@ -368,7 +368,7 @@ class DatabaseSchema_pgsql extends Datab
       $default = 'NULL';
     }
     else {
-      $default = is_string($default) ? "'$default'" : $default;
+      $default = is_string($default) ? $this->connection->quote($default) : $default;
     }
 
     $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN "' . $field . '" SET DEFAULT ' . $default);

=== modified file 'includes/database/sqlite/schema.inc'
--- includes/database/sqlite/schema.inc	2010-10-22 15:18:56 +0000
+++ includes/database/sqlite/schema.inc	2010-12-11 20:49:21 +0000
@@ -174,7 +174,7 @@ class DatabaseSchema_sqlite extends Data
 
       if (isset($spec['default'])) {
         if (is_string($spec['default'])) {
-          $spec['default'] = "'" . $spec['default'] . "'";
+          $spec['default'] = $this->connection->quote($spec['default']);
         }
         $sql .= ' DEFAULT ' . $spec['default'];
       }
@@ -380,11 +380,33 @@ class DatabaseSchema_sqlite extends Data
       }
       if (isset($mapped_fields[$type])) {
         list($type, $size) = explode(':', $mapped_fields[$type]);
+        $default = $row->dflt_value;
+        // The value retrieved from SQLite is always retreived as a string,
+        // even if the intended value has a different type (NULL, integer,
+        // etc).
+        // Values from SQLite starting with a single quote are meant to be
+        // interpreted as strings.
+        if ($default[0] == "'") {
+          // Single quotes are escaped with a second single quote. De-escape
+          // them to avoid the driver double escaping them (' -> '' -> '''').
+          // Additionally, the first and last characters (both single quotes)
+          // are discarded.
+          $default = str_replace("''", "'", substr($default, 1, -1));
+        }
+        elseif (strtoupper($default) == 'NULL') {
+          $default = NULL;
+        }
+        elseif ($type == 'INTEGER') {
+          $default = (int) $default;
+        }
+        elseif ($type == 'FLOAT') {
+          $default = (float) $default;
+        }
         $schema['fields'][$row->name] = array(
           'type' => $type,
           'size' => $size,
           'not null' => !empty($row->notnull),
-          'default' => trim($row->dflt_value, "'"),
+          'default' => $default,
         );
         if ($length) {
           $schema['fields'][$row->name]['length'] = $length;

=== modified file 'modules/simpletest/tests/schema.test'
--- modules/simpletest/tests/schema.test	2010-12-08 06:38:59 +0000
+++ modules/simpletest/tests/schema.test	2010-12-11 20:51:06 +0000
@@ -233,9 +233,10 @@ class SchemaTestCase extends DrupalWebTe
       );
       $variations = array(
         array('not null' => FALSE),
+        array('not null' => TRUE, 'initial' => 'd', 'default' => '7'),
+        array('not null' => FALSE, 'default' => NULL),
         array('not null' => FALSE, 'default' => '7'),
         array('not null' => TRUE, 'initial' => 'd'),
-        array('not null' => TRUE, 'initial' => 'd', 'default' => '7'),
       );
 
       foreach ($variations as $variation) {
@@ -253,6 +254,7 @@ class SchemaTestCase extends DrupalWebTe
         );
         $variations = array(
           array('not null' => FALSE),
+          array('not null' => FALSE, 'default' => NULL),
           array('not null' => FALSE, 'default' => 7),
           array('not null' => TRUE, 'initial' => 1),
           array('not null' => TRUE, 'initial' => 1, 'default' => 7),
@@ -291,6 +293,21 @@ class SchemaTestCase extends DrupalWebTe
         }
       }
     }
+
+    // Test quotes and semicolons.
+    $base_field_spec = array(
+      'type' => 'varchar',
+      'length' => 255,
+    );
+    $variations = array(
+      array('default' => "Dries' commit"),
+      array('default' => "Axl; Stan"),
+    );
+
+    foreach ($variations as $variation) {
+      $field_spec = $variation + $base_field_spec;
+      $this->assertFieldAdditionRemoval($field_spec);
+    }
   }
 
   /**
@@ -367,7 +384,7 @@ class SchemaTestCase extends DrupalWebTe
     }
 
     // Check that the default value has been registered.
-    if (isset($field_spec['default'])) {
+    if (array_key_exists('default', $field_spec)) {
       // Try inserting a row, and check the resulting value of the new column.
       $id = db_insert($table_name)
         ->useDefaults(array('serial_column'))
@@ -377,7 +394,13 @@ class SchemaTestCase extends DrupalWebTe
         ->condition('serial_column', $id)
         ->execute()
         ->fetchField();
-      $this->assertEqual($field_value, $field_spec['default'], t('Default value registered.'));
+      
+      if (!empty($field_spec['default'])) {
+        $this->assertEqual($field_value, $field_spec['default'], t('Default value registered.'));
+      }
+      else {
+        $this->assertIdentical($field_value, $field_spec['default'], t('Default value registered.'));
+      }
     }
 
     db_drop_field($table_name, $field_name);

