Index: gsitemap.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gsitemap/Attic/gsitemap.module,v
retrieving revision 1.56.2.71
diff -u -p -r1.56.2.71 gsitemap.module
--- gsitemap.module	8 Oct 2007 16:18:46 -0000	1.56.2.71
+++ gsitemap.module	8 Oct 2007 18:05:54 -0000
@@ -701,11 +701,11 @@ function gsitemap_output_chunk($chunk) {
       $output .= _gsitemap_sublinks($additional, 'term_data', 'tid', $range, $previous_links);
     }
     else {
-      $count = db_result(db_query(db_rewrite_sql('SELECT COUNT(*) FROM {term_data}', 'term_data', 'tid')));
+      $count = db_result(db_query(db_rewrite_sql('SELECT COUNT(*) FROM {term_data} td', 'term_data', 'tid')));
       $count = $count > $range->high - $previous_links ? $range->high - $previous_links : $count;
       $previous_links = $previous_links + $count;
       if ($previous_links >= $range->low && !empty($count)) {
-        $tid = db_result(db_query_range(db_rewrite_sql('SELECT tid FROM {term_data} ORDER BY tid', 'term_data', 'tid'), $count - 1, 1));
+        $tid = db_result(db_query_range(db_rewrite_sql('SELECT td.tid FROM {term_data} td ORDER BY td.tid', 'term_data', 'tid'), $count - 1, 1));
         $limit = $previous_links - $range->low;
         $output .= _gsitemap_links('tid', $tid, $limit);
         $range->low = $previous_links;
@@ -801,7 +801,7 @@ function _gsitemap_sublinks($additional,
         $count = db_result(db_query('SELECT COUNT(*) FROM {users} WHERE uid >= %d AND uid <= %d'), $previous_id, $id);
       }
       else {
-        $count = db_result(db_query(db_rewrite_sql('SELECT COUNT(*) FROM {%s} WHERE %s >= %d AND %s <= %d', $table, $type), $table, $type, $previous_id, $type, $id));
+        $count = db_result(db_query(db_rewrite_sql('SELECT COUNT(*) FROM {%s} x WHERE x.%s >= %d AND x.%s <= %d', $table, $type), $table, $type, $previous_id, $type, $id));
       }
       $previous_id = $id + 1;
       $count = $count + $previous_links > $range->high ? $range->high - $previous_links : $count;
@@ -860,9 +860,9 @@ function _gsitemap_sublinks($additional,
       $id = db_result(db_query_range('SELECT uid FROM {users} WHERE uid >= %d ORDER BY uid', $count - 1, 1), $previous_id);
     }
     else {
-      $count = db_result(db_query(db_rewrite_sql('SELECT COUNT(*) FROM {%s} WHERE %s >= %d', $table, $type), $table, $type, $previous_id));
+      $count = db_result(db_query(db_rewrite_sql('SELECT COUNT(*) FROM {%s} x WHERE x.%s >= %d', $table, $type), $table, $type, $previous_id));
       $count = $count + $previous_links > $range->high ? $range->high - $previous_links : $count;
-      $id = db_result(db_query_range(db_rewrite_sql('SELECT %s FROM {%s} WHERE %s >= %d ORDER BY %s', $table, $type), $type, $table, $type, $previous_id, $type, $count - 1, 1));
+      $id = db_result(db_query_range(db_rewrite_sql('SELECT x.%s FROM {%s} x WHERE x.%s >= %d ORDER BY x.%s', $table, $type), $type, $table, $type, $previous_id, $type, $count - 1, 1));
     }
     $previous_links = $previous_links + $count;
     if ($previous_links >= $range->low) {
@@ -885,8 +885,8 @@ function _gsitemap_links($type, $id, $li
   $output = '';
   switch ($type) {
     case 'tid':
-      $offset = db_result(db_query(db_rewrite_sql('SELECT COUNT(*) - %d FROM {term_data} WHERE tid <= %d', 'term_data', 'tid'), $limit, $id));
-      $result = db_query_range(db_rewrite_sql('SELECT * FROM {term_data} WHERE tid <= %d ORDER BY tid', 'term_data', 'tid'), $id, $offset, $limit);
+      $offset = db_result(db_query(db_rewrite_sql('SELECT COUNT(*) - %d FROM {term_data} td WHERE td.tid <= %d', 'term_data', 'tid'), $limit, $id));
+      $result = db_query_range(db_rewrite_sql('SELECT * FROM {term_data} td WHERE td.tid <= %d ORDER BY td.tid', 'term_data', 'tid'), $id, $offset, $limit);
       while ($term = db_fetch_object($result)) {
         $output .= '<url><loc>'. url(taxonomy_term_path($term), NULL, NULL, TRUE) ."</loc><changefreq>always</changefreq></url>\n";
       }
@@ -1184,7 +1184,7 @@ function _gsitemap_link_count() {
   ")));
   $link_count = $link_count + count(module_invoke_all('gsitemap', 'node', $excludes));
   if (variable_get('gsitemap_showterms', FALSE)) {
-    $link_count = $link_count + db_result(db_query(db_rewrite_sql('SELECT COUNT(*) FROM {term_data}', 'term_data', 'tid')));
+    $link_count = $link_count + db_result(db_query(db_rewrite_sql('SELECT COUNT(*) FROM {term_data} td', 'term_data', 'tid')));
     $link_count = $link_count + count(module_invoke_all('gsitemap', 'term'));
   }
   if (variable_get('gsitemap_showusers', FALSE) && user_access('access user profiles')) {
