? sites/default/files
? sites/default/settings.php
Index: includes/database/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/schema.inc,v
retrieving revision 1.11
diff -u -p -r1.11 schema.inc
--- includes/database/schema.inc	24 Feb 2009 16:34:46 -0000	1.11
+++ includes/database/schema.inc	5 Mar 2009 22:14:13 -0000
@@ -493,6 +493,22 @@ abstract class DatabaseSchema {
     }
     return $ret;
   }
+
+  /**
+   * Prepare a table or column comment for database query.
+   * 
+   * @param $comment
+   *   The comment string to prepare.
+   * @param $length
+   *   Optional upper limit on the returned string length.
+   * @return
+   *   The prepared comment.
+   */
+  public function prepareComment($comment, $length = NULL) {
+    // Decode HTML-encoded comments.
+    $comment = decode_entities(strip_tags($comment));
+    return $this->connection->quote($comment);
+  }
 }
 
 /**
Index: includes/database/mysql/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/mysql/schema.inc,v
retrieving revision 1.11
diff -u -p -r1.11 schema.inc
--- includes/database/mysql/schema.inc	26 Jan 2009 14:08:41 -0000	1.11
+++ includes/database/mysql/schema.inc	5 Mar 2009 22:14:14 -0000
@@ -15,6 +15,16 @@
 class DatabaseSchema_mysql extends DatabaseSchema {
 
   /**
+   * Maximum length of a table comment in MySQL.
+   */
+  const COMMENT_MAX_TABLE = 60;
+
+  /**
+   * Maximum length of a column comment in MySQL.
+   */
+  const COMMENT_MAX_COLUMN = 255;
+
+  /**
    * Build a condition to match a table name against a standard information_schema.
    *
    * MySQL uses databases like schemas rather than catalogs so when we build
@@ -50,7 +60,7 @@ class DatabaseSchema_mysql extends Datab
    */
   protected function createTableSql($name, $table) {
     if (empty($table['mysql_suffix'])) {
-      $table['mysql_suffix'] = "/*!40100 DEFAULT CHARACTER SET UTF8 */";
+      $table['mysql_suffix'] = 'DEFAULT CHARACTER SET UTF8';
     }
 
     $sql = "CREATE TABLE {" . $name . "} (\n";
@@ -71,6 +81,11 @@ class DatabaseSchema_mysql extends Datab
 
     $sql .= $table['mysql_suffix'];
 
+    // Add table comment.
+    if (!empty($table['description'])) {
+      $sql .= ' COMMENT ' . $this->prepareComment($table['description'], self::COMMENT_MAX_TABLE);
+    }
+
     return array($sql);
   }
 
@@ -122,6 +137,11 @@ class DatabaseSchema_mysql extends Datab
       $sql .= ' DEFAULT NULL';
     }
 
+    // Add column comment.
+    if (!empty($spec['description'])) {
+      $sql .= ' COMMENT ' . $this->prepareComment($spec['description'], self::COMMENT_MAX_COLUMN);
+    }
+
     return $sql;
   }
 
@@ -325,6 +345,22 @@ class DatabaseSchema_mysql extends Datab
     $ret[] = update_sql($sql);
   }
 
+  public function prepareComment($comment, $length = NULL) {
+    // Decode HTML-encoded comments.
+    $comment = decode_entities(strip_tags($comment));
+
+    // Work around a bug in some versions of PDO, see http://bugs.php.net/bug.php?id=41125
+    $comment = str_replace("'", '’', $comment);
+ 
+    // Truncate comment to maximum comment length.
+    if (isset($length)) {
+      // Add table prefixes before truncating.
+      $comment = truncate_utf8($this->connection->prefixTables($comment), $length, TRUE, TRUE);
+    }
+
+    return $this->connection->quote($comment);
+  }
+
 }
 
 /**
Index: includes/database/pgsql/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/pgsql/schema.inc,v
retrieving revision 1.8
diff -u -p -r1.8 schema.inc
--- includes/database/pgsql/schema.inc	24 Feb 2009 16:34:46 -0000	1.8
+++ includes/database/pgsql/schema.inc	5 Mar 2009 22:14:16 -0000
@@ -109,6 +109,18 @@ class DatabaseSchema_pgsql extends Datab
       }
     }
 
+    // Add table comment.
+    if (!empty($table['description'])) {
+      $statements[] = 'COMMENT ON TABLE {' . $name . '} IS ' . $this->prepareComment($table['description']);
+    }
+
+    // Add column comments.
+    foreach ($table['fields'] as $field_name => $field) {
+      if (!empty($field['description'])) {
+        $statements[] = 'COMMENT ON COLUMN {' . $name . '}.' . $field_name . ' IS ' . $this->prepareComment($field['description']);
+      }
+    }
+
     return $statements;
   }
 
@@ -322,6 +334,10 @@ class DatabaseSchema_pgsql extends Datab
     if (isset($new_keys)) {
       $this->_createKeys($ret, $table, $new_keys);
     }
+    // Add column comment.
+    if (!empty($spec['description'])) {
+      $ret[] = update_sql('COMMENT ON COLUMN {' . $table . '}.' . $field . ' IS ' . $this->prepareComment($spec['description']));
+    }
   }
 
   /**
