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: add a SET CLUSTER SETTING sql.defaults deprecation notice #80548

Merged
merged 1 commit into from
May 16, 2022

Conversation

e-mbrown
Copy link
Contributor

@e-mbrown e-mbrown commented Apr 26, 2022

Resolves #80325

Added a deprecation notice for when SET CLUSTER SETTINGS sql.defaults...
is used. The notice directs users to use the ALTER ROLE syntax instead

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@e-mbrown e-mbrown requested review from rafiss and a team April 26, 2022 14:11
@e-mbrown e-mbrown requested review from a team and msbutler and removed request for a team April 26, 2022 18:04
Copy link
Collaborator

@msbutler msbutler left a comment

Choose a reason for hiding this comment

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

LGTM.

Might be worth adding to the release note, unless the docs team is already aware of this deprecation?


if strings.Contains(n.name, "sql.defaults") {
params.p.BufferClientNotice(params.ctx,
pgnotice.Newf("The `SET CLUSTER SETTING sql.defaults...` syntax is deprecated, please "+
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps

params.p.BufferClientNotice(
      params.ctx,
      errors.WithHintf(
			   pgnotice.Newf("`SET CLUSTER SETTING %s` syntax is deprecated", n.name),
         "use `ALTER ROLE ... SET` which allows finger-grained control. See %s",
         docs.URL("alter-role.html#set-default-session-variable-values-for-a-role"),
    ),
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

i think we should use a bit softer language than "deprecated" -- usually deprecated means that we don't support it or it will go away eventually

in this case, i'd view the notice as more of a helpful hint. like

"setting a global default; use the `ALTER ROLE ... SET` syntax to control session variable defaults at a finer-grained level"

@blathers-crl blathers-crl bot requested a review from otan April 27, 2022 14:39
@e-mbrown e-mbrown force-pushed the eb/sqldeflts branch 2 times, most recently from e31f7ea to 431a4ce Compare April 27, 2022 20:56
errors.WithHintf(
pgnotice.Newf("Setting global default %s`;", n.name),
"use the `ALTER ROLE ... SET` syntax to control session variable defaults at a finer-grained level. See: %s",
docs.URL("https://www.cockroachlabs.com/docs/stable/alter-role.html#set-default-session-variable-values-for-a-role"),
Copy link
Contributor

Choose a reason for hiding this comment

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

this should just be alter-role.html#set-default-session-variable-values-for-a-role

Copy link
Contributor

@otan otan left a comment

Choose a reason for hiding this comment

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

i think we should make a release note out of this as well

@@ -193,6 +195,18 @@ func (p *planner) getAndValidateTypedClusterSetting(
}

func (n *setClusterSettingNode) startExec(params runParams) error {

if strings.Contains(n.name, "sql.defaults") {
Copy link
Contributor

Choose a reason for hiding this comment

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

lets use strings.HasPrefix

params.p.BufferClientNotice(
params.ctx,
errors.WithHintf(
pgnotice.Newf("Setting global default %s`;", n.name),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: errors start with lowercase, so "setting global default". remove the semicolon ; as well

@blathers-crl blathers-crl bot requested a review from otan May 2, 2022 19:06
params.p.BufferClientNotice(
params.ctx,
errors.WithHintf(
pgnotice.Newf("setting global default %s`", n.name),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe" setting global default %s is not recommended" (remove the backtick at the end)

@blathers-crl blathers-crl bot requested a review from otan May 3, 2022 18:50
Release note (sql change): The `ALTER ROLE` syntax` allows users to set
default values for session variables making `SET CLUSTER SETTINGS
sql.defaults...` redundant. This PR adds a notice to `SET CLUSTER SETTINGS
sql.defaults...` that directs the user to use the `ALTER ROLE` syntax instead.
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.

lgtm!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @e-mbrown and @otan)

@craig
Copy link
Contributor

craig bot commented May 16, 2022

Build succeeded:

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.

sql: show a notice when SET CLUSTER SETTING sql.defaults... is used
5 participants