-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
85922: sql: fix conflicting udf options validation r=chengxiong-ruan a=chengxiong-ruan A silly mistake that forgot to add option type to the map :( Release note: None Release justification: Fixing a bug that function options can be conflicting with each other. Also Fixing a bug that leakproof can be set for non-immutable function with ALTER FUNCTION 85963: backupccl: immediately process resume spans during backup r=dt a=stevendanna Previously, we put resume spans returned from an export request back on the queue for processing. In a large cluster with a lot of work to do, this might result in the resume span being processed much later. This isn't great because (1) it means we don't get to take advantage of disk and block caching and (2) it means that the resume span has a smaller chance of ending up in the same SST as the original span. Release justification: Low risk performance improvement. Release note: None Co-authored-by: Chengxiong Ruan <[email protected]> Co-authored-by: Steven Danna <[email protected]>
- Loading branch information
Showing
10 changed files
with
378 additions
and
202 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package tree_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestConflictingFunctionOptions(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
|
||
testCases := []struct { | ||
testName string | ||
options tree.FunctionOptions | ||
expectedErr string | ||
}{ | ||
{ | ||
testName: "no conflict", | ||
options: tree.FunctionOptions{ | ||
tree.FunctionVolatile, tree.FunctionLeakproof(true), tree.FunctionCalledOnNullInput, tree.FunctionLangSQL, tree.FunctionBodyStr("hi"), | ||
}, | ||
expectedErr: "", | ||
}, | ||
{ | ||
testName: "volatility conflict", | ||
options: tree.FunctionOptions{ | ||
tree.FunctionVolatile, tree.FunctionStable, | ||
}, | ||
expectedErr: "STABLE: conflicting or redundant options", | ||
}, | ||
{ | ||
testName: "null input behavior conflict 1", | ||
options: tree.FunctionOptions{ | ||
tree.FunctionCalledOnNullInput, tree.FunctionReturnsNullOnNullInput, | ||
}, | ||
expectedErr: "RETURNS NULL ON NULL INPUT: conflicting or redundant options", | ||
}, | ||
{ | ||
testName: "null input behavior conflict 2", | ||
options: tree.FunctionOptions{ | ||
tree.FunctionCalledOnNullInput, tree.FunctionStrict, | ||
}, | ||
expectedErr: "STRICT: conflicting or redundant options", | ||
}, | ||
{ | ||
testName: "leakproof conflict", | ||
options: tree.FunctionOptions{ | ||
tree.FunctionLeakproof(true), tree.FunctionLeakproof(false), | ||
}, | ||
expectedErr: "NOT LEAKPROOF: conflicting or redundant options", | ||
}, | ||
{ | ||
testName: "language conflict", | ||
options: tree.FunctionOptions{ | ||
tree.FunctionLangSQL, tree.FunctionLangSQL, | ||
}, | ||
expectedErr: "LANGUAGE SQL: conflicting or redundant options", | ||
}, | ||
{ | ||
testName: "function body conflict", | ||
options: tree.FunctionOptions{ | ||
tree.FunctionBodyStr("queries"), tree.FunctionBodyStr("others"), | ||
}, | ||
expectedErr: "AS $$others$$: conflicting or redundant options", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.testName, func(t *testing.T) { | ||
err := tree.ValidateFuncOptions(tc.options) | ||
if tc.expectedErr == "" { | ||
require.NoError(t, err) | ||
return | ||
} | ||
require.Equal(t, tc.expectedErr, err.Error()) | ||
}) | ||
} | ||
} |