Skip to content

Commit 6f42039

Browse files
craig[bot]DrewKimballrickystewartyuzefovich
committed
105582: opt: check that generator functions are not used in CASE or COALESCE r=DrewKimball a=DrewKimball #### opt: check that generator functions are not used in CASE or COALESCE This patch adds checks during type-checking to ensure that generator functions are not used in the arguments of `CASE`, `IF`, `COALESCE`, or `IFNULL` expressions. This mirrors postgres behavior. This patch also corrects the error message that is returned in these cases to say "set-returning" instead of "generator". Fixes cockroachdb#97119 Fixes cockroachdb#94890 Release note (bug fix): CASE, IF, COALESCE, and IFNULL expressions now return an error when passed a generator function as an argument. This mirrors postgres behavior. 106944: bazel,dev: in `dev`, handle different `--compilation_mode`s correctly... r=rail a=rickystewart ... and switch our default compilation mode to `dbg`. Under `fastbuild`, built binaries are stripped. This is not the case with `dbg`. Have `dev doctor` recommend using `dbg`, and either way make `dev` resilient to whatever kind of `--compilation_mode` you're using. In principle or theory `dbg` is slower than `fastbuild`, but for the Go compiler it generates debuggable binaries by default and you have to opt-in to stripping, so it shoould make no real difference. Now, we think of the `--compilation_mode` simply as follows: `dbg` is the default that everyone is opted into by default unless they explicitly set `-c opt` (we use this for release). For now I don't see a reason anyone would need `fastbuild`. Epic: CRDB-17171 Release note: None Closes: cockroachdb#106820 107086: server: minor improvement around TestTenantInterface r=yuzefovich a=yuzefovich Addresses: cockroachdb#76378. Fixes: cockroachdb#106903. Co-authored-by: Drew Kimball <[email protected]> Co-authored-by: Ricky Stewart <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]>
4 parents 25855ac + 5cc456b + 60e8bce + dc6b2dc commit 6f42039

File tree

35 files changed

+310
-183
lines changed

35 files changed

+310
-183
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ build --define gotags=bazel,gss
3636
build --experimental_proto_descriptor_sets_include_source_info
3737
build --incompatible_strict_action_env --incompatible_enable_cc_toolchain_resolution
3838
build --symlink_prefix=_bazel/
39+
build -c dbg
3940
common --experimental_allow_tags_propagation
4041
test --config=test --experimental_ui_max_stdouterr_bytes=10485760
4142
build --ui_event_filters=-DEBUG

build/teamcity/cockroach/ci/builds/build_impl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fi
3838

3939
bazel build //pkg/cmd/bazci --config=ci
4040
BAZEL_BIN=$(bazel info bazel-bin --config=ci)
41-
"$BAZEL_BIN/pkg/cmd/bazci/bazci_/bazci" -- build -c opt \
41+
"$BAZEL_BIN/pkg/cmd/bazci/bazci_/bazci" -- build \
4242
--config "$CONFIG" --config ci $EXTRA_ARGS \
4343
//pkg/cmd/cockroach-short //pkg/cmd/cockroach \
4444
//pkg/cmd/cockroach-sql \

build/teamcity/cockroach/nightlies/pebble_nightly_common.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ mkdir -p "$PWD/bin"
2727
chmod o+rwx "$PWD/bin"
2828

2929
# Build the roachtest binary.
30-
bazel build //pkg/cmd/roachtest --config ci -c opt
31-
BAZEL_BIN=$(bazel info bazel-bin --config ci -c opt)
30+
bazel build //pkg/cmd/roachtest --config ci
31+
BAZEL_BIN=$(bazel info bazel-bin --config ci)
3232
cp $BAZEL_BIN/pkg/cmd/roachtest/roachtest_/roachtest bin
3333
chmod a+w bin/roachtest
3434

@@ -39,8 +39,8 @@ chmod a+w bin/roachtest
3939
bazel run @go_sdk//:bin/go get github.com/cockroachdb/pebble@latest
4040
NEW_DEPS_BZL_CONTENT=$(bazel run //pkg/cmd/mirror/go:mirror)
4141
echo "$NEW_DEPS_BZL_CONTENT" > DEPS.bzl
42-
bazel build @com_github_cockroachdb_pebble//cmd/pebble --config ci -c opt
43-
BAZEL_BIN=$(bazel info bazel-bin --config ci -c opt)
42+
bazel build @com_github_cockroachdb_pebble//cmd/pebble --config ci
43+
BAZEL_BIN=$(bazel info bazel-bin --config ci)
4444
cp $BAZEL_BIN/external/com_github_cockroachdb_pebble/cmd/pebble/pebble_/pebble ./pebble.linux
4545
chmod a+w ./pebble.linux
4646

@@ -67,8 +67,8 @@ function prepare_datadir() {
6767
# Build the mkbench tool from within the Pebble repo. This is used to parse
6868
# the benchmark data.
6969
function build_mkbench() {
70-
bazel build @com_github_cockroachdb_pebble//internal/mkbench --config ci -c opt
71-
BAZEL_BIN=$(bazel info bazel-bin --config ci -c opt)
70+
bazel build @com_github_cockroachdb_pebble//internal/mkbench --config ci
71+
BAZEL_BIN=$(bazel info bazel-bin --config ci)
7272
cp $BAZEL_BIN/external/com_github_cockroachdb_pebble/internal/mkbench/mkbench_/mkbench .
7373
chmod a+w mkbench
7474
}

build/teamcity/cockroach/nightlies/pebble_nightly_race_common.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ mkdir -p "$PWD/bin"
2727
chmod o+rwx "$PWD/bin"
2828

2929
# Build the roachtest binary.
30-
bazel build //pkg/cmd/roachtest --config ci -c opt
31-
BAZEL_BIN=$(bazel info bazel-bin --config ci -c opt)
30+
bazel build //pkg/cmd/roachtest --config ci
31+
BAZEL_BIN=$(bazel info bazel-bin --config ci)
3232
cp $BAZEL_BIN/pkg/cmd/roachtest/roachtest_/roachtest bin
3333
chmod a+w bin/roachtest
3434

@@ -39,8 +39,8 @@ chmod a+w bin/roachtest
3939
bazel run @go_sdk//:bin/go get github.com/cockroachdb/pebble@latest
4040
NEW_DEPS_BZL_CONTENT=$(bazel run //pkg/cmd/mirror/go:mirror)
4141
echo "$NEW_DEPS_BZL_CONTENT" > DEPS.bzl
42-
bazel build @com_github_cockroachdb_pebble//cmd/pebble --config race --config ci -c opt
43-
BAZEL_BIN=$(bazel info bazel-bin --config race --config ci -c opt)
42+
bazel build @com_github_cockroachdb_pebble//cmd/pebble --config race --config ci
43+
BAZEL_BIN=$(bazel info bazel-bin --config race --config ci)
4444
cp $BAZEL_BIN/external/com_github_cockroachdb_pebble/cmd/pebble/pebble_/pebble ./pebble.linux
4545
chmod a+w ./pebble.linux
4646

build/teamcity/cockroach/nightlies/roachtest_compile_bits.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ for platform in "${cross_builds[@]}"; do
3535

3636
echo "Building $platform, os=$os, arch=$arch..."
3737
# Build cockroach, workload and geos libs.
38-
bazel build --config $platform --config ci -c opt --config force_build_cdeps \
38+
bazel build --config $platform --config ci --config force_build_cdeps \
3939
//pkg/cmd/cockroach //pkg/cmd/workload \
4040
//c-deps:libgeos
41-
BAZEL_BIN=$(bazel info bazel-bin --config $platform --config ci -c opt)
41+
BAZEL_BIN=$(bazel info bazel-bin --config $platform --config ci)
4242

4343
# N.B. roachtest is built once, for the host architecture.
4444
if [[ $os == "linux" && $arch == $host_arch ]]; then
45-
bazel build --config $platform --config ci -c opt //pkg/cmd/roachtest
45+
bazel build --config $platform --config ci //pkg/cmd/roachtest
4646

4747
cp $BAZEL_BIN/pkg/cmd/roachtest/roachtest_/roachtest bin/roachtest
4848
# Make it writable to simplify cleanup and copying (e.g., scp retry).
4949
chmod a+w bin/roachtest
5050
fi
5151
# Build cockroach-short with assertions enabled.
52-
bazel build --config $platform --config ci -c opt //pkg/cmd/cockroach-short --crdb_test
52+
bazel build --config $platform --config ci //pkg/cmd/cockroach-short --crdb_test
5353
# Copy the binaries.
5454
cp $BAZEL_BIN/pkg/cmd/cockroach/cockroach_/cockroach bin/cockroach.$os-$arch
5555
cp $BAZEL_BIN/pkg/cmd/workload/workload_/workload bin/workload.$os-$arch

build/toolchains/BUILD.bazel

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,6 @@ config_setting(
404404
},
405405
)
406406

407-
config_setting(
408-
name = "opt",
409-
values = {
410-
"compilation_mode": "opt",
411-
},
412-
)
413-
414407
bool_flag(
415408
name = "nogo_flag",
416409
build_setting_default = False,

dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fi
88
set -euo pipefail
99

1010
# Bump this counter to force rebuilding `dev` on all machines.
11-
DEV_VERSION=79
11+
DEV_VERSION=80
1212

1313
THIS_DIR=$(cd "$(dirname "$0")" && pwd)
1414
BINARY_DIR=$THIS_DIR/bin/dev-versions

pkg/ccl/serverccl/role_authentication_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ func TestVerifyPassword(t *testing.T) {
3333
defer log.Scope(t).Close(t)
3434

3535
ctx := context.Background()
36-
s, db, _ := serverutils.StartServer(t,
37-
base.TestServerArgs{
38-
// One of the sub-tests fails.
39-
DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(106903),
40-
},
41-
)
36+
s, db, _ := serverutils.StartServer(t, base.TestServerArgs{})
4237
defer s.Stopper().Stop(ctx)
4338

4439
ts := s.TenantOrServer()
@@ -145,7 +140,7 @@ func TestVerifyPassword(t *testing.T) {
145140
{"user with VALID UNTIL NULL should succeed", "cthon98", "12345", false, false, true, true},
146141
} {
147142
t.Run(tc.testName, func(t *testing.T) {
148-
execCfg := s.ExecutorConfig().(sql.ExecutorConfig)
143+
execCfg := ts.ExecutorConfig().(sql.ExecutorConfig)
149144
username := username.MakeSQLUsernameFromPreNormalizedString(tc.username)
150145
exists, canLoginSQL, canLoginDBConsole, canUseReplicationMode, isSuperuser, _, pwRetrieveFn, err := sql.GetUserSessionInitInfo(
151146
context.Background(), &execCfg, username, "", /* databaseName */

pkg/cmd/dev/build.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ func (d *dev) build(cmd *cobra.Command, commandLine []string) error {
170170
return err
171171
}
172172
args = append(args, additionalBazelArgs...)
173+
configArgs := getConfigArgs(args)
174+
configArgs = append(configArgs, getConfigArgs(additionalBazelArgs)...)
173175

174176
if cross == "" {
175177
// Do not log --build_event_binary_file=... because it is not relevant to the actual call
@@ -183,7 +185,7 @@ func (d *dev) build(cmd *cobra.Command, commandLine []string) error {
183185
if err := d.exec.CommandContextInheritingStdStreams(ctx, "bazel", args...); err != nil {
184186
return err
185187
}
186-
return d.stageArtifacts(ctx, buildTargets)
188+
return d.stageArtifacts(ctx, buildTargets, configArgs)
187189
}
188190
volume := mustGetFlagString(cmd, volumeFlag)
189191
cross = "cross" + cross
@@ -252,7 +254,9 @@ func (d *dev) crossBuild(
252254
return err
253255
}
254256

255-
func (d *dev) stageArtifacts(ctx context.Context, targets []buildTarget) error {
257+
func (d *dev) stageArtifacts(
258+
ctx context.Context, targets []buildTarget, configArgs []string,
259+
) error {
256260
workspace, err := d.getWorkspace(ctx)
257261
if err != nil {
258262
return err
@@ -261,7 +265,7 @@ func (d *dev) stageArtifacts(ctx context.Context, targets []buildTarget) error {
261265
if err = d.os.MkdirAll(path.Join(workspace, "bin")); err != nil {
262266
return err
263267
}
264-
bazelBin, err := d.getBazelBin(ctx)
268+
bazelBin, err := d.getBazelBin(ctx, configArgs)
265269
if err != nil {
266270
return err
267271
}
@@ -453,11 +457,19 @@ func (d *dev) getBasicBuildArgs(
453457
return args, buildTargets, nil
454458
}
455459

456-
// Given a list of Bazel arguments, find the ones starting with --config= and
457-
// return them.
460+
// Given a list of Bazel arguments, find the ones that represent a "config"
461+
// (either --config or -c) and return all of these. This is used to find
462+
// the appropriate bazel-bin for any invocation.
458463
func getConfigArgs(args []string) (ret []string) {
464+
var addNext bool
459465
for _, arg := range args {
460-
if strings.HasPrefix(arg, "--config=") {
466+
if addNext {
467+
ret = append(ret, arg)
468+
addNext = false
469+
} else if arg == "--config" || arg == "--compilation_mode" || arg == "-c" {
470+
ret = append(ret, arg)
471+
addNext = true
472+
} else if strings.HasPrefix(arg, "--config=") || strings.HasPrefix(arg, "--compilation_mode=") {
461473
ret = append(ret, arg)
462474
}
463475
}

pkg/cmd/dev/doctor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ func (d *dev) doctor(cmd *cobra.Command, _ []string) error {
503503
if err != nil {
504504
return err
505505
}
506-
bazelBin, err := d.getBazelBin(ctx)
506+
bazelBin, err := d.getBazelBin(ctx, []string{})
507507
if err != nil {
508508
return err
509509
}

0 commit comments

Comments
 (0)