Skip to content

Commit 3160bcf

Browse files
craig[bot]yuzefovich
craig[bot]
andcommitted
Merge #77260
77260: types: remove no longer used version gate r=yuzefovich a=yuzefovich This is done to break the dependency of `sql/types` on `roachpb` (which is a part of the effort to clean up the dependencies of `execgen`). This commit brings the dependencies of `execgen` to a much more reasonable set. Although there is an ask in place to not remove this code even if it's not used at the moment (so that we have the necessary infra in place if/when the need arises), in order to keep the functionality we would need to pull out `roachpb.Version` out of `roachpb`, and I don't want to embark on that since we're in stability period. Fixes: #77234. Release note: None Release justification: low risk change to clean up the dependencies. Co-authored-by: Yahor Yuzefovich <[email protected]>
2 parents 0e1edf3 + f09a36d commit 3160bcf

12 files changed

+70
-131
lines changed

pkg/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ ALL_TESTS = [
243243
"//pkg/sql/colexec/colexectestutils:colexectestutils_test",
244244
"//pkg/sql/colexec/colexecutils:colexecutils_test",
245245
"//pkg/sql/colexec/colexecwindow:colexecwindow_test",
246+
"//pkg/sql/colexec/execgen/cmd/execgen:execgen_test",
246247
"//pkg/sql/colexec/execgen:execgen_test",
247248
"//pkg/sql/colexec:colexec_test",
248249
"//pkg/sql/colexecerror:colexecerror_test",

pkg/sql/add_column.go

-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ func (p *planner) addColumnImpl(
4949
)
5050
}
5151

52-
if err := checkTypeIsSupported(params.ctx, params.ExecCfg().Settings, toType); err != nil {
53-
return err
54-
}
55-
5652
var colOwnedSeqDesc *tabledesc.Mutable
5753
newDef, seqPrefix, seqName, seqOpts, err := params.p.processSerialLikeInColumnDef(params.ctx, d, tn)
5854
if err != nil {

pkg/sql/alter_column_type.go

-4
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ func AlterColumnType(
8282
return err
8383
}
8484

85-
if err := checkTypeIsSupported(ctx, params.ExecCfg().Settings, typ); err != nil {
86-
return err
87-
}
88-
8985
// Special handling for STRING COLLATE xy to verify that we recognize the language.
9086
if t.Collation != "" {
9187
if types.IsStringType(typ) {

pkg/sql/colexec/dep_test.go

-8
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,4 @@ func TestNoLinkForbidden(t *testing.T) {
3030
"github.com/cockroachdb/cockroach/pkg/sql/rowflow",
3131
}, nil,
3232
)
33-
buildutil.VerifyNoImports(t,
34-
"github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen/cmd/execgen", true,
35-
[]string{
36-
"github.com/cockroachdb/cockroach/pkg/sql/catalog",
37-
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb",
38-
"github.com/cockroachdb/cockroach/pkg/sql/tree",
39-
}, nil,
40-
)
4133
}

pkg/sql/colexec/execgen/cmd/execgen/BUILD.bazel

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
1+
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
22

33
go_library(
44
name = "execgen_lib",
@@ -83,3 +83,10 @@ go_binary(
8383
embed = [":execgen_lib"],
8484
visibility = ["//visibility:public"],
8585
)
86+
87+
go_test(
88+
name = "execgen_test",
89+
srcs = ["dep_test.go"],
90+
embed = [":execgen_lib"],
91+
deps = ["//pkg/testutils/buildutil"],
92+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2022 The Cockroach Authors.
2+
//
3+
// Use of this software is governed by the Business Source License
4+
// included in the file licenses/BSL.txt.
5+
//
6+
// As of the Change Date specified in that file, in accordance with
7+
// the Business Source License, use of this software will be governed
8+
// by the Apache License, Version 2.0, included in the file
9+
// licenses/APL.txt.
10+
11+
package main
12+
13+
import (
14+
"testing"
15+
16+
"github.com/cockroachdb/cockroach/pkg/testutils/buildutil"
17+
)
18+
19+
func TestNoLinkForbidden(t *testing.T) {
20+
buildutil.VerifyNoImports(t,
21+
"github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen/cmd/execgen", true,
22+
[]string{
23+
"github.com/cockroachdb/cockroach/pkg/roachpb",
24+
"github.com/cockroachdb/cockroach/pkg/sql/catalog",
25+
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb",
26+
"github.com/cockroachdb/cockroach/pkg/sql/tree",
27+
}, nil,
28+
)
29+
}

pkg/sql/create_table.go

-15
Original file line numberDiff line numberDiff line change
@@ -1533,9 +1533,6 @@ func NewTableDesc(
15331533
)
15341534
}
15351535
}
1536-
if err := checkTypeIsSupported(ctx, st, defType); err != nil {
1537-
return nil, err
1538-
}
15391536
if d.PrimaryKey.Sharded {
15401537
if n.PartitionByTable.ContainsPartitions() && !n.PartitionByTable.All {
15411538
return nil, pgerror.New(pgcode.FeatureNotSupported, "hash sharded indexes cannot be explicitly partitioned")
@@ -2777,18 +2774,6 @@ func regionalByRowDefaultColDef(
27772774
return c
27782775
}
27792776

2780-
func checkTypeIsSupported(ctx context.Context, settings *cluster.Settings, typ *types.T) error {
2781-
version := settings.Version.ActiveVersionOrEmpty(ctx)
2782-
if supported := types.IsTypeSupportedInVersion(version, typ); !supported {
2783-
return pgerror.Newf(
2784-
pgcode.FeatureNotSupported,
2785-
"type %s is not supported until version upgrade is finalized",
2786-
typ.SQLString(),
2787-
)
2788-
}
2789-
return nil
2790-
}
2791-
27922777
// setSequenceOwner adds sequence id to the sequence id list owned by a column
27932778
// and set ownership values of sequence options.
27942779
func setSequenceOwner(

pkg/sql/schemachanger/scbuild/builder_state.go

+3-13
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
package scbuild
1212

1313
import (
14-
"context"
1514
"strings"
1615

1716
"github.com/cockroachdb/cockroach/pkg/keys"
18-
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
1917
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
2018
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catconstants"
2119
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catpb"
@@ -298,18 +296,10 @@ func (b *builderState) ResolveTypeRef(ref tree.ResolvableTypeReference) scpb.Typ
298296
if err != nil {
299297
panic(err)
300298
}
301-
return newTypeT(b.ctx, b.clusterSettings, toType)
299+
return newTypeT(toType)
302300
}
303301

304-
func newTypeT(ctx context.Context, settings *cluster.Settings, t *types.T) scpb.TypeT {
305-
version := settings.Version.ActiveVersionOrEmpty(ctx)
306-
supported := types.IsTypeSupportedInVersion(version, t)
307-
if !supported {
308-
panic(pgerror.Newf(pgcode.FeatureNotSupported,
309-
"type %s is not supported until version upgrade is finalized", t.SQLString(),
310-
))
311-
}
312-
302+
func newTypeT(t *types.T) scpb.TypeT {
313303
m, err := typedesc.GetTypeDescriptorClosure(t)
314304
if err != nil {
315305
panic(err)
@@ -416,7 +406,7 @@ func (b *builderState) ComputedColumnExpression(
416406
if err != nil {
417407
panic(err)
418408
}
419-
return parsedExpr, newTypeT(b.ctx, b.clusterSettings, typ)
409+
return parsedExpr, newTypeT(typ)
420410
}
421411

422412
var _ scbuildstmt.ElementReferences = (*builderState)(nil)

pkg/sql/types/BUILD.bazel

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ go_library(
66
name = "types",
77
srcs = [
88
"alias.go",
9-
"minimum_type_version.go",
109
"oid.go",
1110
"testutils.go",
1211
"types.go",
@@ -16,7 +15,6 @@ go_library(
1615
importpath = "github.com/cockroachdb/cockroach/pkg/sql/types",
1716
visibility = ["//visibility:public"],
1817
deps = [
19-
"//pkg/clusterversion",
2018
"//pkg/geo/geopb",
2119
"//pkg/sql/lex",
2220
"//pkg/sql/oidext",
@@ -35,19 +33,17 @@ go_test(
3533
name = "types_test",
3634
size = "small",
3735
srcs = [
38-
"minimum_type_version_test.go",
36+
"dep_test.go",
3937
"types_test.go",
4038
"types_text_marshal_test.go",
4139
],
4240
embed = [":types"],
4341
deps = [
44-
"//pkg/clusterversion",
4542
"//pkg/geo/geopb",
4643
"//pkg/sql/catalog/descpb",
4744
"//pkg/sql/catalog/typedesc",
4845
"//pkg/sql/oidext",
49-
"//pkg/util/leaktest",
50-
"//pkg/util/log",
46+
"//pkg/testutils/buildutil",
5147
"//pkg/util/protoutil",
5248
"@com_github_lib_pq//oid",
5349
"@com_github_stretchr_testify//assert",

pkg/sql/types/dep_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2022 The Cockroach Authors.
2+
//
3+
// Use of this software is governed by the Business Source License
4+
// included in the file licenses/BSL.txt.
5+
//
6+
// As of the Change Date specified in that file, in accordance with
7+
// the Business Source License, use of this software will be governed
8+
// by the Apache License, Version 2.0, included in the file
9+
// licenses/APL.txt.
10+
11+
package types
12+
13+
import (
14+
"testing"
15+
16+
"github.com/cockroachdb/cockroach/pkg/testutils/buildutil"
17+
)
18+
19+
func TestNoLinkForbidden(t *testing.T) {
20+
buildutil.VerifyNoImports(t,
21+
"github.com/cockroachdb/cockroach/pkg/sql/types", true,
22+
[]string{
23+
"github.com/cockroachdb/cockroach/pkg/clusterversion",
24+
"github.com/cockroachdb/cockroach/pkg/roachpb",
25+
}, nil,
26+
)
27+
}

pkg/sql/types/minimum_type_version.go

-34
This file was deleted.

pkg/sql/types/minimum_type_version_test.go

-46
This file was deleted.

0 commit comments

Comments
 (0)