diff --git a/pkg/sql/logictest/testdata/logic_test/set b/pkg/sql/logictest/testdata/logic_test/set index 7fd50393bca6..b2abe3959469 100644 --- a/pkg/sql/logictest/testdata/logic_test/set +++ b/pkg/sql/logictest/testdata/logic_test/set @@ -753,6 +753,13 @@ SHOW tracing.custom ---- ijk +# Show a notice if a custom session variable has the same name as a cluster setting. +query T noticetrace +SET server.shutdown.drain_wait = '10s' +---- +NOTICE: setting custom variable "server.shutdown.drain_wait" +HINT: did you mean SET CLUSTER SETTING? + # Test that RESET ALL changes custom options to empty strings. statement ok RESET ALL diff --git a/pkg/sql/set_var.go b/pkg/sql/set_var.go index 0249ed00e25a..9f0bd4715f9c 100644 --- a/pkg/sql/set_var.go +++ b/pkg/sql/set_var.go @@ -17,6 +17,7 @@ import ( "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/server/telemetry" + "github.com/cockroachdb/cockroach/pkg/settings" "github.com/cockroachdb/cockroach/pkg/sql/paramparse" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" @@ -61,6 +62,15 @@ func (p *planner) SetVar(ctx context.Context, n *tree.SetVar) (planNode, error) if err != nil { return nil, err } + if _, ok := settings.Lookup(name, settings.LookupForLocalAccess, p.ExecCfg().Codec.ForSystemTenant()); ok { + p.BufferClientNotice( + ctx, + errors.WithHint( + pgnotice.Newf("setting custom variable %q", name), + "did you mean SET CLUSTER SETTING?", + ), + ) + } var typedValues []tree.TypedExpr if len(n.Values) > 0 {