Skip to content

fix(pg_client): discover attached database name dynamically - #34

Closed
adsharma wants to merge 1 commit into
mainfrom
fix/foreign-db-name-dynamic-lookup
Closed

fix(pg_client): discover attached database name dynamically#34
adsharma wants to merge 1 commit into
mainfrom
fix/foreign-db-name-dynamic-lookup

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Replace the hardcoded 'pg' database name in foreignDatabaseName with a dynamic lookup that matches the PgClientConnector reference against all attached databases in DatabaseManager. This ensures the correct database alias is used regardless of what name the user specified in the ATTACH ... AS statement.

Adds getAttachedDBName() helper that iterates through attached databases, finds the AttachedPgClientDatabase whose connector matches, and returns its dbName. Falls back to empty string if no match is found.

Pass the ATTACH alias (dbName) directly through the PgClientCatalog
constructor instead of hardcoding schema-qualified names like
'public.node_person' or 'public.fkrel_knows'.

The foreignDatabaseName must be the lbug attached-database name so
the join-push-down optimizer can look it up via
DatabaseManager::getAttachedDatabase().  The correct name is already
known at ATTACH time (the AS <name> alias), so we thread it through
the constructor rather than trying to discover it later.

This fixes the case where a user ATTACHes pg_client with a custom
alias (e.g. 'ATTACH ... AS mydb') — the shadow entries will now
use 'mydb' instead of failing to find the attached database.
@adsharma
adsharma force-pushed the fix/foreign-db-name-dynamic-lookup branch from 77bb79d to e83f8b4 Compare July 28, 2026 00:02
@adsharma

Copy link
Copy Markdown
Contributor Author

This doesn't work

@adsharma adsharma closed this Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant