PostgreSQL metadata commands use a different database name than the actual connection database
- Dominant language
- Java
- Stars
- 56
- Forks
- 7
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 5
Description
## Description
`dbvr meta database list` reports a database name that does not match the database configured in the datasource or the database actually used by the PostgreSQL connection.
The SQL connection works correctly, but the metadata commands appear to use a different database/catalog name.
## Environment
- dbvr: `26.1.5.202608161900`
- Database: PostgreSQL-compatible
- OS: Linux ARM64
The same behavior was also observed with dbvr `26.1.0`.
## Datasource configuration
The datasource is configured with a JDBC URL pointing to `actual_db`:
```text
jdbc:postgresql://db.example.com:5432/actual_db
```
For example:
```bash
dbvr datasource view
```
returns:
```json
{
"provider": "postgresql",
"driver": "postgres-jdbc",
"name": "example-ds",
"save-password": true,
"configuration": {
"url": "jdbc:postgresql://db.example.com:5432/actual_db",
"configurationType": "MANUAL",
"type": "dev"
}
}
```
## Actual PostgreSQL connection
Running:
```bash
dbvr sql -ds=example-ds "select current_database();"
```
returns:
```text
|current_database|
|----------------|
|actual_db |
Rows read: 1
```
So the JDBC connection is definitely connected to `actual_db`.
## Metadata result
However:
```bash
dbvr meta database list -ds=example-ds
```
returns:
```text
unexpected_db
```
Trying to use the actual database name with a metadata command fails:
```bash
dbvr meta table list -ds=example-ds -db=actual_db -sn=public
```
Result:
```text
Error evaluating cli: actual_db' not found
```
But using the incorrectly reported database name works:
```bash
dbvr meta table list -ds=example-ds -db=unexpected_db -sn=public
```
and correctly lists tables that actually belong to `actual_db`.
## Expected behavior
`dbvr meta database list -ds=example-ds` should report:
```text
actual_db
```
and metadata commands should accept:
```text
-db=actual_db
```
since this is both:
1. the database specified in the JDBC datasource URL; and
2. the value returned by PostgreSQL `current_database()`.
## Actual behavior
The SQL layer connects to `actual_db`, while the metadata layer exposes it under a different database/catalog name (`unexpected_db`).
It appears that the database/catalog name resolved by the metadata layer is inconsistent with the actual JDBC connection database.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue with the documented datasource URL and compare `dbvr sql -ds=example-ds "select current_database();"` with `dbvr meta database list -ds=example-ds`. Trace how the metadata commands resolve the database/catalog name, then verify that the listed name and `-db` value are `actual_db` and that table listing works with it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, postgresql
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100