in core/src/main/java/org/apache/calcite/avatica/MetaImpl.java [1589:1631]
private void moveNext() {
for (;;) {
if (rows.hasNext()) {
break;
}
if (frame.done) {
rows = null;
break;
}
try {
// currentOffset updated after element is read from `rows` iterator
frame = fetch(stmt.handle, currentOffset, fetchSize);
} catch (NoSuchStatementException e) {
resetStatement();
// re-fetch the batch where we left off
continue;
} catch (MissingResultsException e) {
try {
// We saw the statement, but it didnt' have a resultset initialized. So, reset it.
if (!stmt.syncResults(state, currentOffset)) {
// This returned false, so there aren't actually any more results to iterate over
frame = null;
rows = null;
break;
}
// syncResults returning true means we need to fetch those results
} catch (NoSuchStatementException e1) {
// Tried to reset the result set, but lost the statement, save a loop before retrying.
resetStatement();
// Will just loop back around to a MissingResultsException, but w/e recursion
}
// Kick back to the top to try to fetch again (in both branches)
continue;
}
if (frame == null) {
rows = null;
break;
}
// It is valid for rows to be empty, so we go around the loop again to
// check
rows = frame.rows.iterator();
}
}