Calling Statement.setMaxRows(N) has the effect of returning N+1 rows
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
N) has the effect of returning
N+1) rows, as can be shown with this alternative program:
while (r.next()) System.out.println(r.getInt(1));