sql: bump the advertised pg compat version to 9.6 or later
The advertised pg compat version should be 9.6 or above.
Preferably 10 after enough client libraries / frameworks have been tested to confirm a high value does not disrupt compatibility.
Original issue description follows
Describe the problem
CockroachDB has a compatibility issue with JDBC driver.
CockroachDB claims to be Postgresql 9.5, however, in PgDatabaseMetaData.java#getIndexInfo, JDBC driver assumes column amcanorder to exist on table pg_am.
To Reproduce
- Set up CockroachDB cluster
- Set up a Spring Boot project and use JPA to manage the schema of the database.
- Set a non-unique index on a column
- Start the Java program, stop it, and start it again. JPA will try to validate the schema and leads to the exception.
Expected behavior
Either CockroachDB should claim to be version 9.6+ or should have column amcanorder on table pg_am.
Additional data / screenshots
Java call stack https://pastebin.com/hqtkp5LD
Environment:
- CockroachDB version: 2.1.1
- Server OS: Docker on macOS
- Client app: JDBC
Additional context
Thank you for your analysis. Yes indeed this seems to be a shortcoming that needs to be corrected.
@awoods187 this will be needed for Spring compatibility and overall more compatibility with Java client.
I'm also experiencing this using Spring Boot, JPA, and Hibernate.
@knz what's the effort to address this?
The strategy would be split in 3 phases:
-
in the immediate term (with backport to 2.1) introduce an opt-in session parameter, customizable in the connection URL, to configure the pg version reported to the client.
-
in the short term (perhaps with backport to 2.1), add the missing column in pg_am. I think the work is minimal but I am not sure.
-
in the longer term (no backport, perhaps no earlier than 2.3) bump the pg version reported to clients to something more recent, at least 9.6 but perhaps 10 or 11
As to your phases:
- The customizable session parameter seems like unneeded work. Being able to customize the reported pg version means we would have to either support more than one version of pg or hope that setting the version to something we don't fully support will allow the client to proceed. I fear if they're hitting one introspection bug, changing the reported version may hit others.
- Is now done in #33252
- I'm in full agreement about having 2.2 or 2.3 report pg 10 or 11 and make sure all of the introspection tables match.
Removing the severity label because pg_am now contains amcanorder.
@rafiss @knz would it be possible to bump the postgres version to at least 10 to support EntGo?
A version bump is overdue, I agree, but is not entirely trivial:
- we must update a couple of the pg_catalog tables to adhere to the new post-v9.6 and v10 schemas
- we must check for regression in our compatibility test suites
So I'd agree we want to do this but we can't do it casually either.
Closing since #56248 was merged