Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
  • Loading branch information
harshit-gangal committed Nov 13, 2023
1 parent 601133f commit 63a9075
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go/vt/vtgate/engine/sequential.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *Sequential) GetTableName() string {
func (s *Sequential) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantFields bool) (*sqltypes.Result, error) {
finalRes := &sqltypes.Result{}
for _, source := range s.Sources {
res, err := source.TryExecute(ctx, vcursor, bindVars, wantFields)
res, err := vcursor.ExecutePrimitive(ctx, source, bindVars, wantFields)
if err != nil {
return nil, err
}
Expand Down
11 changes: 11 additions & 0 deletions go/vt/vtgate/planbuilder/operator_transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ func transformSequential(ctx *plancontext.PlanningContext, op *operators.Sequent
if err != nil {
return nil, err
}
pw, ok := lp.(*primitiveWrapper)
if ok {
switch dml := pw.prim.(type) {
case *engine.Update:
dml.PreventAutoCommit = true
case *engine.Delete:
dml.PreventAutoCommit = true
case *engine.Insert:
dml.PreventAutoCommit = true
}
}
lps = append(lps, lp)
}
return &sequential{
Expand Down
6 changes: 0 additions & 6 deletions go/vt/vtgate/planbuilder/operators/sequential.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ type Sequential struct {
noColumns
}

func newSequential(srcs []ops.Operator) *Sequential {
return &Sequential{
Sources: srcs,
}
}

// Clone implements the Operator interface
func (s *Sequential) Clone(inputs []ops.Operator) ops.Operator {
newOp := *s
Expand Down
8 changes: 8 additions & 0 deletions go/vt/vtgate/planbuilder/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ func setFks(t *testing.T, vschema *vindexes.VSchema) {

_ = vschema.AddForeignKey("unsharded_fk_allow", "u_multicol_tbl2", createFkDefinition([]string{"cola", "colb"}, "u_multicol_tbl1", []string{"cola", "colb"}, sqlparser.SetNull, sqlparser.SetNull))
_ = vschema.AddForeignKey("unsharded_fk_allow", "u_multicol_tbl3", createFkDefinition([]string{"cola", "colb"}, "u_multicol_tbl2", []string{"cola", "colb"}, sqlparser.Cascade, sqlparser.Cascade))

_ = vschema.AddForeignKey("unsharded_fk_allow", "fk_t3", createFkDefinition([]string{"col"}, "fk_t2", []string{"col2"}, sqlparser.SetNull, sqlparser.SetNull))
_ = vschema.AddForeignKey("unsharded_fk_allow", "fk_t4", createFkDefinition([]string{"col3"}, "fk_t3", []string{"col2"}, sqlparser.SetNull, sqlparser.SetNull))
_ = vschema.AddPrimaryKey("unsharded_fk_allow", "fk_t2", []string{"id"})
_ = vschema.AddPrimaryKey("unsharded_fk_allow", "fk_t3", []string{"id"})
_ = vschema.AddPrimaryKey("unsharded_fk_allow", "fk_t4", []string{"id"})
_ = vschema.AddUniqueKey("unsharded_fk_allow", "fk_t3", sqlparser.Exprs{sqlparser.NewColName("col")})
}

_ = vschema.AddPrimaryKey("unsharded_fk_allow", "u_tbl1", []string{"id"})
Expand All @@ -184,6 +191,7 @@ func setFks(t *testing.T, vschema *vindexes.VSchema) {
_ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", sqlparser.Exprs{sqlparser.NewColName("col9"), sqlparser.NewColName("foo")})
_ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", sqlparser.Exprs{sqlparser.NewColName("foo"), sqlparser.NewColName("bar")})
_ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", sqlparser.Exprs{sqlparser.NewColName("bar"), sqlparser.NewColName("col9")})
_ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl8", sqlparser.Exprs{sqlparser.NewColName("col8")})
}

func TestSystemTables57(t *testing.T) {
Expand Down
12 changes: 1 addition & 11 deletions go/vt/vtgate/planbuilder/sequential.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,7 @@ var _ logicalPlan = (*sequential)(nil)
func (s *sequential) Primitive() engine.Primitive {
var sources []engine.Primitive
for _, source := range s.sources {
prim := source.Primitive()
switch dml := prim.(type) {
case *engine.Update:
dml.PreventAutoCommit = true
case *engine.Delete:
dml.PreventAutoCommit = true
case *engine.Insert:
dml.PreventAutoCommit = true
}
sources = append(sources, prim)
sources = append(sources, source.Primitive())
}

return engine.NewSequential(sources)
}
1 change: 0 additions & 1 deletion go/vt/vtgate/schema/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ func (t *Tracker) GetIndexes(ks string, tbl string) []*sqlparser.IndexDefinition

tblInfo := t.tables.get(ks, tbl)
return tblInfo.Indexes

}

// Tables returns a map with the columns for all known tables in the keyspace
Expand Down

0 comments on commit 63a9075

Please sign in to comment.