Calling Statement.setMaxRows(N) has the effect of returning N+1 rows

Issue #65 resolved
Lukas Eder
created an issue

I'm running jOOQ integration tests against the Xerial driver and I've found a couple of bugs, which I'm reporting here. I have detected these bugs with the downloaded version 3.7.15-SNAPSHOT-2.

Run this Java program

Connection c = getConnection();
Statement s = c.createStatement();
s.setMaxRows(1);
ResultSet r = s.executeQuery(
    "select 1 union select 2 union select 3 order by 1");
assertTrue(r.next());
assertEquals(1, r.getInt(1));
assertFalse(r.next()); // This fails

In fact, setting max rows to 1 (N) has the effect of returning 2 (N+1) rows, as can be shown with this alternative program:

while (r.next())
    System.out.println(r.getInt(1));