Skip to content

Commit

Permalink
sql: add stub exec.Factory for opt-driven distsql planning
Browse files Browse the repository at this point in the history
This commit adds a stub implementation of `exec.Factory` interface that
will be creating DistSQL processor specs directly from `opt.Tree`,
sidestepping intermediate `planNode` phase.

It also introduces a new private cluster setting
"sql.defaults.experimental_distsql_planning" as well as a session
variable "experimental_distsql_planning" which determine whether the new
factory is used, set to `off` by default (other options are `on` and
`always` - the latter is only for the session variable).

`Off` planning mode means using the old code path, `on` means attempting
to use the new code path but falling back to the old one if we encounter
an error, and `always` means using only the new code path and do not
fallback in case of an error. Currently the fallback doesn't occur with
`always` only for SELECT statements (so that we could run other
statements types, like SET).

Release note: None
  • Loading branch information
yuzefovich committed May 29, 2020
1 parent 9879c75 commit f613950
Show file tree
Hide file tree
Showing 10 changed files with 593 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/sql/distsql_running.go
Original file line number Diff line number Diff line change
Expand Up @@ -1076,14 +1076,14 @@ func (dsp *DistSQLPlanner) PlanAndRunCascadesAndChecks(
}

evalCtx := evalCtxFactory()
execFactory := makeExecFactory(planner)
execFactory := newExecFactory(planner)
// The cascading query is allowed to autocommit only if it is the last
// cascade and there are no check queries to run.
if len(plan.checkPlans) > 0 || i < len(plan.cascades)-1 {
execFactory.disableAutoCommit()
}
cascadePlan, err := plan.cascades[i].PlanFn(
ctx, &planner.semaCtx, &evalCtx.EvalContext, &execFactory, buf, buf.bufferedRows.Len(),
ctx, &planner.semaCtx, &evalCtx.EvalContext, execFactory, buf, buf.bufferedRows.Len(),
)
if err != nil {
recv.SetError(err)
Expand Down
Loading

0 comments on commit f613950

Please sign in to comment.