Skip to content
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

adapter: expose Materialize version in mz_version parameter #17024

Merged
merged 1 commit into from
Jan 9, 2023

Conversation

benesch
Copy link
Member

@benesch benesch commented Jan 8, 2023

This commit exposes the Materialize-specific information in a new mz_version parameter, as in:

materialize=> show mz_version;
       mz_version
-------------------------
 v0.39.0-dev (73f6bed0e)
(1 row)

The mz_version parameter is additionally added to the parameter set that is automatically sent to the client during part of startup. This approach comes from CockroachDB, and allows clients to easily detect whether they're talking to Materialize or PostgreSQL without incurring an additional roundtrip.

I already have a PR out to sqlx 0 that uses this feature to automatically disable PostgreSQL-specific features that Materialize does not support.

The version string matches the output of the mz_version() function.

The implementation is somewhat irritating, as it requires plumbing the BuildInfo from the adapter into each session. Doesn't turn out too complicated, though, now that it's all written out.

Motivation

  • This PR adds a feature that has not yet been specified: sqlx support.

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered.

  • This PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way) and therefore is tagged with a T-proto label.

  • If this PR will require changes to cloud orchestration, there is a
    companion cloud PR to account for those changes that is tagged with
    the release-blocker label (example).

  • This PR includes the following user-facing behavior changes:

    • Add an mz_version system configuration parameter, which reports the Materialize version information. The value of this parameter is the same as the value returned by the existing mz_version() function. The parameter form can be more convenient for downstream applications.

@benesch benesch requested review from maddyblue and jkosh44 January 8, 2023 02:40
This commit exposes the Materialize-specific information in a new
`mz_version` parameter, as in:

    materialize=> show mz_version;
           mz_version
    -------------------------
     v0.39.0-dev (73f6bed)
    (1 row)

The `mz_version` parameter is additionally added to the parameter set
that is automatically sent to the client during part of startup. This
approach comes from CockroachDB, and allows clients to easily detect
whether they're talking to Materialize or PostgreSQL without incurring
an additional roundtrip.

I already have a PR out to sqlx [0] that uses this feature to
automatically disable PostgreSQL-specific features that Materialize does
not support.

The version string matches the output of the `mz_version()` function.

The implementation is somewhat irritating, as it requires plumbing the
`BuildInfo` from the adapter into each session. Doesn't turn out too
complicated, though, now that it's all written out.

[0]: launchbadge/sqlx#2282
@@ -399,6 +402,7 @@ static EMIT_TRACE_ID_NOTICE: ServerVar<bool> = ServerVar {
#[derive(Debug)]
pub struct SessionVars {
application_name: SessionVar<str>,
build_info: &'static BuildInfo,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go on SystemVars instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System vars can be set with ALTER SYSTEM SET which is not what we want here. It's kinda a funny split (probably system vars and server/session vars should be unified somehow), but for now this is the right spot!

@benesch benesch merged commit 5fcb756 into MaterializeInc:main Jan 9, 2023
@benesch benesch deleted the mz-version-param branch January 9, 2023 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants