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 13:14:43 -0000
@@ -2630,6 +2630,38 @@ function ip_address() {
  */
 
 /**
+ * Get the schema definition of a table.
+ *
+ * The returned schema will include any modifications made by any
+ * module that implements hook_schema_alter().
+ *
+ * @param $table
+ *   The name of the table.
+ * @param $rebuild
+ *   If true, the schema will be rebuilt instead of retrieved from the cache.
+ */
+function drupal_get_table_schema($table, $rebuild = FALSE) {
+  static $schema = array();
+
+  if (!$rebuild && isset($schema[$table])) {
+    return $schema[$table];
+  }
+  else if (!$rebuild && $cached = cache_get("schema:$table")) {
+    $schema[$table] = $cached->data;
+  }
+  else {
+    $full_schema = drupal_get_schema(NULL, $rebuild);
+    if (isset($full_schema[$table])) {
+      $schema[$table] = $full_schema[$table];
+      if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) {
+        cache_set("schema:$table", $full_schema[$table]);
+      }
+    }
+  }
+  return isset($schema[$table]) ? $schema[$table] : FALSE;
+}
+
+/**
  * Get the schema definition of a table, or the whole database schema.
  *
  * The returned schema will include any modifications made by any
@@ -2641,14 +2673,13 @@ function ip_address() {
  *   If true, the schema will be rebuilt instead of retrieved from the cache.
  */
 function drupal_get_schema($table = NULL, $rebuild = FALSE) {
-  static $schema = array();
-
-  if (empty($schema) || $rebuild) {
-    // Try to load the schema from cache.
+  if (isset($table)) {
+    return drupal_get_table_schema($table, $rebuild);
+  }
+  else {
     if (!$rebuild && $cached = cache_get('schema')) {
       $schema = $cached->data;
     }
-    // Otherwise, rebuild the schema cache.
     else {
       $schema = array();
       // Load the .install files to get hook_schema.
@@ -2680,20 +2711,13 @@ function drupal_get_schema($table = NULL
       // 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)) {
+        // To avoid race conditions, clear the cache prior to setting it.
+        cache_clear_all('schema', 'cache', TRUE);
         cache_set('schema', $schema);
       }
     }
-  }
-
-  if (!isset($table)) {
     return $schema;
   }
-  elseif (isset($schema[$table])) {
-    return $schema[$table];
-  }
-  else {
-    return FALSE;
-  }
 }
 
 /**
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 13:14:44 -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;
     }
