luislavena/mysql-gem — pull request #12 by cbandy (2013-02-07 13:59:55+00:00)
Title: Use ULL2NUM for affected_rows

This is a partial fix for #11.

I was able to bypass disk and memory requirements by using the BLACKHOLE engine, but the tests below take 22 minutes *each* on my [older] desktop. Without this commit, these tests fail with `<4294967296> expected but was <0>`.

```diff
diff --git a/test/test_mysql.rb b/test/test_mysql.rb
index f9013cd..543db6c 100644
--- a/test/test_mysql.rb
+++ b/test/test_mysql.rb
@@ -131,6 +131,16 @@ class TC_Mysql2 < Test::Unit::TestCase
assert_equal(1, @m.affected_rows)
end

+ def test_affected_rows_bigint()
+ @m.query("CREATE OR REPLACE VIEW null_16 AS SELECT NULL#{' UNION ALL SELECT NULL' * 15}")
+ @m.query("CREATE OR REPLACE VIEW null_256 AS SELECT NULL FROM null_16 a, null_16 b")
+ @m.query("CREATE OR REPLACE VIEW null_64k AS SELECT NULL FROM null_256 a, null_256 b")
+ @m.query("CREATE OR REPLACE VIEW null_4g AS SELECT NULL FROM null_64k a, null_64k b")
+
+ @m.query("CREATE TEMPORARY TABLE t ENGINE BLACKHOLE AS SELECT * FROM null_4g")
+ assert_equal(4_294_967_296, @m.affected_rows)
+ end
+
def test_autocommit()
if @m.methods.include? "autocommit" then
assert_equal(@m, @m.autocommit(true))
@@ -506,6 +516,17 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
end
end

+ def test_affected_rows_bigint()
+ @m.query("CREATE OR REPLACE VIEW null_16 AS SELECT NULL#{' UNION ALL SELECT NULL' * 15}")
+ @m.query("CREATE OR REPLACE VIEW null_256 AS SELECT NULL FROM null_16 a, null_16 b")
+ @m.query("CREATE OR REPLACE VIEW null_64k AS SELECT NULL FROM null_256 a, null_256 b")
+ @m.query("CREATE OR REPLACE VIEW null_4g AS SELECT NULL FROM null_64k a, null_64k b")
+
+ @s.prepare("CREATE TEMPORARY TABLE t ENGINE BLACKHOLE AS SELECT * FROM null_4g")
+ @s.execute
+ assert_equal(4_294_967_296, @s.affected_rows)
+ end
+
=begin
def test_attr_get()
assert_equal(false, @s.attr_get(Mysql::Stmt::ATTR_UPDATE_MAX_LENGTH))
```