Skip to content

Commit

Permalink
Merge pull request #51632 from yuzefovich/upsert-19.2
Browse files Browse the repository at this point in the history
release-19.2: sql: follow-up to UPSERT batching behavior fix
  • Loading branch information
yuzefovich authored Jul 21, 2020
2 parents 84d492a + ad9e2a8 commit bd427b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions pkg/sql/tablewriter_upsert.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ func (tu *tableUpserterBase) batchedValues(rowIdx int) tree.Datums {
return tu.rowsUpserted.At(rowIdx)
}

func (tu *tableUpserterBase) curBatchSize() int { return tu.insertRows.Len() }

// close is part of the tableWriter interface.
func (tu *tableUpserterBase) close(ctx context.Context) {
tu.insertRows.Close(ctx)
Expand Down Expand Up @@ -487,6 +485,11 @@ func (tu *tableUpserter) atBatchEnd(ctx context.Context, traceKV bool) error {
return nil
}

// curBatchSize is part of the extendedTableWriter interface. Note that we need
// to override tableWriterBase.curBatchSize because tableUpserter stores the
// insert rows not in the batch but in insertRows row container.
func (tu *tableUpserter) curBatchSize() int { return tu.insertRows.Len() }

// updateConflictingRow updates the existing row in the table, when there was a
// conflict. existingRows contains the previously seen rows, and is modified
// or extended depending on how the PK columns are updated by the SET clauses.
Expand Down
5 changes: 0 additions & 5 deletions pkg/sql/tablewriter_upsert_opt.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ func (tu *optTableUpserter) atBatchEnd(ctx context.Context, traceKV bool) error
return nil
}

// curBatchSize is part of the extendedTableWriter interface. Note that we need
// to override tableUpserterBase.curBatchSize because the optimizer-driven
// UPSERTs do not store the insert rows in insertRows row container.
func (tu *optTableUpserter) curBatchSize() int { return tu.batchSize }

// insertNonConflictingRow inserts the given source row into the table when
// there was no conflict. If the RETURNING clause was specified, then the
// inserted row is stored in the rowsUpserted collection.
Expand Down
5 changes: 5 additions & 0 deletions pkg/sql/tablewriter_upsert_strict.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func (tu *strictTableUpserter) atBatchEnd(ctx context.Context, traceKV bool) err
return nil
}

// curBatchSize is part of the extendedTableWriter interface. Note that we need
// to override tableWriterBase.curBatchSize because tableUpserter stores the
// insert rows not in the batch but in insertRows row container.
func (tu *strictTableUpserter) curBatchSize() int { return tu.insertRows.Len() }

// Get all unique indexes and store them in tu.ConflictIndexes.
func (tu *strictTableUpserter) getUniqueIndexes() (err error) {
tableDesc := tu.tableDesc()
Expand Down

0 comments on commit bd427b0

Please sign in to comment.