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

sql: new built-in function crdb_internal.active_version() #77233

Merged
merged 1 commit into from
Mar 5, 2022

Conversation

knz
Copy link
Contributor

@knz knz commented Mar 1, 2022

Release justification: low risk, high benefit changes to existing functionality

Release note (sql change): The new built-in scalar function
crdb_internal.active_version() can now be used alongside
crdb_internal.is_at_least_version() to determine which cluster
version is currently active and choose client-side feature levels
accordingly.

@knz knz requested a review from rafiss March 1, 2022 17:57
@knz knz requested a review from a team as a code owner March 1, 2022 17:57
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

ty!

ReturnType: tree.FixedReturnType(types.Jsonb),
Fn: func(ctx *tree.EvalContext, _ tree.Datums) (tree.Datum, error) {
activeVersion := ctx.Settings.Version.ActiveVersionOrEmpty(ctx.Context)
jsonStr, err := gojson.Marshal(&activeVersion.Version)
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this behave correctly if "empty" was returned by ActiveVersionOrEmpty? (asking mostly to be educated, since i don't quite know when the version would be empty.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's empty if for some reason this function is called before the cluster is done initializing. In the SQL layer, that's about impossible since we don't let SQL start before cluster init.

@knz
Copy link
Contributor Author

knz commented Mar 5, 2022

TFYR!

bors r=rafiss

Release justification: low risk, high benefit changes to existing functionality

Release note (sql change): The new built-in scalar function
`crdb_internal.active_version()` can now be used alongside
`crdb_internal.is_at_least_version()` to determine which cluster
version is currently active and choose client-side feature levels
accordingly.
@craig
Copy link
Contributor

craig bot commented Mar 5, 2022

Build succeeded:

@craig craig bot merged commit f00306f into cockroachdb:master Mar 5, 2022
@knz knz deleted the 20220301-active-version branch March 5, 2022 13:33
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.

3 participants