From 1a7b1104dc4626667d55350c913ddfa3655ee811 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Fri, 17 Jan 2025 11:57:35 +0100 Subject: [PATCH] wip --- go/vt/vtgate/planbuilder/operators/ast_to_op.go | 7 ++++--- go/vt/vtgate/semantics/bitset/mutable.go | 4 ++-- go/vt/vtgate/semantics/semantic_table.go | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go/vt/vtgate/planbuilder/operators/ast_to_op.go b/go/vt/vtgate/planbuilder/operators/ast_to_op.go index b65a54a4248..8f9246f60b8 100644 --- a/go/vt/vtgate/planbuilder/operators/ast_to_op.go +++ b/go/vt/vtgate/planbuilder/operators/ast_to_op.go @@ -18,6 +18,7 @@ package operators import ( "fmt" + "vitess.io/vitess/go/vt/vtgate/semantics/bitset" "vitess.io/vitess/go/vt/sqlparser" "vitess.io/vitess/go/vt/vterrors" @@ -121,17 +122,17 @@ func cloneASTAndSemState[T sqlparser.SQLNode](ctx *plancontext.PlanningContext, // findTablesContained returns the TableSet of all the contained func findTablesContained(ctx *plancontext.PlanningContext, node sqlparser.SQLNode) semantics.TableSet { - var tables []semantics.TableSet + bs := bitset.NewMutable() _ = sqlparser.Walk(func(node sqlparser.SQLNode) (bool, error) { t, ok := node.(*sqlparser.AliasedTableExpr) if !ok { return true, nil } ts := ctx.SemTable.TableSetFor(t) - tables = append(tables, ts) + bs.Or(bitset.Bitset(ts)) return true, nil }, node) - return semantics.MergeTableSets(tables...) + return semantics.TableSet(bs.AsImmutable()) } // joinPredicateCollector is used to inspect the predicates inside the subquery, looking for any diff --git a/go/vt/vtgate/semantics/bitset/mutable.go b/go/vt/vtgate/semantics/bitset/mutable.go index 47649cfa03f..2bf42672e07 100644 --- a/go/vt/vtgate/semantics/bitset/mutable.go +++ b/go/vt/vtgate/semantics/bitset/mutable.go @@ -22,8 +22,8 @@ type Mutable struct { data []byte } -// NewMutableTableSet creates an initially empty MutableTableSet. -func NewMutableTableSet() *Mutable { +// NewMutable creates an initially empty mutable BitSet. +func NewMutable() *Mutable { return &Mutable{} } diff --git a/go/vt/vtgate/semantics/semantic_table.go b/go/vt/vtgate/semantics/semantic_table.go index 62ba5d3fec1..96b8a2e8ea1 100644 --- a/go/vt/vtgate/semantics/semantic_table.go +++ b/go/vt/vtgate/semantics/semantic_table.go @@ -708,7 +708,7 @@ func (d ExprDependencies) dependencies(expr sqlparser.Expr) (deps TableSet) { }() } - depsCalc := bitset.NewMutableTableSet() + depsCalc := bitset.NewMutable() // During the original semantic analysis, all ColNames were found and bound to the corresponding tables // Here, we'll walk the expression tree and look to see if we can find any sub-expressions // that have already set dependencies.