From c61631e064205006622253caaf5020dcffaf99d4 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Tue, 3 Dec 2024 09:19:23 +0100 Subject: [PATCH] refactor: rename to SelectedKeyspace Signed-off-by: Andres Taylor --- go/test/vschemawrapper/vschema_wrapper.go | 4 ++-- go/vt/vtgate/planbuilder/builder.go | 6 +++--- go/vt/vtgate/planbuilder/bypass.go | 2 +- go/vt/vtgate/planbuilder/ddl.go | 2 +- go/vt/vtgate/planbuilder/operator_transformers.go | 2 +- go/vt/vtgate/planbuilder/plancontext/planning_context.go | 2 +- .../vtgate/planbuilder/plancontext/planning_context_test.go | 2 +- go/vt/vtgate/planbuilder/plancontext/vschema.go | 4 ++-- go/vt/vtgate/planbuilder/select.go | 4 ++-- go/vt/vtgate/planbuilder/show.go | 2 +- go/vt/vtgate/vcursor_impl.go | 6 +++--- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/go/test/vschemawrapper/vschema_wrapper.go b/go/test/vschemawrapper/vschema_wrapper.go index d086166823f..b362a8b7408 100644 --- a/go/test/vschemawrapper/vschema_wrapper.go +++ b/go/test/vschemawrapper/vschema_wrapper.go @@ -299,12 +299,12 @@ func (vw *VSchemaWrapper) getActualKeyspace() string { return ks.Name } -func (vw *VSchemaWrapper) CurrentKeyspace() (*vindexes.Keyspace, error) { +func (vw *VSchemaWrapper) SelectedKeyspace() (*vindexes.Keyspace, error) { return vw.V.Keyspaces["main"].Keyspace, nil } func (vw *VSchemaWrapper) AnyKeyspace() (*vindexes.Keyspace, error) { - return vw.CurrentKeyspace() + return vw.SelectedKeyspace() } func (vw *VSchemaWrapper) FirstSortedKeyspace() (*vindexes.Keyspace, error) { diff --git a/go/vt/vtgate/planbuilder/builder.go b/go/vt/vtgate/planbuilder/builder.go index bea2ba87028..495564d6571 100644 --- a/go/vt/vtgate/planbuilder/builder.go +++ b/go/vt/vtgate/planbuilder/builder.go @@ -275,7 +275,7 @@ func buildDBDDLPlan(stmt sqlparser.Statement, _ *sqlparser.ReservedVars, vschema dbDDLstmt := stmt.(sqlparser.DBDDLStatement) ksName := dbDDLstmt.GetDatabaseName() if ksName == "" { - ks, err := vschema.CurrentKeyspace() + ks, err := vschema.SelectedKeyspace() if err != nil { return nil, err } @@ -310,7 +310,7 @@ func buildDBDDLPlan(stmt sqlparser.Statement, _ *sqlparser.ReservedVars, vschema } func buildLoadPlan(query string, vschema plancontext.VSchema) (*planResult, error) { - keyspace, err := vschema.CurrentKeyspace() + keyspace, err := vschema.SelectedKeyspace() if err != nil { return nil, err } @@ -355,7 +355,7 @@ func buildFlushOptions(stmt *sqlparser.Flush, vschema plancontext.VSchema) (*pla return nil, vterrors.VT09012("FLUSH", vschema.TabletType().String()) } - keyspace, err := vschema.CurrentKeyspace() + keyspace, err := vschema.SelectedKeyspace() if err != nil { return nil, err } diff --git a/go/vt/vtgate/planbuilder/bypass.go b/go/vt/vtgate/planbuilder/bypass.go index a753a3cb7bf..d3384d509c1 100644 --- a/go/vt/vtgate/planbuilder/bypass.go +++ b/go/vt/vtgate/planbuilder/bypass.go @@ -26,7 +26,7 @@ import ( ) func buildPlanForBypass(stmt sqlparser.Statement, _ *sqlparser.ReservedVars, vschema plancontext.VSchema) (*planResult, error) { - keyspace, err := vschema.CurrentKeyspace() + keyspace, err := vschema.SelectedKeyspace() if err != nil { return nil, err } diff --git a/go/vt/vtgate/planbuilder/ddl.go b/go/vt/vtgate/planbuilder/ddl.go index f9524625528..5e16dab1c59 100644 --- a/go/vt/vtgate/planbuilder/ddl.go +++ b/go/vt/vtgate/planbuilder/ddl.go @@ -81,7 +81,7 @@ func buildGeneralDDLPlan(ctx context.Context, sql string, ddlStatement sqlparser } func buildByPassPlan(sql string, vschema plancontext.VSchema, isDDL bool) (*planResult, error) { - keyspace, err := vschema.CurrentKeyspace() + keyspace, err := vschema.SelectedKeyspace() 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 c6e50140880..df14745e6b2 100644 --- a/go/vt/vtgate/planbuilder/operator_transformers.go +++ b/go/vt/vtgate/planbuilder/operator_transformers.go @@ -545,7 +545,7 @@ func routeToEngineRoute(ctx *plancontext.PlanningContext, op *operators.Route, h } func newRoutingParams(ctx *plancontext.PlanningContext, opCode engine.Opcode) *engine.RoutingParameters { - ks, _ := ctx.VSchema.CurrentKeyspace() + ks, _ := ctx.VSchema.SelectedKeyspace() if ks == nil { // if we don't have a selected keyspace, any keyspace will do // this is used by operators that do not set the keyspace diff --git a/go/vt/vtgate/planbuilder/plancontext/planning_context.go b/go/vt/vtgate/planbuilder/plancontext/planning_context.go index 16d808535bd..016f5c877cf 100644 --- a/go/vt/vtgate/planbuilder/plancontext/planning_context.go +++ b/go/vt/vtgate/planbuilder/plancontext/planning_context.go @@ -91,7 +91,7 @@ func CreatePlanningContext(stmt sqlparser.Statement, version querypb.ExecuteOptions_PlannerVersion, ) (*PlanningContext, error) { ksName := "" - if ks, _ := vschema.CurrentKeyspace(); ks != nil { + if ks, _ := vschema.SelectedKeyspace(); ks != nil { ksName = ks.Name } diff --git a/go/vt/vtgate/planbuilder/plancontext/planning_context_test.go b/go/vt/vtgate/planbuilder/plancontext/planning_context_test.go index 596837c5dbf..e5e96b0a4be 100644 --- a/go/vt/vtgate/planbuilder/plancontext/planning_context_test.go +++ b/go/vt/vtgate/planbuilder/plancontext/planning_context_test.go @@ -201,7 +201,7 @@ func (v *vschema) FindTableOrVindex(tablename sqlparser.TableName) (*vindexes.Ta panic("implement me") } -func (v *vschema) CurrentKeyspace() (*vindexes.Keyspace, error) { +func (v *vschema) SelectedKeyspace() (*vindexes.Keyspace, error) { // TODO implement me panic("implement me") } diff --git a/go/vt/vtgate/planbuilder/plancontext/vschema.go b/go/vt/vtgate/planbuilder/plancontext/vschema.go index b7bc656eaab..b4560424718 100644 --- a/go/vt/vtgate/planbuilder/plancontext/vschema.go +++ b/go/vt/vtgate/planbuilder/plancontext/vschema.go @@ -28,8 +28,8 @@ type VSchema interface { FindView(name sqlparser.TableName) sqlparser.SelectStatement FindTableOrVindex(tablename sqlparser.TableName) (*vindexes.Table, vindexes.Vindex, string, topodatapb.TabletType, key.Destination, error) - // CurrentKeyspace returns the current keyspace if set, otherwise returns an error - CurrentKeyspace() (*vindexes.Keyspace, error) + // SelectedKeyspace returns the current keyspace if set, otherwise returns an error + SelectedKeyspace() (*vindexes.Keyspace, error) TargetString() string Destination() key.Destination TabletType() topodatapb.TabletType diff --git a/go/vt/vtgate/planbuilder/select.go b/go/vt/vtgate/planbuilder/select.go index 2c2e31a9d13..409343f2760 100644 --- a/go/vt/vtgate/planbuilder/select.go +++ b/go/vt/vtgate/planbuilder/select.go @@ -46,7 +46,7 @@ func gen4SelectStmtPlanner( } if p != nil { used := "dual" - keyspace, ksErr := vschema.CurrentKeyspace() + keyspace, ksErr := vschema.SelectedKeyspace() if ksErr == nil { // we are just getting the ks to log the correct table use. // no need to fail this if we can't find the default keyspace @@ -101,7 +101,7 @@ func gen4SelectStmtPlanner( func gen4planSQLCalcFoundRows(vschema plancontext.VSchema, sel *sqlparser.Select, query string, reservedVars *sqlparser.ReservedVars) (*planResult, error) { ksName := "" - if ks, _ := vschema.CurrentKeyspace(); ks != nil { + if ks, _ := vschema.SelectedKeyspace(); ks != nil { ksName = ks.Name } semTable, err := semantics.Analyze(sel, ksName, vschema) diff --git a/go/vt/vtgate/planbuilder/show.go b/go/vt/vtgate/planbuilder/show.go index abc859518f4..40cf7b2411f 100644 --- a/go/vt/vtgate/planbuilder/show.go +++ b/go/vt/vtgate/planbuilder/show.go @@ -676,7 +676,7 @@ func buildVschemaKeyspacesPlan(vschema plancontext.VSchema) (engine.Primitive, e func buildVschemaTablesPlan(vschema plancontext.VSchema) (engine.Primitive, error) { vs := vschema.GetVSchema() - ks, err := vschema.CurrentKeyspace() + ks, err := vschema.SelectedKeyspace() if err != nil { return nil, err } diff --git a/go/vt/vtgate/vcursor_impl.go b/go/vt/vtgate/vcursor_impl.go index baea28a8504..691b9988d9e 100644 --- a/go/vt/vtgate/vcursor_impl.go +++ b/go/vt/vtgate/vcursor_impl.go @@ -392,10 +392,10 @@ func (vc *vcursorImpl) getActualKeyspace() string { return ks.Name } -// DefaultKeyspace returns the default keyspace of the current request +// SelectedKeyspace returns the selected keyspace of the current request // if there is one. If the keyspace specified in the target cannot be // identified, it returns an error. -func (vc *vcursorImpl) CurrentKeyspace() (*vindexes.Keyspace, error) { +func (vc *vcursorImpl) SelectedKeyspace() (*vindexes.Keyspace, error) { if ignoreKeyspace(vc.keyspace) { return nil, errNoKeyspace } @@ -409,7 +409,7 @@ func (vc *vcursorImpl) CurrentKeyspace() (*vindexes.Keyspace, error) { var errNoDbAvailable = vterrors.NewErrorf(vtrpcpb.Code_FAILED_PRECONDITION, vterrors.NoDB, "no database available") func (vc *vcursorImpl) AnyKeyspace() (*vindexes.Keyspace, error) { - keyspace, err := vc.CurrentKeyspace() + keyspace, err := vc.SelectedKeyspace() if err == nil { return keyspace, nil }