Skip to content

Extract TableMetadataResolver from LibsqlResultSetMetaData #205

Closed

Description

@magnusp

Goal

Move table metadata lookup out of LibsqlResultSetMetaData. The class currently implements ResultSetMetaData and also queries sqlite_master, pragma_table_info, and pragma_database_list, with attached-schema fallback and a negative cache.

Depends on

#204 for file order, and #195 because the attached-schema branch has no test today.

Pin

LibsqlResultSetMetaDataTest covers aliases, joins, subqueries, RETURNING, views, USING and NATURAL star expansion, generated columns, width mismatches, and non-ASCII names. #195 adds the attached-schema case.

Scope

  • Create TableMetadataResolver holding the connection, SQL, column count, lazy resolution, and the LinkedHashMap cache, from LibsqlResultSetMetaData 35 and 397 to 527.
  • Move the ColumnInfo and TableInfo records with it.
  • Keep tableForColumn(int) as the single entry point for the three callers.

Preserve

  • tableContextResolved stays a separate boolean. A resolved null is not an unresolved state.
  • The negative cache uses containsKey and put. Do not switch to computeIfAbsent.
  • Temp before main fallback, hidden != 1, and COLLATE NOCASE in both queries.
  • Lowercased cache keys with the original-case name returned.
  • SqlTableReference.resolve receives the column list copy in order.

Acceptance

  • TableMetadataResolver.java exists and holds the moved code unchanged.
  • LibsqlResultSetMetaData.java is under 300 lines.
  • ./mvnw -pl libsql-jdbc -am test green with no assertion edited, including the new attached-schema pin.
  • ./mvnw -pl libsql-conformance -am verify green.
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