Handle invalid step results

This commit is contained in:
김선우
2025-01-21 19:00:38 +09:00
parent f7a8d1b428
commit 82e9fe0219
3 changed files with 14 additions and 3 deletions

View File

@@ -64,6 +64,11 @@ public class LimboResultSet {
row++;
}
if (lastStepResult.isInInvalidState()) {
open = false;
throw new SQLException("step() returned invalid result: " + lastStepResult);
}
pastLastRow = lastStepResult.isDone();
if (pastLastRow) {
open = false;

View File

@@ -13,6 +13,7 @@ public class LimboStepResult {
private static final int STEP_RESULT_ID_IO = 20;
private static final int STEP_RESULT_ID_DONE = 30;
private static final int STEP_RESULT_ID_INTERRUPT = 40;
// Indicates that the database file could not be written because of concurrent activity by some other connection
private static final int STEP_RESULT_ID_BUSY = 50;
private static final int STEP_RESULT_ID_ERROR = 60;
@@ -41,6 +42,14 @@ public class LimboStepResult {
return stepResultId == STEP_RESULT_ID_DONE;
}
public boolean isInInvalidState() {
// current implementation doesn't allow STEP_RESULT_ID_IO to be returned
return stepResultId == STEP_RESULT_ID_IO ||
stepResultId == STEP_RESULT_ID_INTERRUPT ||
stepResultId == STEP_RESULT_ID_BUSY ||
stepResultId == STEP_RESULT_ID_ERROR;
}
@Override
public String toString() {
return "LimboStepResult{" +

View File

@@ -9,7 +9,6 @@ import java.util.Properties;
import org.github.tursodatabase.TestUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
class JDBC4ResultSetTest {
@@ -27,7 +26,6 @@ class JDBC4ResultSetTest {
}
@Test
@Disabled("https://github.com/tursodatabase/limbo/pull/743#issuecomment-2600746904")
void invoking_next_before_the_last_row_should_return_true() throws Exception {
stmt.executeUpdate("CREATE TABLE users (id INT PRIMARY KEY, username TEXT);");
stmt.executeUpdate("INSERT INTO users VALUES (1, 'sinwoo');");
@@ -41,7 +39,6 @@ class JDBC4ResultSetTest {
}
@Test
@Disabled("https://github.com/tursodatabase/limbo/pull/743#issuecomment-2600746904")
void invoking_next_after_the_last_row_should_return_false() throws Exception {
stmt.executeUpdate("CREATE TABLE users (id INT PRIMARY KEY, username TEXT);");
stmt.executeUpdate("INSERT INTO users VALUES (1, 'sinwoo');");