Message-ID: From: "kneth (@kneth)" To: "pgjdbc/pgjdbc" Date: Tue, 18 Feb 2025 16:10:11 +0000 Subject: [pgjdbc/pgjdbc] issue #3527: Improve compatibility with non-Postgres databases List-Id: X-GitHub-Author-Id: 1225363 X-GitHub-Author-Login: kneth X-GitHub-Issue: 3527 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3527 Content-Type: text/plain; charset=utf-8 Postgres compatible databases like https://github.com/crate/crate can use PG JDBC as driver. Often the PG JDBC driver is used by a tool or integration (JetBrains DataGrip to name one). As CrateDB isn't fully PG compatible, and hopefully the PG JDBC can offer a more robust support. The issue has also been reported as https://github.com/crate/crate/issues/17393. A patch to work around the differences between the two databases can be found in https://github.com/pgjdbc/pgjdbc/pull/3526. **Describe the issue** As far as I can see, a query as `SELECT current_database()` will return a different column name. For Postgres, the column name will be `current_database` while for CrateDB, the column name will be the name of the current database. The PG JDBC driver will try to access the column `current_database` - which does not exist in the CrateDB case (leading to an error or exception). It means that https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java#L1273 will fail as the column name is not specified in https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java#L1253 . **Driver Version?** 42.7.5 **Java Version?** **OS Version?** **PostgreSQL Version?** **To Reproduce** Any query with `current_database()` with the minimal case `SELECT current_database()`. **Expected behaviour** The driver should not throw an exception. **Logs** The following two screenshots show the difference between Postgres and CrateDB. ![Image](https://github.com/user-attachments/assets/910c468f-3bec-4ada-8e60-0f3041ba6f28) ![Image](https://github.com/user-attachments/assets/ddc71437-23c1-4ad5-a188-1f4829fac85e)