@@ -102,9 +102,15 @@ public class QueryExecutor {
102
102
public Continuation execute (@ Nonnull RelationalConnection connection , @ Nullable Continuation continuation ,
103
103
@ Nonnull QueryConfig config , boolean checkCache , @ Nullable Integer maxRows ) throws RelationalException {
104
104
final var currentQuery = config .decorateQuery (query );
105
- if (continuation == null || continuation .atBeginning ()) {
105
+ if (continuation == null ) {
106
+ // no continuation - start the query execution from the beginning
106
107
return executeQuery (connection , config , currentQuery , checkCache , maxRows );
108
+ } else if (continuation .atBeginning ()) {
109
+ // Continuation cannot be at beginning if it was returned from a query
110
+ reportTestFailure ("Received continuation shouldn't be at beginning" );
111
+ return null ;
107
112
} else {
113
+ // Have a continuation - continue
108
114
return executeContinuation (connection , continuation , config , maxRows );
109
115
}
110
116
}
@@ -238,14 +244,17 @@ private Object executeStatementWithForcedContinuations(final @Nonnull Statement
238
244
// Have continuations - keep running the query
239
245
Continuation continuation = resultSet .getContinuation ();
240
246
while (!continuation .atEnd ()) {
247
+ if (continuation .atBeginning ()) {
248
+ reportTestFailure ("Received continuation shouldn't be at beginning" );
249
+ }
241
250
try (var s2 = prepareContinuationStatement (connection , continuation , FORCED_MAX_ROWS )) {
242
251
resultSet = (RelationalResultSet )executeStatement (s2 , null );
243
252
final boolean hasNext = resultSet .next (); // Initialize result set value retrieval. Has only one row.
244
253
continuation = resultSet .getContinuation ();
245
254
if (!continuation .atEnd ()) {
246
255
results .add (resultSet );
247
256
} else {
248
- // We assume that the last result is empty because of the maxWors :1
257
+ // We assume that the last result is empty because of the maxRows :1
249
258
Assertions .assertFalse (hasNext );
250
259
}
251
260
}
0 commit comments