diff --git a/lib/Redmine/DB/MySQL.pm b/lib/Redmine/DB/MySQL.pm
index d52d2edd9dd260b20ec32a5a7d784c1c0fbac5a6..935b6769509676094bfd56da5ab69c03e2ae2c3d 100644
--- a/lib/Redmine/DB/MySQL.pm
+++ b/lib/Redmine/DB/MySQL.pm
@@ -73,8 +73,8 @@ sub get_all_x
   if (defined ($where))
   {
     # print "where: ", Dumper ($where) if ($show_query);
-    $ss .= ' WHERE ' . shift (@$where);
-    @v= @$where;
+    @v= @$where; # copy first!
+    $ss .= ' WHERE ' . shift (@v);
   }
 
   if ($show_query)