Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.460
diff -u -p -r1.460 bootstrap.inc
--- includes/bootstrap.inc	30 Dec 2010 04:36:53 -0000	1.460
+++ includes/bootstrap.inc	30 Dec 2010 09:30:05 -0000
@@ -2636,52 +2636,73 @@ function ip_address() {
  * module that implements hook_schema_alter().
  *
  * @param $table
- *   The name of the table. If not given, the schema of all tables is returned.
+ *   The name of the table. When this optional parameter is ommitted the full
+ *   database schema is returned.
  * @param $rebuild
- *   If true, the schema will be rebuilt instead of retrieved from the cache.
+ *   If true, the schema will be rebuilt and the cache refreshed.
  */
 function drupal_get_schema($table = NULL, $rebuild = FALSE) {
   static $schema = array();
 
-  if (empty($schema) || $rebuild) {
-    // Try to load the schema from cache.
-    if (!$rebuild && $cached = cache_get('schema')) {
+  // If a table is specified, try to load the individual cache entry for that
+  // table.
+  if (isset($table) && !$rebuild) {
+    if (isset($schema[$table])) {
+      return $schema[$table];
+    }
+    else if ($cached = cache_get('schema:' . $table)) {
+      $schema[$table] = $cached->data;
+    }
+    else {
+      // Rebuild the full schema cache in the case of a cache miss.
+      $rebuild = TRUE;
+    }
+  }
+
+  if (!isset($table) && !$rebuild) {
+    if ($cached = cache_get('schema')) {
       $schema = $cached->data;
+      return $schema;
     }
-    // Otherwise, rebuild the schema cache.
     else {
-      $schema = array();
-      // Load the .install files to get hook_schema.
-      // On some databases this function may be called before bootstrap has
-      // been completed, so we force the functions we need to load just in case.
-      if (function_exists('module_load_all_includes')) {
-        // This function can be called very early in the bootstrap process, so
-        // we force the module_list() cache to be refreshed to ensure that it
-        // contains the complete list of modules before we go on to call
-        // module_load_all_includes().
-        module_list(TRUE);
-        module_load_all_includes('install');
-      }
+      $rebuild = TRUE;
+    }
+  }
+  if ($rebuild) {
+    $schema = array();
+    // Load the .install files to get hook_schema.
+    // On some databases this function may be called before bootstrap has
+    // been completed, so we force the functions we need to load just in case.
+    if (function_exists('module_load_all_includes')) {
+      // This function can be called very early in the bootstrap process, so
+      // we force the module_list() cache to be refreshed to ensure that it
+      // contains the complete list of modules before we go on to call
+      // module_load_all_includes().
+      module_list(TRUE);
+      module_load_all_includes('install');
+    }
 
-      require_once DRUPAL_ROOT . '/includes/common.inc';
-      // Invoke hook_schema for all modules.
-      foreach (module_implements('schema') as $module) {
-        // Cast the result of hook_schema() to an array, as a NULL return value
-        // would cause array_merge() to set the $schema variable to NULL as well.
-        // That would break modules which use $schema further down the line.
-        $current = (array) module_invoke($module, 'schema');
-        // Set 'module' and 'name' keys for each table, and remove descriptions,
-        // as they needlessly slow down cache_get() for every single request.
-        _drupal_schema_initialize($current, $module);
-        $schema = array_merge($schema, $current);
-      }
+    require_once DRUPAL_ROOT . '/includes/common.inc';
+    // Invoke hook_schema for all modules.
+    foreach (module_implements('schema') as $module) {
+      // Cast the result of hook_schema() to an array, as a NULL return value
+      // would cause array_merge() to set the $schema variable to NULL as well.
+      // That would break modules which use $schema further down the line.
+      $current = (array) module_invoke($module, 'schema');
+      // Set 'module' and 'name' keys for each table, and remove descriptions,
+      // as they needlessly slow down cache_get() for every single request.
+      _drupal_schema_initialize($current, $module);
+      $schema = array_merge($schema, $current);
+    }
 
-      drupal_alter('schema', $schema);
-      // If the schema is empty, avoid saving it: some database engines require
-      // the schema to perform queries, and this could lead to infinite loops.
-      if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) {
-        cache_set('schema', $schema);
+    drupal_alter('schema', $schema);
+    // If the schema is empty, avoid saving it: some database engines require
+    // the schema to perform queries, and this could lead to infinite loops.
+    if ($rebuild && !empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) {
+      foreach ($schema as $key => $definition) {
+        cache_set('schema:' . $key, $definition);
       }
+      cache_set($schema);
     }
   }
 
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.429
diff -u -p -r1.429 menu.inc
--- includes/menu.inc	17 Dec 2010 01:08:15 -0000	1.429
+++ includes/menu.inc	30 Dec 2010 09:30:06 -0000
@@ -2376,14 +2376,16 @@ function menu_link_get_preferred($path =
     $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
     $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
     $query->fields('ml');
-    // Weight must be taken from {menu_links}, not {menu_router}.
-    $query->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')));
+    $query->fields('m');
     $query->condition('ml.menu_name', $menu_names, 'IN');
     $query->condition('ml.link_path', $path_candidates, 'IN');
+    // Weight must be taken from {menu_links}, not {menu_router}.
+    $query->addField('ml', 'weight', 'link_weight');
 
     // Sort candidates by link path and menu name.
     $candidates = array();
     foreach ($query->execute() as $candidate) {
+      $candidate['weight'] = $candidate['link_weight'];
       $candidates[$candidate['link_path']][$candidate['menu_name']] = $candidate;
     }
 
@@ -2502,10 +2504,12 @@ function menu_link_load($mlid) {
     $query = db_select('menu_links', 'ml');
     $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
     $query->fields('ml');
-    // Weight should be taken from {menu_links}, not {menu_router}.
-    $query->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')));
+    $query->fields('m');
     $query->condition('ml.mlid', $mlid);
+    // Weight should be taken from {menu_links}, not {menu_router}.
+    $query->addField('ml', 'weight', 'link_weight');
     if ($item = $query->execute()->fetchAssoc()) {
+      $item['weight'] = $item['link_weight'];
       _menu_link_translate($item);
       return $item;
     }
