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: support setting check_function_bodies #74828

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2859,6 +2859,10 @@ func (m *sessionDataMutator) SetSafeUpdates(val bool) {
m.data.SafeUpdates = val
}

func (m *sessionDataMutator) SetCheckFunctionBodies(val bool) {
m.data.CheckFunctionBodies = val
}

func (m *sessionDataMutator) SetPreferLookupJoinsForFKs(val bool) {
m.data.PreferLookupJoinsForFKs = val
}
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/logictest/testdata/logic_test/information_schema
Original file line number Diff line number Diff line change
Expand Up @@ -4625,6 +4625,7 @@ application_name ·
avoid_buffering off
backslash_quote safe_encoding
bytea_output hex
check_function_bodies on
client_encoding UTF8
client_min_messages notice
database test
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -4032,6 +4032,7 @@ application_name · NULL
avoid_buffering off NULL NULL NULL string
backslash_quote safe_encoding NULL NULL NULL string
bytea_output hex NULL NULL NULL string
check_function_bodies on NULL NULL NULL string
client_encoding UTF8 NULL NULL NULL string
client_min_messages notice NULL NULL NULL string
database test NULL NULL NULL string
Expand Down Expand Up @@ -4141,6 +4142,7 @@ application_name · NULL
avoid_buffering off NULL user NULL false false
backslash_quote safe_encoding NULL user NULL safe_encoding safe_encoding
bytea_output hex NULL user NULL hex hex
check_function_bodies on NULL user NULL on on
client_encoding UTF8 NULL user NULL UTF8 UTF8
client_min_messages notice NULL user NULL notice notice
database test NULL user NULL · test
Expand Down Expand Up @@ -4244,6 +4246,7 @@ application_name NULL NULL NULL
avoid_buffering NULL NULL NULL NULL NULL
backslash_quote NULL NULL NULL NULL NULL
bytea_output NULL NULL NULL NULL NULL
check_function_bodies NULL NULL NULL NULL NULL
client_encoding NULL NULL NULL NULL NULL
client_min_messages NULL NULL NULL NULL NULL
crdb_version NULL NULL NULL NULL NULL
Expand Down
18 changes: 18 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/set
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,24 @@ SET LC_NUMERIC = 'en_US.UTF-8'
statement error invalid value for parameter "lc_time": "en_US.UTF-8"
SET LC_TIME = 'en_US.UTF-8'

subtest check_function_bodies_test

statement ok
SET check_function_bodies = true

query T
SHOW check_function_bodies
----
on

statement ok
SET check_function_bodies = false

query T
SHOW check_function_bodies
----
off

# Test custom session variables

statement ok
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/logictest/testdata/logic_test/show_source
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ application_name ·
avoid_buffering off
backslash_quote safe_encoding
bytea_output hex
check_function_bodies on
client_encoding UTF8
client_min_messages notice
database test
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/sessiondatapb/local_only_session_data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ message LocalOnlySessionData {
// buffered by conn executor. This is currently used by replication primitives
// to ensure the data is flushed to the consumer immediately.
bool avoid_buffering = 59;
// CheckFunctionBodies indicates whether functions are validated during
// creation.
bool check_function_bodies = 60;

///////////////////////////////////////////////////////////////////////////
// WARNING: consider whether a session parameter you're adding needs to //
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/unsupported_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var UnsupportedVars = func(ss ...string) map[string]struct{} {
"array_nulls",
"backend_flush_after",
// "bytea_output",
"check_function_bodies",
// "check_function_bodies",
// "client_encoding",
// "client_min_messages",
"commit_delay",
Expand Down
17 changes: 17 additions & 0 deletions pkg/sql/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,23 @@ var varGen = map[string]sessionVar{
GlobalDefault: globalFalse,
},

// See https://www.postgresql.org/docs/13/runtime-config-client.html.
`check_function_bodies`: {
Get: func(evalCtx *extendedEvalContext) (string, error) {
return formatBoolAsPostgresSetting(evalCtx.SessionData().CheckFunctionBodies), nil
},
GetStringVal: makePostgresBoolGetStringValFn("check_function_bodies"),
Set: func(_ context.Context, m sessionDataMutator, s string) error {
b, err := paramparse.ParseBoolVar("check_function_bodies", s)
if err != nil {
return err
}
m.SetCheckFunctionBodies(b)
return nil
},
GlobalDefault: globalTrue,
},

// CockroachDB extension.
`prefer_lookup_joins_for_fks`: {
Get: func(evalCtx *extendedEvalContext) (string, error) {
Expand Down