Repository navigation
getTableTypes is incomplete and several metadata methods leak statements #50
Description
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 errorCall each listed method and inspect open statements and result sets.
Acceptance criteria
-
getTableTypesreturns 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
feat(jdbc): add xerial conformance suite and harden metadata (#28)
fix(jdbc): return all xerial table types (#90)
fix(jdbc): close metadata statements with their result sets (#91)
fix(jdbc): escape quoted table names in getIndexInfo (#93)
fix(jdbc): cache database metadata per connection (#94)