Skip to content

Commit

Permalink
support updating primary/unique key columns in new DML (#20842)
Browse files Browse the repository at this point in the history
let DML queries to run in single-step plan

Approved by: @daviszhen, @aressu1985, @zhangxu19830126, @badboynt1, @qingxinhome, @ouyuanning, @XuPeng-SH
  • Loading branch information
aunjgr authored Jan 16, 2025
1 parent 7605955 commit e9a5458
Show file tree
Hide file tree
Showing 43 changed files with 2,417 additions and 1,955 deletions.
5 changes: 2 additions & 3 deletions pkg/container/batch/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ import (
"bytes"
"context"
"fmt"
"github.com/matrixorigin/matrixone/pkg/common/bitmap"

"github.com/matrixorigin/matrixone/pkg/sql/colexec/aggexec"

"github.com/matrixorigin/matrixone/pkg/common/bitmap"
"github.com/matrixorigin/matrixone/pkg/common/moerr"
"github.com/matrixorigin/matrixone/pkg/common/mpool"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/sql/colexec/aggexec"
)

func New(attrs []string) *Batch {
Expand Down
18 changes: 9 additions & 9 deletions pkg/frontend/test/incrservice_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 9 additions & 14 deletions pkg/frontend/test/mock_incr/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions pkg/incrservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/matrixorigin/matrixone/pkg/common/log"
"github.com/matrixorigin/matrixone/pkg/common/moerr"
"github.com/matrixorigin/matrixone/pkg/common/stopper"
"github.com/matrixorigin/matrixone/pkg/container/batch"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/defines"
"github.com/matrixorigin/matrixone/pkg/pb/timestamp"
"github.com/matrixorigin/matrixone/pkg/pb/txn"
Expand Down Expand Up @@ -220,7 +220,8 @@ func (s *service) GetLastAllocateTS(
func (s *service) InsertValues(
ctx context.Context,
tableID uint64,
bat *batch.Batch,
vecs []*vector.Vector,
rows int,
estimate int64,
) (uint64, error) {
ts, err := s.getCommittedTableCache(
Expand All @@ -232,7 +233,8 @@ func (s *service) InsertValues(
return ts.insertAutoValues(
ctx,
tableID,
bat,
vecs,
rows,
estimate,
)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/incrservice/table_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"sync"

"github.com/matrixorigin/matrixone/pkg/common/log"
"github.com/matrixorigin/matrixone/pkg/container/batch"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/pb/timestamp"
"github.com/matrixorigin/matrixone/pkg/txn/client"
)
Expand Down Expand Up @@ -105,7 +105,8 @@ func (c *tableCache) getLastAllocateTS(colName string) (timestamp.Timestamp, err
func (c *tableCache) insertAutoValues(
ctx context.Context,
tableID uint64,
bat *batch.Batch,
vecs []*vector.Vector,
rows int,
estimate int64,
) (uint64, error) {
lastInsert := uint64(0)
Expand All @@ -120,8 +121,7 @@ func (c *tableCache) insertAutoValues(
cc.preAllocate(ctx, tableID, int(estimate), txnOp)
}

rows := bat.RowCount()
vec := bat.GetVector(int32(col.ColIndex))
vec := vecs[col.ColIndex]
if v, err := cc.insertAutoValues(ctx, tableID, vec, rows, txnOp); err != nil {
return 0, err
} else {
Expand Down
6 changes: 3 additions & 3 deletions pkg/incrservice/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"

"github.com/matrixorigin/matrixone/pkg/common/runtime"
"github.com/matrixorigin/matrixone/pkg/container/batch"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/pb/plan"
"github.com/matrixorigin/matrixone/pkg/pb/timestamp"
"github.com/matrixorigin/matrixone/pkg/txn/client"
Expand Down Expand Up @@ -63,7 +63,7 @@ type AutoIncrementService interface {
// delete operation is triggered.
Delete(ctx context.Context, tableID uint64, txn client.TxnOperator) error
// InsertValues insert auto columns values into bat.
InsertValues(ctx context.Context, tableID uint64, bat *batch.Batch, estimate int64) (uint64, error)
InsertValues(ctx context.Context, tableID uint64, vecs []*vector.Vector, rows int, estimate int64) (uint64, error)
// CurrentValue return current incr column value.
CurrentValue(ctx context.Context, tableID uint64, col string) (uint64, error)
// Reload reload auto increment cache.
Expand Down Expand Up @@ -109,7 +109,7 @@ type incrTableCache interface {
table() uint64
commit()
columns() []AutoColumn
insertAutoValues(ctx context.Context, tableID uint64, bat *batch.Batch, estimate int64) (uint64, error)
insertAutoValues(ctx context.Context, tableID uint64, vecs []*vector.Vector, rows int, estimate int64) (uint64, error)
currentValue(ctx context.Context, tableID uint64, col string) (uint64, error)
getLastAllocateTS(colName string) (timestamp.Timestamp, error)
adjust(ctx context.Context, cols []AutoColumn) error
Expand Down
Loading

0 comments on commit e9a5458

Please sign in to comment.