Bug #35170 isAfterLast() not working in streaming ResultSet
Submitted: 9 Mar 2008 9:29 Modified: 4 Jul 2008 16:08
Reporter: Janbo Petkov Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:5.1.6 OS:Windows (XP)
Assigned to: CPU Architecture:Any
Tags: isAfterLast, setFetchSize

[9 Mar 2008 9:29] Janbo Petkov
Description:
Connector/J

wrong result from isAfterLast() in streaming ResultSet when using setFetchSize(Integer.MIN_VALUE)

possibly connected to bugs #18148, #8778, #7435

tested with server.5.0.27
connector/j:
   3.0.11 - ok
   3.1.14 - ok
   5.0.8 - ok
   5.1.5 - fail
   5.1.6 - fail

How to repeat:
Connection con;
//... initiate con
Statement stt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, 
   ResultSet.CONCUR_READ_ONLY);
stt.setFetchSize(Integer.MIN_VALUE);
ResultSet set = stt.executeQuery("select * from TEST");
while(set.next());
boolean eof = set.isAfterLast();

wrong - eof == false
[10 Mar 2008 10:20] Tonci Grgin
Test case on latest c/J 5.1 sources

Attachment: TestBug35170.java (text/java), 1.54 KiB.

[10 Mar 2008 10:29] Tonci Grgin
Hi Janbo and thanks for your report. I must say I do not understand it. Can you please elaborate why "false" is wrong?
I would expect "false" there but for this.rs.isLast() I would expect error (see comments in my test case) using streaming RS. I'm using driver built from latest sources (5.1.7) on Win32.

Test case output (uncomment isLast() line to see the error):
.Loading JDBC driver 'com.mysql.jdbc.Driver'
Done.

Done.

Connected to 5.0.58-pb1083-log
java.vm.version         : 1.5.0_12-b04
java.vm.vendor          : Sun Microsystems Inc.
java.runtime.version    : 1.5.0_12-b04
os.name                 : Windows XP
os.version              : null
sun.management.compiler : HotSpot Client Compiler
falseE << Output from "this.rs.isAfterLast()", removed from test case attached
Time: 0,234
There was 1 error: << Error from "this.rs.isLast()", remarked in test case attached
1) testBug35170(testsuite.simple.TestBug35170)com.mysql.jdbc.RowDataDynamic$OperationNotSupportedException: Operation not supported for streaming result sets
	at com.mysql.jdbc.RowDataDynamic.notSupported(RowDataDynamic.java:454)
	at com.mysql.jdbc.RowDataDynamic.isLast(RowDataDynamic.java:365)
	at com.mysql.jdbc.ResultSetImpl.isLast(ResultSetImpl.java:6850)
	at testsuite.simple.TestBug35170.testBug35170(TestBug35170.java:39)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at testsuite.simple.TestBug35170.main(TestBug35170.java:51)

FAILURES!!!
Tests run: 1,  Failures: 0,  Errors: 1
[13 Mar 2008 13:17] Janbo Petkov
sorry. wrong example. right one:

			Statement stt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
			stt.setFetchSize(Integer.MIN_VALUE);
			ResultSet rs = stt.executeQuery("select * from mysql.user");
			rs.next();
			while(!rs.isAfterLast()){
				System.out.println(rs.getString(1));
				rs.next();
			}

fails with:
java.lang.NullPointerException
	at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5528)
	at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5434)
[13 Mar 2008 18:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/43953
[4 Jul 2008 16:08] Tony Bedford
An entry has been added to the 5.1.7 changelog:

Incorrect result is returned from isAfterLast() in streaming ResultSet when using setFetchSize(Integer.MIN_VALUE).
[30 Jul 2008 14:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/50724