func (s *server) PreflightSchema(ctx context.Context, request *pb.PreflightSchemaRequest) (*pb.PreflightSchemaResponse, error) { ctx = callinfo.GRPCCallInfo(ctx) response := &pb.PreflightSchemaResponse{} return response, s.agent.RPCWrapLockAction(ctx, actionnode.TabletActionPreflightSchema, request, response, true, func() error { scr, err := s.agent.PreflightSchema(ctx, request.Change) if err == nil { response.BeforeSchema = myproto.SchemaDefinitionToProto(scr.BeforeSchema) response.AfterSchema = myproto.SchemaDefinitionToProto(scr.AfterSchema) } return err }) }
func (s *server) ApplySchema(ctx context.Context, request *pb.ApplySchemaRequest) (*pb.ApplySchemaResponse, error) { ctx = callinfo.GRPCCallInfo(ctx) response := &pb.ApplySchemaResponse{} return response, s.agent.RPCWrapLockAction(ctx, actionnode.TabletActionApplySchema, request, response, true, func() error { scr, err := s.agent.ApplySchema(ctx, &myproto.SchemaChange{ Sql: request.Sql, Force: request.Force, AllowReplication: request.AllowReplication, BeforeSchema: myproto.ProtoToSchemaDefinition(request.BeforeSchema), AfterSchema: myproto.ProtoToSchemaDefinition(request.AfterSchema), }) if err == nil { response.BeforeSchema = myproto.SchemaDefinitionToProto(scr.BeforeSchema) response.AfterSchema = myproto.SchemaDefinitionToProto(scr.AfterSchema) } return err }) }
func (s *server) GetSchema(ctx context.Context, request *pb.GetSchemaRequest) (*pb.GetSchemaResponse, error) { ctx = callinfo.GRPCCallInfo(ctx) response := &pb.GetSchemaResponse{} return response, s.agent.RPCWrap(ctx, actionnode.TabletActionGetSchema, request, response, func() error { sd, err := s.agent.GetSchema(ctx, request.Tables, request.ExcludeTables, request.IncludeViews) if err == nil { response.SchemaDefinition = myproto.SchemaDefinitionToProto(sd) } return err }) }
// ApplySchema is part of the tmclient.TabletManagerClient interface func (client *Client) ApplySchema(ctx context.Context, tablet *topo.TabletInfo, change *myproto.SchemaChange) (*myproto.SchemaChangeResult, error) { cc, c, err := client.dial(ctx, tablet) if err != nil { return nil, err } defer cc.Close() response, err := c.ApplySchema(ctx, &pb.ApplySchemaRequest{ Sql: change.Sql, Force: change.Force, AllowReplication: change.AllowReplication, BeforeSchema: myproto.SchemaDefinitionToProto(change.BeforeSchema), AfterSchema: myproto.SchemaDefinitionToProto(change.AfterSchema), }) if err != nil { return nil, err } return &myproto.SchemaChangeResult{ BeforeSchema: myproto.ProtoToSchemaDefinition(response.BeforeSchema), AfterSchema: myproto.ProtoToSchemaDefinition(response.AfterSchema), }, nil }