Is there a way to get the server-version?
The driver I’m writing would benefit from it to see what syntax it can/should generate.
The pg-adapter sends the following: SELECT CAST(current_setting('server_version_num') AS integer) AS v returning something like 140013 .
https://github.com/jeremyevans/sequel/blob/7a520bb9c013947bd60d9170e727fb52a2287ba1/lib/sequel/adapters/shared/postgres.rb#L757-L762
👍 that needs some parsing for my purpose then. And I see nightly returns "XTDB @ nightly" 🙂 I can open an issue (if not already on the roadmap).
I don't think there's anything open in this area currently 🤔 does the number need to be stable / monotonic?
perhaps a timestamp of the build time?
my usecase would be: easily comparable.
What pg does: major * 10_000 + minor
e.g. output snippet of show all
...
{:name=>"server_version", :setting=>"14.13 (Postgres.app)", :description=>"Shows the server version."},
{:name=>"server_version_num", :setting=>"140013", :description=>"Shows the server version as an integer."},
...
What sequel does for mssql: "13.14.1500" => 13141500
For betas and nightlies both ‘upcoming’ or ‘current + revision’ would work: 2.3.4-pre => 2003004, 2.3.4.1234 => 2003004
Prior art: https://github.com/search?q=repo%3Ajeremyevans%2Fsequel+server_version+path%3A%2F%5Elib%5C%2Fsequel%5C%2F%2F&type=codeWITH s0 AS (
SELECT 'XTDB @ 2.3.4-beta3' AS i0
),
s1 AS (
SELECT SUBSTRING(i0 FROM POSITION(' @ ' IN i0) + 3) AS i1
FROM s0
),
s2 AS (
SELECT SUBSTRING (i1 FROM POSITION('.' IN i1) + 1) AS i2,
CAST(SUBSTRING(i1 FROM 0 FOR POSITION('.' IN i1)) AS INTEGER) AS major
FROM s1
),
s3 AS (
SELECT SUBSTRING (i2 FROM POSITION('.' IN i2) + 1) AS i3,
CAST(SUBSTRING(i2 FROM 0 FOR POSITION('.' IN i2)) AS INTEGER) AS minor
FROM s2
),
s4 AS (
SELECT CAST(SUBSTRING(i3 FROM 0 FOR POSITION('-' IN i3)) AS INTEGER) AS patch
FROM s3
)
SELECT major * 1000000 + minor * 1000 + patch AS server_version_num FROM s0, s1, s2, s3, s4;that would work! 🙂
…though it would require a proper version instead of XTDB @ nightly 😬 hope that that’s possible.
how do NEST_MANY and NEST_ONE work with a jdbc driver? I'm curious partially because it feels like it could be a standard postgres extension as well
JDBC drivers mostly send SQL "as-is" to the database to deal with, so the NEST_* functionality is on the database end of the pg-wire protocol, not the driver.
I mean from a ResultSet
the result of a NEST_MANY would turn into...something
PGObject / JSON-like stuff as I understand it.
is it like a nested resultset?
ah okay
See their xtdb-jdbc module that has next.jdbc helpers for unpacking the result sets.
(since builder fns only handle top-level column values, their builders walk the entire object tree to produce vectors and hash maps)
JDBC allows for arbitrary objects to come back from the database as column values -- but they're opaque to JDBC itself, and the getObject() part is implemented by the specific driver.
the xtdb-jdbc module helps convert things back to regular maps via a custom transit+json Postgres wire protocol OID format (i.e. it's not limited json types)