Index: upgrade.php
===================================================================
--- upgrade.php	(revision 17423)
+++ upgrade.php	(working copy)
@@ -1404,7 +1404,8 @@
 	}
 
 	// Check to see which tables and fields exist
-	if ($tables = $wpdb->get_col('SHOW TABLES;')) {
+	if ($tables = $wpdb->get_col('SHOW TABLES WHERE (`Tables_in_' . $wpdb->dbname. '` like "' . $wpdb->prefix . '%") or ' .
+					'(`Tables_in_' . $wpdb->dbname. '` in ("' . implode('","',$wpdb->tables('global')) . '"));')) {
 		// For every table in the database
 		foreach ($tables as $table) {
 			// Upgrade global tables only for the main site. Don't upgrade at all if DO_NOT_UPGRADE_GLOBAL_TABLES is defined.
