Skip to content

Commit

Permalink
Merge #97760
Browse files Browse the repository at this point in the history
97760: sql: remove CREATE FUNCTION 22.2 version gate r=chengxiong-ruan a=chengxiong-ruan

Informs: #96763, #96751

Release note: None.

Co-authored-by: Chengxiong Ruan <[email protected]>
  • Loading branch information
craig[bot] and chengxiong-ruan committed Feb 28, 2023
2 parents 5f34f44 + 0d6452e commit 227aad0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 50 deletions.
12 changes: 0 additions & 12 deletions pkg/sql/create_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"context"
"fmt"

"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catpb"
Expand Down Expand Up @@ -44,17 +43,6 @@ type createFunctionNode struct {
func (n *createFunctionNode) ReadingOwnWrites() {}

func (n *createFunctionNode) startExec(params runParams) error {
if !params.EvalContext().Settings.Version.IsActive(
params.ctx,
clusterversion.TODODelete_V22_2SchemaChangeSupportsCreateFunction,
) {
// TODO(chengxiong): remove this version gate in 23.1.
return pgerror.Newf(
pgcode.FeatureNotSupported,
"cannot run CREATE FUNCTION before system is fully upgraded to v22.2",
)
}

if n.cf.RoutineBody != nil {
return unimplemented.NewWithIssue(85144, "CREATE FUNCTION...sql_body unimplemented")
}
Expand Down
38 changes: 0 additions & 38 deletions pkg/sql/create_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/tests"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
Expand Down Expand Up @@ -153,43 +152,6 @@ SELECT nextval(105:::REGCLASS);`,
require.NoError(t, err)
}

func TestGatingCreateFunction(t *testing.T) {
defer leaktest.AfterTest(t)()

skip.WithIssue(t, 95530, "bump minBinary to 22.2. Skip 22.2 mixed-version tests for future cleanup")

t.Run("new_schema_changer_version_enabled", func(t *testing.T) {
params, _ := tests.CreateTestServerParams()
// Override binary version to be older.
params.Knobs.Server = &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: clusterversion.ByKey(clusterversion.TODODelete_V22_2SchemaChangeSupportsCreateFunction),
}

s, sqlDB, _ := serverutils.StartServer(t, params)
defer s.Stopper().Stop(context.Background())

_, err := sqlDB.Exec(`CREATE FUNCTION f() RETURNS INT LANGUAGE SQL AS $$ SELECT 1 $$`)
require.NoError(t, err)
})

t.Run("new_schema_changer_version_disabled", func(t *testing.T) {
params, _ := tests.CreateTestServerParams()
// Override binary version to be older.
params.Knobs.Server = &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: clusterversion.ByKey(clusterversion.TODODelete_V22_2SchemaChangeSupportsCreateFunction - 1),
}

s, sqlDB, _ := serverutils.StartServer(t, params)
defer s.Stopper().Stop(context.Background())

_, err := sqlDB.Exec(`CREATE FUNCTION f() RETURNS INT LANGUAGE SQL AS $$ SELECT 1 $$`)
require.Error(t, err)
require.Equal(t, "pq: cannot run CREATE FUNCTION before system is fully upgraded to v22.2", err.Error())
})
}

func TestVersionGatingUDFInCheckConstraints(t *testing.T) {
defer leaktest.AfterTest(t)()

Expand Down

0 comments on commit 227aad0

Please sign in to comment.