Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
80459: sql/schemachanger: Implement comment on in declarative sc r=chengxiong-ruan a=chengxiong-ruan

Split out from cockroachdb#78025

This commit implements COMMENT ON with the new schema changer
framework.

Release note: None

81060: publish-{provisional,}-artifacts: create arm64 builds for non-release r=rail a=rickystewart

These new binaries will only be built for the non-release case.

Release note: None

Co-authored-by: Chengxiong Ruan <[email protected]>
Co-authored-by: Ricky Stewart <[email protected]>
  • Loading branch information
3 people committed May 5, 2022
3 parents 51c7020 + 006a842 + d1ce315 commit da04bc2
Show file tree
Hide file tree
Showing 45 changed files with 1,649 additions and 594 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/publish-artifacts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type runFlags struct {
}

func run(svc s3putter, flags runFlags, execFn release.ExecFn) {
for _, platform := range []release.Platform{release.PlatformLinux, release.PlatformMacOS, release.PlatformWindows} {
for _, platform := range []release.Platform{release.PlatformLinux, release.PlatformLinuxArm, release.PlatformMacOS, release.PlatformWindows} {
var o opts
o.Platform = platform
o.ReleaseVersionStrs = []string{flags.sha}
Expand Down
22 changes: 22 additions & 0 deletions pkg/cmd/publish-artifacts/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ func TestPublish(t *testing.T) {
"env=[] args=bazel info bazel-bin -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxbase",
"env=[MALLOC_CONF=prof:true] args=./cockroach.linux-2.6.32-gnu-amd64 version",
"env=[] args=ldd ./cockroach.linux-2.6.32-gnu-amd64",
"env=[] args=bazel build //pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql '--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu official-binary' -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"env=[] args=bazel info bazel-bin -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"env=[] args=bazel build //pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh x86_64-apple-darwin19 official-binary' -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crossmacosbase",
"env=[] args=bazel info bazel-bin -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crossmacosbase",
Expand Down Expand Up @@ -179,6 +181,26 @@ func TestPublish(t *testing.T) {
"'--workspace_status_command=./build/bazelutil/stamp.sh x86_64-pc-linux-gnu official-binary' " +
"-c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxbase",
"s3://cockroach/cockroach/lib/libgeos_c.linux-gnu-amd64.so.LATEST/no-cache REDIRECT /cockroach/lib/libgeos_c.linux-gnu-amd64.1234567890abcdef.so",
"s3://cockroach//cockroach/cockroach.linux-gnu-aarch64.1234567890abcdef CONTENTS env=[] args=bazel build " +
"//pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu official-binary' " +
"-c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"s3://cockroach/cockroach/cockroach.linux-gnu-aarch64.LATEST/no-cache REDIRECT /cockroach/cockroach.linux-gnu-aarch64.1234567890abcdef",
"s3://cockroach//cockroach/cockroach-sql.linux-gnu-aarch64.1234567890abcdef CONTENTS env=[] args=bazel build " +
"//pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu official-binary' " +
"-c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"s3://cockroach/cockroach/cockroach-sql.linux-gnu-aarch64.LATEST/no-cache REDIRECT /cockroach/cockroach-sql.linux-gnu-aarch64.1234567890abcdef",
"s3://cockroach//cockroach/lib/libgeos.linux-gnu-aarch64.1234567890abcdef.so CONTENTS env=[] args=bazel build " +
"//pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu official-binary' " +
"-c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"s3://cockroach/cockroach/lib/libgeos.linux-gnu-aarch64.so.LATEST/no-cache REDIRECT /cockroach/lib/libgeos.linux-gnu-aarch64.1234567890abcdef.so",
"s3://cockroach//cockroach/lib/libgeos_c.linux-gnu-aarch64.1234567890abcdef.so CONTENTS env=[] args=bazel build " +
"//pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu official-binary' " +
"-c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"s3://cockroach/cockroach/lib/libgeos_c.linux-gnu-aarch64.so.LATEST/no-cache REDIRECT /cockroach/lib/libgeos_c.linux-gnu-aarch64.1234567890abcdef.so",
"s3://cockroach//cockroach/cockroach.darwin-amd64.1234567890abcdef CONTENTS env=[] args=bazel build " +
"//pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh x86_64-apple-darwin19 official-binary' " +
Expand Down
6 changes: 5 additions & 1 deletion pkg/cmd/publish-provisional-artifacts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ func run(svc s3I, flags runFlags, execFn release.ExecFn) {
}
log.Printf("Using S3 bucket: %s", bucketName)

platforms := []release.Platform{release.PlatformLinux, release.PlatformMacOS, release.PlatformWindows}
if !flags.isRelease {
platforms = append(platforms, release.PlatformLinuxArm)
}
var cockroachBuildOpts []opts
for _, platform := range []release.Platform{release.PlatformLinux, release.PlatformMacOS, release.PlatformWindows} {
for _, platform := range platforms {
var o opts
o.Platform = platform
o.PkgDir = flags.pkgDir
Expand Down
19 changes: 19 additions & 0 deletions pkg/cmd/publish-provisional-artifacts/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ func TestProvisional(t *testing.T) {
"env=[] args=bazel build //pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh x86_64-w64-mingw32 official-binary' -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosswindowsbase",
"env=[] args=bazel info bazel-bin -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosswindowsbase",
"env=[] args=bazel build //pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu official-binary' -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"env=[] args=bazel info bazel-bin -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
},
expectedGets: nil,
expectedPuts: []string{
Expand Down Expand Up @@ -258,6 +261,22 @@ func TestProvisional(t *testing.T) {
"dll CONTENTS env=[] args=bazel build //pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh x86_64-w64-mingw32 official-binary' -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosswindowsbase",
"s3://cockroach/cockroach/lib/libgeos_c.windows-amd64.dll.LATEST/no-cache REDIRECT /cockroach/lib/libgeos_c.windows-amd64.00SHA00.dll",
"s3://cockroach//cockroach/cockroach.linux-gnu-aarch64.00SHA00 " +
"CONTENTS env=[] args=bazel build //pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp." +
"sh aarch64-unknown-linux-gnu official-binary' -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"s3://cockroach/cockroach/cockroach.linux-gnu-aarch64.LATEST/no-cache " +
"REDIRECT /cockroach/cockroach.linux-gnu-aarch64.00SHA00",
"s3://cockroach//cockroach/cockroach-sql.linux-gnu-aarch64.00SHA00 CONTENTS env=[] args=bazel build //pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql '--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu official-binary' -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"s3://cockroach/cockroach/cockroach-sql.linux-gnu-aarch64.LATEST/no-cache REDIRECT /cockroach/cockroach-sql.linux-gnu-aarch64.00SHA00",
"s3://cockroach//cockroach/lib/libgeos.linux-gnu-aarch64.00SHA00." +
"so CONTENTS env=[] args=bazel build //pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu official-binary' -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"s3://cockroach/cockroach/lib/libgeos.linux-gnu-aarch64.so.LATEST/no-cache REDIRECT /cockroach/lib/libgeos.linux-gnu-aarch64.00SHA00.so",
"s3://cockroach//cockroach/lib/libgeos_c.linux-gnu-aarch64.00SHA00." +
"so CONTENTS env=[] args=bazel build //pkg/cmd/cockroach //c-deps:libgeos //pkg/cmd/cockroach-sql " +
"'--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu official-binary' -c opt --config=ci --config=force_build_cdeps --config=with_ui --config=crosslinuxarmbase",
"s3://cockroach/cockroach/lib/libgeos_c.linux-gnu-aarch64.so.LATEST/no-cache REDIRECT /cockroach/lib/libgeos_c.linux-gnu-aarch64.00SHA00.so",
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/alter_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ func insertJSONStatistic(
}

func (p *planner) removeColumnComment(
ctx context.Context, tableID descpb.ID, columnID descpb.ColumnID,
ctx context.Context, tableID descpb.ID, pgAttributeNum descpb.PGAttributeNum,
) error {
_, err := p.ExtendedEvalContext().ExecCfg.InternalExecutor.ExecEx(
ctx,
Expand All @@ -1380,7 +1380,7 @@ func (p *planner) removeColumnComment(
"DELETE FROM system.comments WHERE type=$1 AND object_id=$2 AND sub_id=$3",
keys.ColumnCommentType,
tableID,
columnID)
pgAttributeNum)

return err
}
Expand Down Expand Up @@ -1783,7 +1783,7 @@ func dropColumnImpl(
}
}

if err := params.p.removeColumnComment(params.ctx, tableDesc.ID, colToDrop.GetID()); err != nil {
if err := params.p.removeColumnComment(params.ctx, tableDesc.ID, colToDrop.GetPGAttributeNum()); err != nil {
return nil, err
}

Expand Down
19 changes: 19 additions & 0 deletions pkg/sql/catalog/descpb/constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,22 @@ type ConstraintDetail struct {
// Only populated for Check Constraints.
CheckConstraint *TableDescriptor_CheckConstraint
}

// GetConstraintName retrieves correct constraint name base on the constraint
// type.
func (c *ConstraintDetail) GetConstraintName() string {
switch c.Kind {
case ConstraintTypePK:
return c.Index.Name
case ConstraintTypeUnique:
if c.Index != nil {
return c.Index.Name
}
return c.UniqueWithoutIndexConstraint.Name
case ConstraintTypeFK:
return c.FK.Name
case ConstraintTypeCheck:
return c.CheckConstraint.Name
}
return ""
}
2 changes: 2 additions & 0 deletions pkg/sql/catalog/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ type TableDescriptor interface {
GetConstraintInfoWithLookup(fn TableLookupFn) (map[string]descpb.ConstraintDetail, error)
// GetConstraintInfo returns a summary of all constraints on the table.
GetConstraintInfo() (map[string]descpb.ConstraintDetail, error)
// FindConstraintWithID returns a constraint given a constraint id.
FindConstraintWithID(id descpb.ConstraintID) (*descpb.ConstraintDetail, error)

// GetUniqueWithoutIndexConstraints returns all the unique constraints defined
// on this table that are not enforced by an index.
Expand Down
16 changes: 16 additions & 0 deletions pkg/sql/catalog/tabledesc/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,22 @@ func (desc *wrapper) GetConstraintInfo() (map[string]descpb.ConstraintDetail, er
return desc.collectConstraintInfo(nil)
}

// FindConstraintWithID implements the TableDescriptor interface.
func (desc *wrapper) FindConstraintWithID(
id descpb.ConstraintID,
) (*descpb.ConstraintDetail, error) {
constraintInfo, err := desc.GetConstraintInfo()
if err != nil {
return nil, err
}
for _, info := range constraintInfo {
if info.ConstraintID == id {
return &info, nil
}
}
return nil, nil
}

// GetConstraintInfoWithLookup implements the TableDescriptor interface.
func (desc *wrapper) GetConstraintInfoWithLookup(
tableLookup catalog.TableLookupFn,
Expand Down
Loading

0 comments on commit da04bc2

Please sign in to comment.