Duplicate nodes returned from a module's SQL query
I just took a quick look at the calendar_block module. From what I can tell, hook_calendar_block op alter is called for every single day in the calendar. I guess this makes sense at it allows you to alter the appearance of any day.

My guess is that the calendar on your site has 35 days in it which is why your query is run 35 times.

You could make use of a static variable to only do your stuff once or save the query etc.

Something like this could work:

function calendar_block_mod_calendar_block(&amp;$calendar, &amp;$date, $op) {
  switch($op) {
    case 'alter':
      static $events;
      if (empty($events)) {
        $sql = "SELECT DISTINCT node.nid AS nid 
              FROM {node}
              INNER JOIN term_node term_node ON node.vid = term_node.vid 
              WHERE (node.status &lt;&gt; 0) AND (term_node.tid = 5)"; 

        $results = db_query($sql);

        while ($node = db_fetch_object($results)) {    
          $events[] = node_load(array('nid' =&gt; $node-&gt;nid));
        }
      }
      ....
  }
}


The above code doesn't catch the case where there is no result and is just meant as a proof of concept.

Update:
If you only want to run the entire code once, you could do something like this:

function calendar_block_mod_calendar_block(&amp;$calendar, &amp;$date, $op) {
  switch($op) {
    case 'alter':
      static $code_executed;
      if (!$code_executed) {
        ...
        $code_executed = TRUE;
      }
  }
}