Index: modules/taxonomy/taxonomy.install
===================================================================
RCS file: /Users/wright/drupal/local_repo/drupal/modules/taxonomy/taxonomy.install,v
retrieving revision 1.49
diff -u -p -r1.49 taxonomy.install
--- modules/taxonomy/taxonomy.install	1 Oct 2010 01:37:13 -0000	1.49
+++ modules/taxonomy/taxonomy.install	4 Oct 2010 06:12:20 -0000
@@ -567,7 +567,7 @@ function taxonomy_update_7005(&$sandbox)
     $sandbox['count'] = 0;
 
     $query = db_select('taxonomy_term_node', 't');
-    $sandbox['total'] = $query->countQuery()->execute()->fetchField();
+    $sandbox['total'] = db_query('SELECT COUNT(*) FROM {taxonomy_term_data} td INNER JOIN {taxonomy_term_node} tn ON td.tid = tn.tid INNER JOIN {node} n ON tn.nid = n.nid LEFT JOIN {node} n2 ON tn.vid = n2.vid')->fetchField();
 
     // Use an inline version of Drupal 6 taxonomy_get_vocabularies() here since
     // we can no longer rely on $vocabulary->nodes from the API function.
Index: modules/simpletest/tests/upgrade/drupal-6.filled.database.php
===================================================================
RCS file: /Users/wright/drupal/local_repo/drupal/modules/simpletest/tests/upgrade/drupal-6.filled.database.php,v
retrieving revision 1.3
diff -u -p -r1.3 drupal-6.filled.database.php
--- modules/simpletest/tests/upgrade/drupal-6.filled.database.php	11 Sep 2010 00:39:49 -0000	1.3
+++ modules/simpletest/tests/upgrade/drupal-6.filled.database.php	4 Oct 2010 06:11:19 -0000
@@ -13268,6 +13268,11 @@ db_insert('term_node')->fields(array(
 ->values(array(
   'nid' => '1',
   'vid' => '1',
+  'tid' => '0',
+))
+->values(array(
+  'nid' => '1',
+  'vid' => '1',
   'tid' => '1',
 ))
 ->values(array(
