Skip to content

Commit

Permalink
refactor: rename to SelectedKeyspace
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Dec 3, 2024
1 parent b77d1e9 commit c61631e
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions go/test/vschemawrapper/vschema_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vtgate/planbuilder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/bypass.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/operator_transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/plancontext/planning_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/planbuilder/plancontext/vschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/planbuilder/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vtgate/vcursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit c61631e

Please sign in to comment.