Commit b0a410b9 authored by Tobias Schottdorf's avatar Tobias Schottdorf

sql: force local planning on tenants

Release note: None
parent 16e5049e
......@@ -3213,10 +3213,14 @@ func (dsp *DistSQLPlanner) createPlanForExport(
// NewPlanningCtx returns a new PlanningCtx. When distribute is false, a
// lightweight version PlanningCtx is returned that can be used when the caller
// knows plans will only be run on one node.
// knows plans will only be run on one node. It is coerced to false on SQL
// SQL tenants (in which case only local planning is supported), regardless of
// the passed-in value.
func (dsp *DistSQLPlanner) NewPlanningCtx(
ctx context.Context, evalCtx *extendedEvalContext, txn *kv.Txn, distribute bool,
) *PlanningCtx {
// Tenants can not distribute plans.
distribute = distribute && evalCtx.Codec.ForSystemTenant()
planCtx := &PlanningCtx{
ctx: ctx,
ExtendedEvalCtx: evalCtx,
......
......@@ -836,7 +836,9 @@ func TestPartitionSpans(t *testing.T) {
},
}
planCtx := dsp.NewPlanningCtx(context.Background(), nil /* evalCtx */, nil /* txn */, true /* distribute */)
planCtx := dsp.NewPlanningCtx(context.Background(), &extendedEvalContext{
EvalContext: tree.EvalContext{Codec: keys.SystemSQLCodec},
}, nil /* txn */, true /* distribute */)
var spans []roachpb.Span
for _, s := range tc.spans {
spans = append(spans, roachpb.Span{Key: roachpb.Key(s[0]), EndKey: roachpb.Key(s[1])})
......@@ -1017,7 +1019,9 @@ func TestPartitionSpansSkipsIncompatibleNodes(t *testing.T) {
},
}
planCtx := dsp.NewPlanningCtx(context.Background(), nil /* evalCtx */, nil /* txn */, true /* distribute */)
planCtx := dsp.NewPlanningCtx(context.Background(), &extendedEvalContext{
EvalContext: tree.EvalContext{Codec: keys.SystemSQLCodec},
}, nil /* txn */, true /* distribute */)
partitions, err := dsp.PartitionSpans(planCtx, roachpb.Spans{span})
if err != nil {
t.Fatal(err)
......@@ -1113,7 +1117,9 @@ func TestPartitionSpansSkipsNodesNotInGossip(t *testing.T) {
},
}
planCtx := dsp.NewPlanningCtx(context.Background(), nil /* evalCtx */, nil /* txn */, true /* distribute */)
planCtx := dsp.NewPlanningCtx(context.Background(), &extendedEvalContext{
EvalContext: tree.EvalContext{Codec: keys.SystemSQLCodec},
}, nil /* txn */, true /* distribute */)
partitions, err := dsp.PartitionSpans(planCtx, roachpb.Spans{span})
if err != nil {
t.Fatal(err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment