Skip to content

Commit

Permalink
Merge #74828
Browse files Browse the repository at this point in the history
74828: sql: support setting `check_function_bodies` r=rafiss a=otan

This commonly appears in dumps as noise for the actual problem (CREATE
FUNCTION doesn't work). This commit adds setting the variable, but we
don't do anything with it because we don't support UDFs.

Release note (sql change): Support setting `check_function_bodies`. Note
this doesn't variable doesn't do anything.

Co-authored-by: Oliver Tan <[email protected]>
  • Loading branch information
craig[bot] and otan committed Jan 19, 2022
2 parents 912964e + 5d58e67 commit d1eafdf
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2866,6 +2866,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 @@ -4142,6 +4143,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 @@ -4246,6 +4248,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 @@ -660,6 +660,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 @@ -1088,6 +1088,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

0 comments on commit d1eafdf

Please sign in to comment.