Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
110396: sql: add support for foreign key cascades in udfs r=rharding6373 a=rharding6373

This commit adds testing and makes some fixes to support foreign key cascades in UDFs.

Epic: CRDB-25388
Informs: #87289

Release note: none

110925: dev: add support for `podman` r=healthy-pod a=rickystewart

Part of: DEVINF-522

Epic: none
Release note: None

110978: catpb: make JobID implement fmt.Stringer r=yuzefovich a=yuzefovich

This will make some things nicer (e.g. in roachtest/tests/jobs.go we used %s format directive).

Touches: #110782.

Epic: None

Release note: None

Co-authored-by: rharding6373 <[email protected]>
Co-authored-by: Ricky Stewart <[email protected]>
Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
4 people committed Sep 20, 2023
4 parents 81b6149 + eb09145 + c0c5de7 + 7ea7df0 commit 2a90855
Show file tree
Hide file tree
Showing 8 changed files with 436 additions and 26 deletions.
2 changes: 1 addition & 1 deletion dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi
set -euo pipefail

# Bump this counter to force rebuilding `dev` on all machines.
DEV_VERSION=86
DEV_VERSION=87

THIS_DIR=$(cd "$(dirname "$0")" && pwd)
BINARY_DIR=$THIS_DIR/bin/dev-versions
Expand Down
19 changes: 19 additions & 0 deletions pkg/cmd/dev/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package main

import (
"bytes"
"context"
"fmt"
"log"
Expand Down Expand Up @@ -56,6 +57,17 @@ func (d *dev) builder(cmd *cobra.Command, extraArgs []string) error {
return d.exec.CommandContextInheritingStdStreams(ctx, "docker", args...)
}

func (d *dev) dockerIsPodman(ctx context.Context) (bool, error) {
output, err := d.exec.CommandContextSilent(ctx, "docker", "help")
if err != nil {
return false, err
}
if bytes.Contains(output, []byte("podman")) {
return true, nil
}
return false, nil
}

func (d *dev) getDockerRunArgs(
ctx context.Context, volume string, tty bool, extraArgs []string,
) (args []string, err error) {
Expand Down Expand Up @@ -119,6 +131,13 @@ func (d *dev) getDockerRunArgs(
}

args = append(args, "run", "--rm")
isPodman, err := d.dockerIsPodman(ctx)
if err != nil {
return nil, err
}
if isPodman {
args = append(args, "--passwd=false")
}
if tty {
args = append(args, "-it")
} else {
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/dev/testdata/recorderdriven/builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ id
bazel info workspace --color=no
cat crdb-checkout/build/.bazelbuilderversion
docker volume inspect bzlhome
docker help
mkdir crdb-checkout/artifacts
chmod crdb-checkout/artifacts 0777
docker run --rm -it -v crdb-checkout:/cockroach --workdir=/cockroach -v crdb-checkout/build/bazelutil/empty.bazelrc:/cockroach/.bazelrc.user -v crdb-checkout/artifacts:/artifacts -v bzlhome:/home/roach:delegated -u 502:502 cockroachdb/bazel:20220328-163955
Expand All @@ -16,6 +17,7 @@ id
bazel info workspace --color=no
cat crdb-checkout/build/.bazelbuilderversion
docker volume inspect bzlhome
docker help
mkdir crdb-checkout/artifacts
chmod crdb-checkout/artifacts 0777
docker run --rm -i -v crdb-checkout:/cockroach --workdir=/cockroach -v crdb-checkout/build/bazelutil/empty.bazelrc:/cockroach/.bazelrc.user -v crdb-checkout/artifacts:/artifacts -v bzlhome:/home/roach:delegated -u 502:502 cockroachdb/bazel:20220328-163955 echo hi
6 changes: 6 additions & 0 deletions pkg/cmd/dev/testdata/recorderdriven/builder.rec
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ docker volume inspect bzlhome
}
]

docker help
----

mkdir crdb-checkout/artifacts
----

Expand Down Expand Up @@ -65,6 +68,9 @@ docker volume inspect bzlhome
}
]

docker help
----

mkdir crdb-checkout/artifacts
----

Expand Down
12 changes: 11 additions & 1 deletion pkg/sql/apply_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func runPlanInsidePlan(

plannerCopy := *params.p
plannerCopy.curPlan.planComponents = *plan

// "Pausable portal" execution model is only applicable to the outer
// statement since we actually need to execute all inner plans to completion
// before we can produce any "outer" rows to be returned to the client, so
Expand Down Expand Up @@ -333,6 +334,12 @@ func runPlanInsidePlan(
// We don't have "inner" subqueries, so the apply join can only refer to
// the "outer" ones.
plannerCopy.curPlan.subqueryPlans = params.p.curPlan.subqueryPlans
// During cleanup, nil out the inner subquery plans before closing the plan
// components. Otherwise, we may inadvertently close nodes that are needed
// when executing the outer query.
defer func() {
plan.subqueryPlans = nil
}()
}

distributePlan := getPlanDistribution(
Expand Down Expand Up @@ -365,10 +372,13 @@ func runPlanInsidePlan(
evalCtxFactory2 := func(usedConcurrently bool) *extendedEvalContext {
return evalCtxFactory()
}

plannerCopy.autoCommit = false
execCfg.DistSQLPlanner.PlanAndRunCascadesAndChecks(
ctx, &plannerCopy, evalCtxFactory2, &plannerCopy.curPlan.planComponents, recv,
)
// We might have appended some cascades or checks to the plannerCopy, so we
// need to update the plan for cleanup purposes before proceeding.
*plan = plannerCopy.curPlan.planComponents
if recv.commErr != nil {
return recv.commErr
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/sql/catalog/catpb/job_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

package catpb

import "strconv"

// JobID is the ID of a job. It is defined here and imported in jobspb because
// jobs are referenced in descriptors and also jobs reference parts of
// descriptors. This avoids any dependency cycles.
Expand All @@ -20,3 +22,8 @@ const InvalidJobID JobID = 0

// SafeValue implements the redact.SafeValue interface.
func (j JobID) SafeValue() {}

// String implements the fmt.Stringer interface.
func (j JobID) String() string {
return strconv.Itoa(int(j))
}
Loading

0 comments on commit 2a90855

Please sign in to comment.