File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 27
27
result . each { |r | r . should_not be_nil }
28
28
end
29
29
30
- it "#count should be zero for rows after streaming when there were no results " do
30
+ it "#count should be zero for rows after streaming when there were no results" do
31
31
@client . query "USE test"
32
32
result = @client . query ( "SELECT * FROM mysql2_test WHERE null_test IS NOT NULL" , :stream => true , :cache_rows => false )
33
33
result . count . should eql ( 0 )
34
34
result . each . to_a
35
35
result . count . should eql ( 0 )
36
36
end
37
37
38
+ it "should raise an exception if streaming ended due to a timeout" do
39
+ # Create an extra client instance, since we're going to time it out
40
+ client = Mysql2 ::Client . new DatabaseCredentials [ 'root' ]
41
+ client . query "CREATE TEMPORARY TABLE streamingTest (val VARCHAR(10))"
42
+
43
+ # Insert enough records to force the result set into multiple reads
44
+ 10000 . times do |i |
45
+ client . query "INSERT INTO streamingTest (val) VALUES ('Foo #{ i } ')"
46
+ end
47
+
48
+ client . query "SET net_write_timeout = 1"
49
+ res = client . query "SELECT * FROM streamingTest" , :stream => true
50
+
51
+ lambda {
52
+ res . each_with_index do |row , i |
53
+ # Exhaust the first result packet then trigger a timeout
54
+ sleep 2 if i > 0 && i % 1000 == 0
55
+ end
56
+ } . should raise_error ( Mysql2 ::Error , /Lost connection/ )
57
+ end
58
+
38
59
it "should have included Enumerable" do
39
60
Mysql2 ::Result . ancestors . include? ( Enumerable ) . should be_true
40
61
end
You can’t perform that action at this time.
0 commit comments