Index: views_taxonomy.inc
===================================================================
--- views_taxonomy.inc	(revision 854)
+++ views_taxonomy.inc	(working copy)
@@ -31,7 +31,7 @@
 
     $tables[$table['name']] = $table;
 
-    $vocabularies = taxonomy_get_vocabularies();
+    $vocabularies = taxonomy_views_get_vocabularies();
     foreach ($vocabularies as $voc) {
       $tables["term_node_$voc->vid"] = array(
         'name' => 'term_node',
@@ -269,10 +269,10 @@
  */
 function views_handler_field_allterms($fieldinfo, $fielddata, $value, $data) {
   if ($fieldinfo['vocabulary']) {
-    $terms = taxonomy_node_get_terms_by_vocabulary($data->nid, $fieldinfo['vocabulary']);
+    $terms = taxonomy_views_node_get_terms_by_vocabulary($data->nid, $fieldinfo['vocabulary']);
   }
   else {
-    $terms = taxonomy_node_get_terms($data->nid);
+    $terms = taxonomy_views_node_get_terms($data->nid);
   }
 
   if ($fielddata['options'] == 'nolink') {
@@ -572,3 +572,57 @@
     }
   }
 }
+
+
+/**
+ * Views-compatible reworking of taxonomy_node_get_terms() 
+ *
+ * These functions from core taxonomy.module had to be re-implemented by Views to NOT use db_rewrite_sql, see http://drupal.org/node/272289
+ */
+function taxonomy_views_node_get_terms($nid, $key = 'tid') {
+  static $terms;
+
+  if (!isset($terms[$nid][$key])) {
+    $result = db_query('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.nid = %d ORDER BY v.weight, t.weight, t.name', $nid);
+    $terms[$nid][$key] = array();
+    while ($term = db_fetch_object($result)) {
+      $terms[$nid][$key][$term->$key] = $term;
+    }
+  }
+  return $terms[$nid][$key];
+}
+
+/**
+ * Views-compatible reworking of taxonomy_node_get_terms_by_vocabulary() 
+ *
+ * These functions from core taxonomy.module had to be re-implemented by Views to NOT use db_rewrite_sql, see http://drupal.org/node/272289
+ */
+function taxonomy_views_node_get_terms_by_vocabulary($nid, $vid, $key = 'tid') {
+  $result = db_query('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.nid = %d ORDER BY weight', $vid, $nid);
+  $terms = array();
+  while ($term = db_fetch_object($result)) {
+    $terms[$term->$key] = $term;
+  }
+  return $terms;
+}
+
+/**
+ * Views-compatible reworking of taxonomy_get_vocabularies().  
+ *
+ * These functions from core taxonomy.module had to be re-implemented by Views to NOT use db_rewrite_sql, see http://drupal.org/node/272289
+ * This version also removes the unneeded (by Views) $type parameter.
+ */
+function taxonomy_views_get_vocabularies() {
+  $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid ORDER BY v.weight, v.name');
+
+  $vocabularies = array();
+  $node_types = array();
+  while ($voc = db_fetch_object($result)) {
+    $node_types[$voc->vid][] = $voc->type;
+    unset($voc->type);
+    $voc->nodes = $node_types[$voc->vid];
+    $vocabularies[$voc->vid] = $voc;
+  }
+
+  return $vocabularies;
+}
\ No newline at end of file
