refactor(server): extract session database metadata into server/sessionmeta#491
Merged
fuziontech merged 1 commit intomainfrom May 1, 2026
Merged
refactor(server): extract session database metadata into server/sessionmeta#491fuziontech merged 1 commit intomainfrom
fuziontech merged 1 commit intomainfrom
Conversation
…onmeta Carves the session-local catalog/metadata override helpers out of server/ into a new server/sessionmeta subpackage with no dependency on github.com/duckdb/duckdb-go. The helpers install per-session DuckDB views and macros that make current_database, pg_database, and information_schema_*_compat reflect the client-visible database name on the PG wire — used by both the standalone server's clientConn and the control plane's session bring-up. Symbols moved (from server/session_database_metadata.go to server/sessionmeta/sessionmeta.go): - InitSessionDatabaseMetadata (exported) - HasAttachedCatalog (was private hasAttachedCatalog; now exported) - All the buildSession* / sessionColumn* SQL builder helpers (private) - quoteSQLStringLiteral (private) Type signature change: the QueryExecutor parameter is now sqlcore.QueryExecutor (the interface moved to server/sqlcore in PR #488) instead of server.QueryExecutor. Backward compatibility preserved via re-export `var`s in server/exports.go: var ( HasAttachedCatalog = sessionmeta.HasAttachedCatalog InitSessionDatabaseMetadata = sessionmeta.InitSessionDatabaseMetadata ) Internal callers updated: - server/conn.go now calls sessionmeta.InitSessionDatabaseMetadata and sessionmeta.HasAttachedCatalog directly - controlplane/control.go switches from server.X to sessionmeta.X - server/session_database_metadata{,_remote}_test.go keep their duckdb-go-using mocks but call sessionmeta.X for the moved symbols go list -deps ./server/sessionmeta | grep duckdb-go # empty Verified: - go build ./... clean - go build -tags kubernetes ./... clean - go test -short ./server/... — green except the pre-existing server/tlscert hang on real ACME calls (unrelated) - go list -deps ./server/sessionmeta | grep duckdb-go is empty Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Carves the session-local catalog/metadata override helpers out of
server/into a newserver/sessionmetasubpackage with zeroduckdb-godependency.The helpers install per-session DuckDB views/macros that make
current_database,pg_database, and the variousinformation_schema_*_compatviews reflect the client-visible database name on the PG wire — used by both the standalone server'sclientConnand the control plane's session bring-up.Symbols moved from
server/session_database_metadata.gotoserver/sessionmeta/sessionmeta.go:InitSessionDatabaseMetadata(exported)HasAttachedCatalog(was privatehasAttachedCatalog; now exported)buildSession*/sessionColumn*SQL builder helpers (private)quoteSQLStringLiteral(private)The
QueryExecutorparameter is nowsqlcore.QueryExecutor(the interface moved in PR #488) instead ofserver.QueryExecutor.Backward compatibility
server/exports.gokeeps re-exportvars for the externally-used symbols, so existingserver.HasAttachedCatalog/server.InitSessionDatabaseMetadatacallers (control plane, etc.) compile unchanged. Internal callers inserver/conn.goandcontrolplane/control.gonow usesessionmeta.Xdirectly.Test plan
go build ./...cleango build -tags kubernetes ./...cleango test -short ./server/...— green except the pre-existingserver/tlscerthang on real ACME calls (unrelated)go list -deps ./server/sessionmeta | grep duckdb-goreturns empty🤖 Generated with Claude Code