Index: includes/database/mysql/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/mysql/schema.inc,v
retrieving revision 1.32
diff -u -r1.32 schema.inc
--- includes/database/mysql/schema.inc	7 Mar 2010 08:03:44 -0000	1.32
+++ includes/database/mysql/schema.inc	7 Mar 2010 22:39:06 -0000
@@ -161,7 +161,7 @@
 
     // Set the correct database-engine specific datatype.
     if (!isset($field['mysql_type'])) {
-      $map = db_type_map();
+      $map = $this->getFieldTypeMap();
       $field['mysql_type'] = $map[$field['type'] . ':' . $field['size']];
     }
 
Index: includes/database/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/schema.inc,v
retrieving revision 1.30
diff -u -r1.30 schema.inc
--- includes/database/schema.inc	7 Mar 2010 08:03:44 -0000	1.30
+++ includes/database/schema.inc	7 Mar 2010 22:39:06 -0000
@@ -54,7 +54,7 @@
  *       INT, VARCHAR, BLOB, etc.).
  *
  *       Not all sizes are available for all data types. See
- *       db_type_map() for possible combinations.
+ *       DatabaseSchema::getFieldTypeMap() for possible combinations.
  *     - 'not null': If true, no NULL values will be allowed in this
  *       database column. Defaults to false.
  *     - 'default': The field's default value. The PHP type of the
@@ -266,9 +266,15 @@
   }
 
   /**
-   * This maps a generic data type in combination with its data size
-   * to the engine-specific data type.
-   */
+  * Returns a mapping of Drupal schema field names to DB-native field types.
+  *
+  * Because different field types do not map 1:1 between databases, Drupal has
+  * its own normalized field type names. This function returns a driver-specific
+  * mapping table from Drupal names to the native names for each database.
+  *
+  * @return array
+  *   An array of Schema API field types to driver-specific field types.
+  */
   abstract public function getFieldTypeMap();
 
   /**
Index: includes/database/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/database.inc,v
retrieving revision 1.101
diff -u -r1.101 database.inc
--- includes/database/database.inc	7 Mar 2010 08:08:37 -0000	1.101
+++ includes/database/database.inc	7 Mar 2010 22:39:06 -0000
@@ -31,15 +31,15 @@
  * For example, one might wish to return a list of the most recent 10 nodes
  * authored by a given user. Instead of directly issuing the SQL query
  * @code
- *   SELECT n.nid, n.title, n.created FROM node n WHERE n.uid = $uid LIMIT 0, 10;
+ * SELECT n.nid, n.title, n.created FROM node n WHERE n.uid = $uid LIMIT 0, 10;
  * @endcode
  * one would instead call the Drupal functions:
  * @code
- *   $result = db_query_range('SELECT n.nid, n.title, n.created
- *     FROM {node} n WHERE n.uid = :uid', array(':uid' => $uid), 0, 10);
- *   foreach($result as $record) {
- *     // Perform operations on $node->title, etc. here.
- *   }
+ * $result = db_query_range('SELECT n.nid, n.title, n.created
+ *   FROM {node} n WHERE n.uid = :uid', array(':uid' => $uid), 0, 10);
+ * foreach($result as $record) {
+ *   // Perform operations on $node->title, etc. here.
+ * }
  * @endcode
  * Curly braces are used around "node" to provide table prefixing via
  * DatabaseConnection::prefixTables(). The explicit use of a user ID is pulled
@@ -63,7 +63,7 @@
  *
  * Named placeholders begin with a colon followed by a unique string. Example:
  * @code
- * SELECT nid, title FROM {node} WHERE uid=:uid
+ * SELECT nid, title FROM {node} WHERE uid=:uid;
  * @endcode
  *
  * ":uid" is a placeholder that will be replaced with a literal value when
@@ -75,7 +75,7 @@
  *
  * Unnamed placeholders are simply a question mark. Example:
  * @code
- * SELECT nid, title FROM {node} WHERE uid=?
+ * SELECT nid, title FROM {node} WHERE uid=?;
  * @endcode
  *
  * In this case, the array of arguments must be an indexed array of values to
@@ -84,17 +84,13 @@
  * Note that placeholders should be a "complete" value. For example, when
  * running a LIKE query the SQL wildcard character, %, should be part of the
  * value, not the query itself. Thus, the following is incorrect:
- *
  * @code
- * SELECT nid, title FROM {node} WHERE title LIKE :title%
+ * SELECT nid, title FROM {node} WHERE title LIKE :title%;
  * @endcode
- *
  * It should instead read:
- *
  * @code
- * SELECT nid, title FROM {node} WHERE title LIKE :title
+ * SELECT nid, title FROM {node} WHERE title LIKE :title;
  * @endcode
- *
  * and the value for :title should include a % as appropriate. Again, note the
  * lack of quotation marks around :title. Because the value is not inserted
  * into the query as one big string but as an explicitly separate value, the
@@ -105,9 +101,10 @@
  *
  * INSERT, UPDATE, and DELETE queries need special care in order to behave
  * consistently across all different databases. Therefore, they use a special
- * object-oriented API for defining a query structurally. For example, rather than
+ * object-oriented API for defining a query structurally. For example, rather
+ * than:
  * @code
- * INSERT INTO node (nid, title, body) VALUES (1, 'my title', 'my body')
+ * INSERT INTO node (nid, title, body) VALUES (1, 'my title', 'my body');
  * @endcode
  * one would instead write:
  * @code
@@ -181,7 +178,7 @@
  * concrete implementation of it to support special handling required by that
  * database.
  *
- * @link http://php.net/manual/en/book.pdo.php
+ * @see http://php.net/manual/en/book.pdo.php
  */
 abstract class DatabaseConnection extends PDO {
 
@@ -423,6 +420,7 @@
    *
    * @param $sql
    *   A string containing a partial or entire SQL query.
+   *
    * @return
    *   The properly-prefixed string.
    */
@@ -459,6 +457,7 @@
    * @param $query
    *   The query string as SQL, with curly-braces surrounding the
    *   table names.
+   *
    * @return DatabaseStatementInterface
    *   A PDO prepared statement ready for its execute() method.
    */
@@ -528,6 +527,7 @@
    *   The table name to use for the sequence.
    * @param $field
    *   The field name to use for the sequence.
+   *
    * @return
    *   A table prefix-parsed string for the sequence name.
    */
@@ -559,6 +559,7 @@
    * @param $options
    *   An associative array of options to control how the query is run. See
    *   the documentation for DatabaseConnection::defaultOptions() for details.
+   *
    * @return DatabaseStatementInterface
    *   This method will return one of: the executed statement, the number of
    *   rows affected by the query (not the number matched), or the generated
@@ -630,6 +631,7 @@
    *   The query string to modify.
    * @param $args
    *   The arguments for the query.
+   *
    * @return
    *   TRUE if the query was modified, FALSE otherwise.
    */
@@ -674,7 +676,6 @@
   /**
    * Prepare and return a SELECT query object with the specified ID.
    *
-   * @see SelectQuery
    * @param $table
    *   The base table for this query, that is, the first table in the FROM
    *   clause. This table will also be used as the "base" table for query_alter
@@ -683,8 +684,13 @@
    *   The alias of the base table of this query.
    * @param $options
    *   An array of options on the query.
+   *
    * @return SelectQueryInterface
-   *   A new SelectQuery object.
+   *   An appropriate SelectQuery object for this database connection. Note that
+   *   it may be a driver-specific subclass of SelectQuery, depending on the
+   *   driver.
+   *
+   * @see SelectQuery
    */
   public function select($table, $alias = NULL, array $options = array()) {
     if (empty($this->selectClass)) {
@@ -704,11 +710,13 @@
   /**
    * Prepare and return an INSERT query object with the specified ID.
    *
-   * @see InsertQuery
    * @param $options
    *   An array of options on the query.
+   *
    * @return InsertQuery
    *   A new InsertQuery object.
+   *
+   * @see InsertQuery
    */
   public function insert($table, array $options = array()) {
     if (empty($this->insertClass)) {
@@ -724,11 +732,13 @@
   /**
    * Prepare and return a MERGE query object with the specified ID.
    *
-   * @see MergeQuery
    * @param $options
    *   An array of options on the query.
+   *
    * @return MergeQuery
    *   A new MergeQuery object.
+   *
+   * @see MergeQuery
    */
   public function merge($table, array $options = array()) {
     if (empty($this->mergeClass)) {
@@ -745,11 +755,13 @@
   /**
    * Prepare and return an UPDATE query object with the specified ID.
    *
-   * @see UpdateQuery
    * @param $options
    *   An array of options on the query.
+   *
    * @return UpdateQuery
    *   A new UpdateQuery object.
+   *
+   * @see UpdateQuery
    */
   public function update($table, array $options = array()) {
     if (empty($this->updateClass)) {
@@ -765,11 +777,13 @@
   /**
    * Prepare and return a DELETE query object with the specified ID.
    *
-   * @see DeleteQuery
    * @param $options
    *   An array of options on the query.
+   *
    * @return DeleteQuery
    *   A new DeleteQuery object.
+   *
+   * @see DeleteQuery
    */
   public function delete($table, array $options = array()) {
     if (empty($this->deleteClass)) {
@@ -785,11 +799,13 @@
   /**
    * Prepare and return a TRUNCATE query object.
    *
-   * @see TruncateQuery
    * @param $options
    *   An array of options on the query.
+   *
    * @return TruncateQuery
-   *   A new DeleteQuery object.
+   *   A new TruncateQuery object.
+   *
+   * @see TruncateQuery
    */
   public function truncate($table, array $options = array()) {
     if (empty($this->truncateClass)) {
@@ -854,6 +870,7 @@
    *
    * @param $string
    *   The string to escape.
+   *
    * @return
    *   The escaped string.
    */
@@ -1053,6 +1070,7 @@
    *   The maximum number of result rows to return.
    * @param $options
    *   An array of options on the query.
+   *
    * @return DatabaseStatementInterface
    *   A database query result resource, or NULL if the query was not executed
    *   correctly.
@@ -1088,6 +1106,7 @@
    * @param $options
    *   An associative array of options to control how the query is run. See
    *   the documentation for DatabaseConnection::defaultOptions() for details.
+   *
    * @return
    *   The name of the temporary table.
    */
@@ -1140,11 +1159,13 @@
    * overridable lookup function. Database connections should define only
    * those operators they wish to be handled differently than the default.
    *
-   * @see DatabaseCondition::compile()
    * @param $operator
    *   The condition operator, such as "IN", "BETWEEN", etc. Case-sensitive.
+   *
    * @return
    *   The extra handling directives for the specified operator, or NULL.
+   *
+   * @see DatabaseCondition::compile()
    */
   abstract public function mapConditionOperator($operator);
 
@@ -1174,6 +1195,7 @@
    *   After a database import, it might be that the sequences table is behind,
    *   so by passing in the maximum existing id, it can be assured that we
    *   never issue the same id.
+   *
    * @return
    *   An integer number larger than any number returned by earlier calls and
    *   also larger than the $existing_id if one was passed in.
@@ -1187,7 +1209,6 @@
  * This class is uninstantiatable and un-extendable. It acts to encapsulate
  * all control and shepherding of database connections into a single location
  * without the use of globals.
- *
  */
 abstract class Database {
 
@@ -1271,15 +1292,17 @@
   /**
    * Start logging a given logging key on the specified connection.
    *
-   * @see DatabaseLog
    * @param $logging_key
    *   The logging key to log.
    * @param $key
    *   The database connection key for which we want to log.
+   *
    * @return DatabaseLog
    *   The query log object. Note that the log object does support richer
    *   methods than the few exposed through the Database class, so in some
    *   cases it may be desirable to access it directly.
+   *
+   * @see DatabaseLog
    */
   final public static function startLog($logging_key, $key = 'default') {
     if (empty(self::$logs[$key])) {
@@ -1301,13 +1324,14 @@
   /**
    * Set a logging callback for notices and errors.
    *
-   * @see watchdog()
    * @param $logging_callback
    *   The function to use as the logging callback.
    * @param $logging_default_severity
    *   The default severity level to use for logged messages.
    * @param $logging_error_severity
    *   The severity level to use for logging error messages.
+   *
+   * @see watchdog()
    */
   final public static function setLoggingCallback($callback, $default_severity, $error_severity) {
     self::$logging_callback = array(
@@ -1337,13 +1361,15 @@
    * it again (which does nothing to an open log key) and call methods on it as
    * desired.
    *
-   * @see DatabaseLog
    * @param $logging_key
    *   The logging key to log.
    * @param $key
    *   The database connection key for which we want to log.
+   *
    * @return array
    *   The query log for the specified logging key and connection.
+   *
+   * @see DatabaseLog
    */
   final public static function getLog($logging_key, $key = 'default') {
     if (empty(self::$logs[$key])) {
@@ -1361,6 +1387,7 @@
    *   The database target name.
    * @param $key
    *   The database connection key. Defaults to NULL which means the active key.
+   *
    * @return DatabaseConnection
    *   The corresponding connection object.
    */
@@ -1596,7 +1623,7 @@
 }
 
 /**
- * Exception to throw when popTransaction() is called when no transaction is active.
+ * Exception for when popTransaction() is called with no active transaction.
  */
 class NoActiveTransactionException extends Exception { }
 
@@ -1644,8 +1671,9 @@
  * commands, allowing user-space code to proceed normally. The only difference
  * is that rollbacks won't actually do anything.
  *
- * In the vast majority of cases, you should not instantiate this class directly.
- * Instead, call ->startTransaction(), from the appropriate connection object.
+ * In the vast majority of cases, you should not instantiate this class
+ * directly. Instead, call ->startTransaction(), from the appropriate connection
+ * object.
  */
 class DatabaseTransaction {
 
@@ -1740,6 +1768,7 @@
    *   the SQL statement being executed.
    * @param $options
    *   An array of options for this query.
+   *
    * @return
    *   TRUE on success, or FALSE on failure.
    */
@@ -1794,6 +1823,7 @@
    *   Not implemented in all database drivers, don't use.
    * @param $cursor_offset
    *   Not implemented in all database drivers, don't use.
+   *
    * @return
    *   A result, formatted according to $mode.
    */
@@ -1804,6 +1834,7 @@
    *
    * @param $index
    *   The numeric index of the field to return. Defaults to the first field.
+   *
    * @return
    *   A single field from the next record.
    */
@@ -1838,6 +1869,7 @@
    *   If $mode is PDO::FETCH_COLUMN, the index of the column to fetch.
    * @param $constructor_arguments
    *   If $mode is PDO::FETCH_CLASS, the arguments to pass to the constructor.
+   *
    * @return
    *   An array of results.
    */
@@ -1850,6 +1882,7 @@
    *
    * @param $index
    *   The index of the column number to fetch.
+   *
    * @return
    *   An indexed array.
    */
@@ -1869,6 +1902,7 @@
    *   The numeric index of the field to use as the array key.
    * @param $value_index
    *   The numeric index of the field to use as the array value.
+   *
    * @return
    *   An associative array.
    */
@@ -1889,6 +1923,7 @@
    *   The fetchmode to use. If set to PDO::FETCH_ASSOC, PDO::FETCH_NUM, or
    *   PDO::FETCH_BOTH the returned value with be an array of arrays. For any
    *   other value it will be an array of objects.
+   *
    * @return
    *   An associative array.
    */
@@ -1904,7 +1939,7 @@
  * driver needs to set a custom statement class, it may do so in its
  * constructor.
  *
- * @link http://us.php.net/pdostatement
+ * @see http://us.php.net/pdostatement
  */
 class DatabaseStatementBase extends PDOStatement implements DatabaseStatementInterface {
 
@@ -2081,17 +2116,17 @@
 
 /**
  * The following utility functions are simply convenience wrappers.
+ *
  * They should never, ever have any database-specific code in them.
  */
 
 /**
- * Execute an arbitrary query string against the active database.
+ * Executes an arbitrary query string against the active database.
  *
  * Do not use this function for INSERT, UPDATE, or DELETE queries. Those should
  * be handled via the appropriate query builder factory. Use this function for
  * SELECT queries that do not require a query builder.
  *
- * @see DatabaseConnection::defaultOptions()
  * @param $query
  *   The prepared statement query to run. Although it will accept both named and
  *   unnamed placeholders, named placeholders are strongly preferred as they are
@@ -2103,8 +2138,11 @@
  *   the order of placeholders in the query string.
  * @param $options
  *   An array of options to control how the query operates.
+ *
  * @return DatabaseStatementInterface
  *   A prepared statement object, already executed.
+ *
+ * @see DatabaseConnection::defaultOptions()
  */
 function db_query($query, array $args = array(), array $options = array()) {
   if (empty($options['target'])) {
@@ -2115,10 +2153,8 @@
 }
 
 /**
- * Execute an arbitrary query string against the active database, restricted to
- * a specified range.
+ * Executes a query against the active database, restricted to a range.
  *
- * @see DatabaseConnection::defaultOptions()
  * @param $query
  *   The prepared statement query to run. Although it will accept both named and
  *   unnamed placeholders, named placeholders are strongly preferred as they are
@@ -2134,8 +2170,11 @@
  *   the order of placeholders in the query string.
  * @param $options
  *   An array of options to control how the query operates.
+ *
  * @return DatabaseStatementInterface
  *   A prepared statement object, already executed.
+ *
+ * @see DatabaseConnection::defaultOptions()
  */
 function db_query_range($query, $from, $count, array $args = array(), array $options = array()) {
   if (empty($options['target'])) {
@@ -2146,10 +2185,10 @@
 }
 
 /**
- * Execute a query string against the active database and save the result set
- * to a temp table.
+ * Executes a query string and save the result set to a temp table.
+ *
+ * The execution of the query string happens against the active database.
  *
- * @see DatabaseConnection::defaultOptions()
  * @param $query
  *   The prepared statement query to run. Although it will accept both named and
  *   unnamed placeholders, named placeholders are strongly preferred as they are
@@ -2161,8 +2200,11 @@
  *   the order of placeholders in the query string.
  * @param $options
  *   An array of options to control how the query operates.
+ *
  * @return
  *   The name of the temporary table.
+ *
+ * @see DatabaseConnection::defaultOptions()
  */
 function db_query_temporary($query, array $args = array(), array $options = array()) {
   if (empty($options['target'])) {
@@ -2179,6 +2221,7 @@
  *   The table into which to insert.
  * @param $options
  *   An array of options to control how the query operates.
+ *
  * @return InsertQuery
  *   A new InsertQuery object for this connection.
  */
@@ -2196,6 +2239,7 @@
  *   The table into which to merge.
  * @param $options
  *   An array of options to control how the query operates.
+ *
  * @return MergeQuery
  *   A new MergeQuery object for this connection.
  */
@@ -2213,6 +2257,7 @@
  *   The table to update.
  * @param $options
  *   An array of options to control how the query operates.
+ *
  * @return UpdateQuery
  *   A new UpdateQuery object for this connection.
  */
@@ -2230,6 +2275,7 @@
  *   The table from which to delete.
  * @param $options
  *   An array of options to control how the query operates.
+ *
  * @return DeleteQuery
  *   A new DeleteQuery object for this connection.
  */
@@ -2247,6 +2293,7 @@
  *   The table from which to delete.
  * @param $options
  *   An array of options to control how the query operates.
+ *
  * @return TruncateQuery
  *   A new TruncateQuery object for this connection.
  */
@@ -2267,6 +2314,7 @@
  *   The alias for the base table of this query.
  * @param $options
  *   An array of options to control how the query operates.
+ *
  * @return SelectQuery
  *   A new SelectQuery object for this connection.
  */
@@ -2287,6 +2335,7 @@
  * @param $options
  *   An array of options to control how the transaction operates.  Only the
  *   target key has any meaning in this case.
+ *
  * @return DatabaseTransaction
  *   A new DatabaseTransaction object for this connection.
  */
@@ -2302,6 +2351,7 @@
  *
  * @param $key
  *   The key in the $databases array to set as the default database.
+ *
  * @return
  *   The key of the formerly active database.
  */
@@ -2330,6 +2380,7 @@
  *
  * @param $table
  *   The table name to escape.
+ *
  * @return
  *   The escaped table name as a string.
  */
@@ -2358,6 +2409,7 @@
  *
  * @param $string
  *   The string to escape.
+ *
  * @return
  *   The escaped string.
  */
@@ -2366,10 +2418,10 @@
 }
 
 /**
- * Retrieve the name of the currently active database driver, such as "mysql" or
- * "pgsql".
+ * Retrieves the name of the currently active database driver.
  *
- * @return The name of the currently active database driver.
+ * @return
+ *   The name of the currently active database driver.
  */
 function db_driver() {
   return Database::getConnection()->driver();
@@ -2399,6 +2451,7 @@
  *   After a database import, it might be that the sequences table is behind, so
  *   by passing in a minimum ID, it can be assured that we never issue the same
  *   ID.
+ *
  * @return
  *   An integer number larger than any number returned before for this sequence.
  */
@@ -2439,6 +2492,7 @@
  *
  * @param $fields
  *   An array of key/index column specifiers.
+ *
  * @return
  *   An array of field names.
  */
@@ -2453,6 +2507,7 @@
  *   The name of the table in drupal (no prefixing).
  * @param $name
  *   The name of the index in drupal (no prefixing).
+ *
  * @return
  *   TRUE if the given index exists, otherwise FALSE.
  */
@@ -2465,6 +2520,7 @@
  *
  * @param $table
  *   The name of the table in drupal (no prefixing).
+ *
  * @return
  *   TRUE if the given table exists, otherwise FALSE.
  */
@@ -2479,6 +2535,7 @@
  *   The name of the table in drupal (no prefixing).
  * @param $name
  *   The name of the column.
+ *
  * @return
  *   TRUE if the given column exists, otherwise FALSE.
  */
@@ -2492,6 +2549,7 @@
  * @param $table_expression
  *   An SQL expression, for example "simpletest%" (without the quotes).
  *   BEWARE: this is not prefixed, the caller should take care of that.
+ *
  * @return
  *   Array, both the keys and the values are the matching tables.
  */
@@ -2504,14 +2562,6 @@
 }
 
 /**
- * This maps a generic data type in combination with its data size
- * to the engine-specific data type.
- */
-function db_type_map() {
-  return Database::getConnection()->schema()->getFieldTypeMap();
-}
-
-/**
  * Rename a table.
  *
  * @param $table
@@ -2551,6 +2601,7 @@
  *   without the 'fields' element. If you are adding a type 'serial' field, you
  *   MUST specify at least one key or index including it in this array. See
  *   db_change_field() for more explanation why.
+ *
  * @see db_change_field()
  */
 function db_add_field($table, $field, $spec, $keys_new = array()) {
@@ -2737,19 +2788,6 @@
  * @} End of "ingroup schemaapi".
  */
 
-/**
- * Prints a themed maintenance page with the 'Site offline' text, adding the
- * provided error message in the case of 'display_errors' set to on. Ends the
- * page request; no return.
- */
-function _db_error_page($error = '') {
-  global $db_type;
-  drupal_language_initialize();
-  drupal_maintenance_theme();
-  drupal_add_http_header('Status', '503 Service Unavailable');
-  drupal_set_title('Site offline');
-}
-
  /**
  * Helper function to get duration lag from variable and set the session
  * variable that contains the lag.
