From d8a49673ea4fd821cd2583b9affbc50b69406f3d Mon Sep 17 00:00:00 2001 From: Neha George Date: Tue, 21 Dec 2021 11:18:53 -0500 Subject: [PATCH] sql: refactor GlobalDefault for session variables This commit refactors `pkg/sql/vars.go` to use globalFalse and globalTrue as the setting GlobalDefault where possible. Release note: None --- pkg/sql/vars.go | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/pkg/sql/vars.go b/pkg/sql/vars.go index dffd70cdacd8..fc874ec2d08c 100644 --- a/pkg/sql/vars.go +++ b/pkg/sql/vars.go @@ -586,9 +586,7 @@ var varGen = map[string]sessionVar{ Get: func(evalCtx *extendedEvalContext) (string, error) { return formatBoolAsPostgresSetting(evalCtx.SessionData().PartiallyDistributedPlansDisabled), nil }, - GlobalDefault: func(sv *settings.Values) string { - return formatBoolAsPostgresSetting(false) - }, + GlobalDefault: globalFalse, }, // CockroachDB extension. @@ -686,9 +684,7 @@ var varGen = map[string]sessionVar{ Get: func(evalCtx *extendedEvalContext) (string, error) { return formatBoolAsPostgresSetting(evalCtx.SessionData().TestingVectorizeInjectPanics), nil }, - GlobalDefault: func(sv *settings.Values) string { - return formatBoolAsPostgresSetting(false) - }, + GlobalDefault: globalFalse, }, // CockroachDB extension. @@ -990,10 +986,8 @@ var varGen = map[string]sessionVar{ GetFromSessionData: func(sd *sessiondata.SessionData) string { return formatBoolAsPostgresSetting(sd.IsSuperuser) }, - GetStringVal: makePostgresBoolGetStringValFn("is_superuser"), - GlobalDefault: func(sv *settings.Values) string { - return "off" - }, + GetStringVal: makePostgresBoolGetStringValFn("is_superuser"), + GlobalDefault: globalFalse, }, // CockroachDB extension. @@ -1512,9 +1506,7 @@ var varGen = map[string]sessionVar{ Get: func(evalCtx *extendedEvalContext) (string, error) { return formatBoolAsPostgresSetting(true), nil }, - GlobalDefault: func(sv *settings.Values) string { - return formatBoolAsPostgresSetting(true) - }, + GlobalDefault: globalTrue, }, // CockroachDB extension. @@ -1684,9 +1676,7 @@ var varGen = map[string]sessionVar{ Get: func(evalCtx *extendedEvalContext) (string, error) { return formatBoolAsPostgresSetting(evalCtx.SessionData().NullOrderedLast), nil }, - GlobalDefault: func(sv *settings.Values) string { - return formatBoolAsPostgresSetting(false) - }, + GlobalDefault: globalFalse, }, `propagate_input_ordering`: {