Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planbuilder: Cleanup unused logic #15415

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/operators/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
22 changes: 2 additions & 20 deletions go/vt/vtgate/planbuilder/operators/dml_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions go/vt/vtgate/planbuilder/operators/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down
Loading