From 9d9e80028f4300ad14ad991d992edf77d44f0848 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Wed, 6 Mar 2024 14:52:21 +0100 Subject: [PATCH] planbuilder: Cleanup unused logic (#15415) --- go/vt/vtgate/planbuilder/operators/delete.go | 2 +- .../planbuilder/operators/dml_planning.go | 22 ++----------------- go/vt/vtgate/planbuilder/operators/update.go | 10 ++++----- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/go/vt/vtgate/planbuilder/operators/delete.go b/go/vt/vtgate/planbuilder/operators/delete.go index 7ce321378d0..8c7703ef096 100644 --- a/go/vt/vtgate/planbuilder/operators/delete.go +++ b/go/vt/vtgate/planbuilder/operators/delete.go @@ -270,7 +270,7 @@ func createDeleteOperator(ctx *plancontext.PlanningContext, del *sqlparser.Delet var ovq *sqlparser.Select if vTbl.Keyspace.Sharded && vTbl.Type == vindexes.TypeTable { - primaryVindex, _ := getVindexInformation(tblID, vTbl) + primaryVindex := getVindexInformation(tblID, vTbl) if len(vTbl.Owned) > 0 { ovq = generateOwnedVindexQuery(del, targetTbl, primaryVindex.Columns) } diff --git a/go/vt/vtgate/planbuilder/operators/dml_planning.go b/go/vt/vtgate/planbuilder/operators/dml_planning.go index 561cfde4c1a..b8fa172b87c 100644 --- a/go/vt/vtgate/planbuilder/operators/dml_planning.go +++ b/go/vt/vtgate/planbuilder/operators/dml_planning.go @@ -59,30 +59,12 @@ func shortDesc(target TargetTable, ovq *sqlparser.Select) string { // getVindexInformation returns the vindex and VindexPlusPredicates for the DML, // If it cannot find a unique vindex match, it returns an error. -func getVindexInformation(id semantics.TableSet, table *vindexes.Table) ( - *vindexes.ColumnVindex, - []*VindexPlusPredicates) { - +func getVindexInformation(id semantics.TableSet, table *vindexes.Table) *vindexes.ColumnVindex { // Check that we have a primary vindex which is valid if len(table.ColumnVindexes) == 0 || !table.ColumnVindexes[0].IsUnique() { panic(vterrors.VT09001(table.Name)) } - primaryVindex := table.ColumnVindexes[0] - - var vindexesAndPredicates []*VindexPlusPredicates - for _, colVindex := range table.Ordered { - if lu, isLu := colVindex.Vindex.(vindexes.LookupBackfill); isLu && lu.IsBackfilling() { - // Checking if the Vindex is currently backfilling or not, if it isn't we can read from the vindex table, - // and we will be able to do a delete equal. Otherwise, we continue to look for next best vindex. - continue - } - - vindexesAndPredicates = append(vindexesAndPredicates, &VindexPlusPredicates{ - ColVindex: colVindex, - TableID: id, - }) - } - return primaryVindex, vindexesAndPredicates + return table.ColumnVindexes[0] } func createAssignmentExpressions( diff --git a/go/vt/vtgate/planbuilder/operators/update.go b/go/vt/vtgate/planbuilder/operators/update.go index 7f394634f6c..7f97e62f41e 100644 --- a/go/vt/vtgate/planbuilder/operators/update.go +++ b/go/vt/vtgate/planbuilder/operators/update.go @@ -269,7 +269,7 @@ func createUpdateOperator(ctx *plancontext.PlanningContext, updStmt *sqlparser.U Name: name, } - _, cvv, ovq, subQueriesArgOnChangedVindex := getUpdateVindexInformation(ctx, updStmt, targetTbl, assignments) + cvv, ovq, subQueriesArgOnChangedVindex := getUpdateVindexInformation(ctx, updStmt, targetTbl, assignments) updOp := &Update{ DMLCommon: &DMLCommon{ @@ -302,14 +302,14 @@ func getUpdateVindexInformation( updStmt *sqlparser.Update, table TargetTable, assignments []SetExpr, -) ([]*VindexPlusPredicates, map[string]*engine.VindexValues, *sqlparser.Select, []string) { +) (map[string]*engine.VindexValues, *sqlparser.Select, []string) { if !table.VTable.Keyspace.Sharded { - return nil, nil, nil, nil + return nil, nil, nil } - primaryVindex, vindexAndPredicates := getVindexInformation(table.ID, table.VTable) + primaryVindex := getVindexInformation(table.ID, table.VTable) changedVindexValues, ownedVindexQuery, subQueriesArgOnChangedVindex := buildChangedVindexesValues(ctx, updStmt, table.VTable, primaryVindex.Columns, assignments) - return vindexAndPredicates, changedVindexValues, ownedVindexQuery, subQueriesArgOnChangedVindex + return changedVindexValues, ownedVindexQuery, subQueriesArgOnChangedVindex } func buildFkOperator(ctx *plancontext.PlanningContext, updOp Operator, updClone *sqlparser.Update, parentFks []vindexes.ParentFKInfo, childFks []vindexes.ChildFKInfo, updatedTable *vindexes.Table) Operator {