? 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.4
diff -u -p -r1.4 schema.inc
--- includes/database/schema.inc	31 Oct 2008 15:46:16 -0000	1.4
+++ includes/database/schema.inc	1 Dec 2008 04:19:05 -0000
@@ -423,6 +423,24 @@ abstract class DatabaseSchema {
     ));
     return $result->fetchAllKeyed(0, 0);
   }
+
+  /**
+   * Prepare a table or column comment for database query.
+   * 
+   * @param $comment
+   *   The comment string to prepare.
+   * @param $length
+   *   An upper limit on the returned string length.
+   * @return
+   *   The prepared comment.
+   */
+  public function prepareComment($comment, $length = NULL) {
+    $comment = decode_entities(strip_tags($comment));
+    if (isset($length)) {
+      $comment = truncate_utf8($comment, $length, TRUE, TRUE);
+    }
+    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.6
diff -u -p -r1.6 schema.inc
--- includes/database/mysql/schema.inc	13 Nov 2008 20:52:13 -0000	1.6
+++ includes/database/mysql/schema.inc	1 Dec 2008 04:19:05 -0000
@@ -14,6 +14,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;
+
   public function tableExists($table) {
     return (bool) $this->connection->query("SHOW TABLES LIKE '{" . $table . "}'", array(), array())->fetchField();
   }
@@ -56,6 +66,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);
   }
 
@@ -107,6 +122,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;
   }
 
Index: includes/database/pgsql/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/pgsql/schema.inc,v
retrieving revision 1.3
diff -u -p -r1.3 schema.inc
--- includes/database/pgsql/schema.inc	26 Nov 2008 13:42:25 -0000	1.3
+++ includes/database/pgsql/schema.inc	1 Dec 2008 04:19:05 -0000
@@ -62,6 +62,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;
   }
 
@@ -261,6 +273,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']));
+    }
   }
 
   /**
