From e3d1827231c0dd55c5ffe9d9a1c382a7dba03c41 Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Thu, 2 Feb 2017 17:44:59 +0000 Subject: [PATCH] sql: make the backfill code use a limitNode for chunking. By making the limit part of the semantic plan, distSQL will be able to use it. (Not yet tested since distSQL is not yet activated for backfilling.) --- pkg/sql/backfill.go | 4 +++- pkg/sql/plan.go | 8 +------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/sql/backfill.go b/pkg/sql/backfill.go index 382c33aad40f..9796d2400383 100644 --- a/pkg/sql/backfill.go +++ b/pkg/sql/backfill.go @@ -697,7 +697,9 @@ func (sc *SchemaChanger) backfillIndexesChunk( return err } - if err := planner.startPlanWithLimit(rows, chunkSize); err != nil { + rows = &limitNode{p: planner, plan: rows, countExpr: parser.NewDInt(parser.DInt(chunkSize))} + + if err := planner.startPlan(rows); err != nil { return err } diff --git a/pkg/sql/plan.go b/pkg/sql/plan.go index 5b80dbab1235..06e4ef61c69c 100644 --- a/pkg/sql/plan.go +++ b/pkg/sql/plan.go @@ -17,8 +17,6 @@ package sql import ( - "math" - "github.com/cockroachdb/cockroach/pkg/sql/parser" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/tracing" @@ -211,10 +209,6 @@ func (p *planner) makePlan(stmt parser.Statement, autoCommit bool) (planNode, er // startPlan starts the plan and all its sub-query nodes. func (p *planner) startPlan(plan planNode) error { - return p.startPlanWithLimit(plan, math.MaxInt64) -} - -func (p *planner) startPlanWithLimit(plan planNode, numRowsNeeded int64) error { if err := p.startSubqueryPlans(plan); err != nil { return err } @@ -222,7 +216,7 @@ func (p *planner) startPlanWithLimit(plan planNode, numRowsNeeded int64) error { return err } // Trigger limit propagation through the plan and sub-queries. - applyLimit(plan, numRowsNeeded, false /* !soft */) + setUnlimited(plan) return nil }