-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql + pgwire: provide ways for clients to discover the CockroachDB version #14145
Conversation
nit: second commit message should not reference the first; just describe the commit in isolation. Reviewed 2 of 2 files at r1, 3 of 3 files at r2. pkg/acceptance/c_test.go, line 491 at r1 (raw file):
I'd probably include this in the other test rather than adding a new one. pkg/sql/pgwire/v3.go, line 258 at r1 (raw file):
why not get this at init? Comments from Reviewable |
Review status: 2 of 6 files reviewed at latest revision, 2 unresolved discussions, some commit checks pending. pkg/acceptance/c_test.go, line 491 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
The other test is ran two times (one with a good query, one in a failing query) -- it didn't seem to be a good fit. pkg/sql/pgwire/v3.go, line 258 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
You mean Comments from Reviewable |
Reviewed 2 of 2 files at r1, 4 of 4 files at r3. pkg/acceptance/c_test.go, line 491 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
I was going to suggest this as well originally, but that test is getting pretty big and gnarly. I would be a fan of a refactor to this test (and others like it) that pull out the inlined programs into their own files, with a corresponding test harness update. I'm not suggesting we do that in this PR though. pkg/sql/crdb_internal.go, line 46 at r4 (raw file):
bikeshed: I'm not sure the name Comments from Reviewable |
Review status: 3 of 6 files reviewed at latest revision, 3 unresolved discussions. pkg/acceptance/c_test.go, line 491 at r1 (raw file): Previously, jordanlewis (Jordan Lewis) wrote…
Well there's a reason for that; we are testing (there) that we can actually detect a failing test. Currently, this test does not include that machinery, so for all we know, it could be exiting zero regardless of the implementation. pkg/sql/pgwire/v3.go, line 258 at r1 (raw file): Previously, knz (kena) wrote…
Ah, I misread; this is good as-is. Comments from Reviewable |
Review status: 3 of 6 files reviewed at latest revision, 3 unresolved discussions, some commit checks pending. pkg/acceptance/c_test.go, line 491 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
I'm not sure I'm following the conversation here. To come back to the issue at hand, what do you suggest I do in this PR? pkg/sql/crdb_internal.go, line 46 at r4 (raw file): Previously, jordanlewis (Jordan Lewis) wrote…
Done. Comments from Reviewable |
Review status: 3 of 6 files reviewed at latest revision, 2 unresolved discussions. pkg/acceptance/c_test.go, line 491 at r1 (raw file): Previously, knz (kena) wrote…
Two options:
Comments from Reviewable |
…ssage. Discussed in MagicStack/asyncpg#87 (comment) It is useful for clients to know that they are actually talking to a CockroachDB SQL node, as opposed to a real PostgreSQL server. At this point there is no way to determine a client is connected to CockroachDB using a SQL statement/query that would not otherwise *fail* in PostgreSQL. This patch addresses this limitation by returning a new `crdb_version` parameter in the ParameterStatus message. (https://www.postgresql.org/docs/9.5/static/protocol-message-formats.html) This is safe because as explained in https://www.postgresql.org/docs/9.5/static/protocol-flow.html#PROTOCOL-ASYNC "This set might change in the future, or even become configurable. Accordingly, a frontend should simply ignore ParameterStatus for parameters that it does not understand or care about."
Prior to this commit, pgwire clients could inspect the CockroachDB version from the parameter status message. However this is only reported during connection start-up, and client drivers may not be able to save this information (e.g. Go's lib/pq doesn't). This patch complements the previous mechanism by reporting the version details also in a new virtual table `crdb_internal.local_version`. A client that wants to disambiguate between pg and CockroachDB can select into that table. To avoid this query to fail on pg, the client may first check using `information_schema.schemata` whether this table exists.
Review status: 2 of 6 files reviewed at latest revision, 2 unresolved discussions. pkg/acceptance/c_test.go, line 491 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Thanks for explaining. Done. Comments from Reviewable |
Reviewed 1 of 4 files at r3, 1 of 4 files at r5, 3 of 3 files at r6. Comments from Reviewable |
TFYRs! |
Fixes #14142.
sql/pgwire: report the CockroachDB version in the pgwire parameter message.
Discussed in MagicStack/asyncpg#87 (comment)
It is useful for clients to know that they are actually talking to a
CockroachDB SQL node, as opposed to a real PostgreSQL server. At this
point there is no way to determine a client is connected to
CockroachDB using a SQL statement/query that would not otherwise
fail in PostgreSQL.
This patch addresses this limitation by returning a new
crdb_version
parameter in the ParameterStatus
message. (https://www.postgresql.org/docs/9.5/static/protocol-message-formats.html)
This is safe because as explained in
https://www.postgresql.org/docs/9.5/static/protocol-flow.html#PROTOCOL-ASYNC
"This set might change in the future, or even become
configurable. Accordingly, a frontend should simply ignore
ParameterStatus for parameters that it does not understand or care
about."
sql: report the CockroachDB information details also in a virtual table.
The changes in the previous commit have enabled pgwire clients to
inspect the CockroachDB version from the parameter status message.
However this is only reported during connection start-up, and client
drivers may not be able to save this information (e.g. Go's lib/pq
doesn't).
This patch complements the previous change by reporting the version
details also in a new virtual table
crdb_internal.local_version
. Aclient that wants to disambiguate between pg and CockroachDB can
select into that table. To avoid this query to fail on pg, the client
may first check using
information_schema.schemata
whether this tableexists.
This change is