diff --git a/go/vt/vtgate/engine/sequential.go b/go/vt/vtgate/engine/sequential.go index 759d48fcc2f..3c3e77f2ca1 100644 --- a/go/vt/vtgate/engine/sequential.go +++ b/go/vt/vtgate/engine/sequential.go @@ -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 } diff --git a/go/vt/vtgate/planbuilder/operator_transformers.go b/go/vt/vtgate/planbuilder/operator_transformers.go index 35d9f91021f..11a7ae60cee 100644 --- a/go/vt/vtgate/planbuilder/operator_transformers.go +++ b/go/vt/vtgate/planbuilder/operator_transformers.go @@ -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{ diff --git a/go/vt/vtgate/planbuilder/operators/sequential.go b/go/vt/vtgate/planbuilder/operators/sequential.go index 92242feb403..2b333c6270a 100644 --- a/go/vt/vtgate/planbuilder/operators/sequential.go +++ b/go/vt/vtgate/planbuilder/operators/sequential.go @@ -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 diff --git a/go/vt/vtgate/planbuilder/plan_test.go b/go/vt/vtgate/planbuilder/plan_test.go index c84072a252a..9c1592fdf81 100644 --- a/go/vt/vtgate/planbuilder/plan_test.go +++ b/go/vt/vtgate/planbuilder/plan_test.go @@ -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"}) @@ -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) { diff --git a/go/vt/vtgate/planbuilder/sequential.go b/go/vt/vtgate/planbuilder/sequential.go index 8080043265b..ff6abacb437 100644 --- a/go/vt/vtgate/planbuilder/sequential.go +++ b/go/vt/vtgate/planbuilder/sequential.go @@ -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) } diff --git a/go/vt/vtgate/schema/tracker.go b/go/vt/vtgate/schema/tracker.go index 9d966e17048..c4b48ce8156 100644 --- a/go/vt/vtgate/schema/tracker.go +++ b/go/vt/vtgate/schema/tracker.go @@ -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