Skip to content

getTableTypes is incomplete and several metadata methods leak statements #50

Closed

Description

@magnusp

Problem

Metadata methods return incomplete results and leave statements open. Long-running schema tools accumulate open statements, and a table name with a quote can break getIndexInfo.

Actual behavior

getTableTypes returns only TABLE and VIEW (LibsqlDatabaseMetaData.java:332-335). xerial 3.53.4.0 also returns SYSTEM TABLE and GLOBAL TEMPORARY. getSchemas, getCatalogs, getTypeInfo, getImportedKeys, getExportedKeys, getCrossReference, and getIndexInfo create statements that are never closed (:343-387). getIndexInfo interpolates the table name into SQL without escaping (:375-387). getMetaData returns a new object each call and never caches it (LibsqlConnection.java:288-292).

Expected behavior

The table type list is complete. Every metadata statement closes or is tracked. Table names are escaped. Metadata caching is documented or fixed.

Reproduction

dbmd.getTableTypes(); // missing SYSTEM TABLE and GLOBAL TEMPORARY
dbmd.getIndexInfo(null, null, "t'x", false, false); // syntax error

Call each listed method and inspect open statements and result sets.

Acceptance criteria

  • getTableTypes returns TABLE, VIEW, SYSTEM TABLE, and GLOBAL TEMPORARY.
  • No metadata method leaks a statement.
  • A table name containing a single quote is safe for getIndexInfo.
  • Tests cover each listed method.
  • Metadata caching behavior is documented.

References

  • libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/LibsqlDatabaseMetaData.java:332-335 (getTableTypes)
  • libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/LibsqlDatabaseMetaData.java:343-387 (leaking metadata methods)
  • libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/LibsqlDatabaseMetaData.java:375-387 (getIndexInfo)
  • libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/LibsqlConnection.java:288-292 (getMetaData)
  • xerial 3.53.4.0 JDBC3DatabaseMetaData.java:1754-1772 (getTableTypes)

Steering

Lane E (LibsqlDatabaseMetaData.java), position 3 of 3. Depends on #42. Lands in wave 5.

Correction from the #28 review. This body bundles four unrelated defects. Deliver them as four small sequenced PRs under this issue, one per defect, in this order. (1) getTableTypes completeness. (2) Statement leaks in the listed metadata methods. (3) getIndexInfo table-name escaping. (4) getMetaData caching, which touches LibsqlConnection.java; Lane D is complete by then. If the operator splits this into four issues, the order stands.

Contract. Match xerial 3.53.4.0 where it leads (JDBC3DatabaseMetaData.java:1754-1772 for table types). Parity is the default under #54.

Evidence. Per PR: the table-types list is complete; a leak-count test wraps each listed metadata method; a quoted table name round-trips through getIndexInfo; caching behavior is documented and pinned by a test. New tests fail on the current code and pass after the fix. Run ./mvnw -pl libsql-jdbc -am test and ./mvnw spotless:apply before push.

PR shape. Four PRs, each referencing this issue. Part of #54.

Activity

  1. added
    bugSomething isn't working
    P2Normal priority: edge case, feature gap, or test/process improvement
    on Oct 21, 2026
  2. added a commit that references this issue on Oct 22, 2026
    dca0037
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

    P2Normal priority: edge case, feature gap, or test/process improvementbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions