Skip to content

Unify statement result attachment and remove the closed=false window #211

Closed

Description

@magnusp

Goal

Unify statement result attachment and remove the transient closed = false window. assignResultSet and executeResult are near copies, and closeResultSet flips closed and closing so a nested close can pass the closed check.

Depends on

#195 for the close-path pin.

Pin

LibsqlStatementLifecycleTest covers post-close execute returning a closed result set, close-on-completion, and the requested-result-set error. LibsqlStatementConcurrencyTest covers execute against close. The xerial StatementTest, PrepStmtTest, and MetadataLeakTest cover the same surface.

Scope

  • Add one attachResult(...) used by both paths, with a discardCurrentResult() for the closed branch.
  • Add LibsqlResultSet.closeDetached() that closes without calling back into the statement.
  • Replace the flag flip in closeResultSet (329 to 342).
  • Share newQueryResult(...) between LibsqlStatement.executeQuery and LibsqlPreparedStatement.executeQuery.

Preserve

  • Post-close execute, executeQuery, executeUpdate, and getConnection keep working and return a closed result set.
  • A second result set on the same statement throws "ResultSet already requested".
  • closeOnCompletion and isCloseOnCompletion keep the lower-case "statement is closed" message.
  • Metadata result sets never use close-on-completion.
  • updateCount is -1 when a result set exists and the affected row count otherwise.

Acceptance

  • closed is never written outside close() and closeDetached, and no method temporarily reopens the statement.
  • LibsqlStatement.java is under 650 lines.
  • ./mvnw -pl libsql-jdbc -am test green with no assertion edited.
  • ./mvnw -pl libsql-itests -am verify green with DOCKER_CONFIG set per AGENTS.md section 4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions