title: Ruby Mysql2: different results using count method
body: <p>I'm using .count method in a mysql2 query results:</p>
  
  <p>My code:</p>
  
  <pre><code>  require "mysql2"
  
    hostname='db.xxxxx.xxx'
    port='3306'
    username='xxxxxx'
    password='xxxxxxxxxxxxxxxxxxxxxxxxxx'
    database='xxx'
  
    dbh = Mysql2::Client.new(:host=&gt; hostname, :username=&gt; username, :password=&gt; password, :database=&gt; database, :port=&gt; port.to_f, :database_timezone=&gt; :utc, :application_timezone =&gt; :local)
  
  
    results=dbh.query("SELECT * FROM xxx")
      p results.count
      i=0
      results.each do |result|
          i=i+1   
      end
  
      p results.count
  </code></pre>
  
  <p>With the first results.count I obtain the number of SELECT results rows as expected. But for the second one, I obtain (sometimes!) a different value:</p>
  
  <hr>
  
  <p>My results:</p>
  
  <pre><code>$ ruby test_count.rb
  4942
  4942
  
  $ ruby test_count.rb 
  4942
  24773520
  
  $ ruby test_count.rb 
  4942
  37442208
  </code></pre>
  
  <hr>
  
  <p>My config:</p>
  
  <pre><code>$ rvm --version
  rvm 1.13.4 (stable) by Wayne E. Seguin &lt;wayneeseguin@gmail.com&gt;, Michal Papis &lt;mpapis@gmail.com&gt; [https://rvm.io/]
  
  $ ruby --version
  ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
  
  $ gem list
  
  *** LOCAL GEMS ***
  
  Ascii85 (1.0.1)
  bundler (1.1.3)
  curb (0.8.0)
  mime-types (1.18)
  mysql (2.8.1)
  mysql2 (0.3.11)
  pdf-reader (1.1.1)
  prawn (0.12.0)
  prawn-core (0.8.4)
  rake (0.9.2.2)
  ruby-filemagic (0.4.2)
  ruby-rc4 (0.1.5)
  rubygems-bundler (0.9.2)
  RubyInline (3.11.2)
  rvm (1.11.3.3)
  ttfunk (1.0.3)
  ZenTest (4.8.0)
  </code></pre>
  
  <p>Someone have any idea why is this happen?</p>
  
  <p>Thanks</p>