From 530366f9d4c008b63d26ea35f744a1f77d84cb09 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Wed, 26 Feb 2025 00:07:55 +0530 Subject: [PATCH] added prepared bool to VTGate Execute request to use raw query for getting plan without parsing and normalizing Signed-off-by: Harshit Gangal --- go/cmd/vtgateclienttest/services/callerid.go | 11 +- go/cmd/vtgateclienttest/services/echo.go | 11 +- go/cmd/vtgateclienttest/services/errors.go | 11 +- go/cmd/vtgateclienttest/services/fallback.go | 11 +- go/cmd/vtgateclienttest/services/terminal.go | 9 +- go/test/endtoend/cluster/cluster_process.go | 2 +- go/test/endtoend/cluster/cluster_util.go | 2 +- go/test/endtoend/recovery/recovery_util.go | 2 +- go/vt/proto/vtgate/vtgate.pb.go | 292 +++++++++-------- go/vt/proto/vtgate/vtgate_vtproto.pb.go | 34 ++ go/vt/vitessdriver/driver.go | 8 +- go/vt/vitessdriver/fakeserver_test.go | 9 +- go/vt/vtexplain/vtexplain_vtgate.go | 2 +- go/vt/vtgate/autocommit_test.go | 11 +- go/vt/vtgate/bench_test.go | 2 + go/vt/vtgate/executor.go | 18 +- go/vt/vtgate/executor_ddl_test.go | 2 +- go/vt/vtgate/executor_dml_test.go | 75 ++--- go/vt/vtgate/executor_framework_test.go | 18 +- go/vt/vtgate/executor_scatter_stats_test.go | 12 +- go/vt/vtgate/executor_select_test.go | 164 +++++----- go/vt/vtgate/executor_set_test.go | 34 +- go/vt/vtgate/executor_test.go | 301 +++++++++--------- go/vt/vtgate/executor_vexplain_test.go | 2 +- go/vt/vtgate/executor_vschema_ddl_test.go | 102 +++--- go/vt/vtgate/executorcontext/vcursor_impl.go | 6 +- .../executorcontext/vcursor_impl_test.go | 2 +- go/vt/vtgate/fakerpcvtgateconn/conn.go | 8 +- go/vt/vtgate/grpcvtgateconn/conn.go | 9 +- go/vt/vtgate/grpcvtgateconn/conn_rpc_test.go | 2 +- go/vt/vtgate/grpcvtgateconn/suite_test.go | 17 +- go/vt/vtgate/grpcvtgateservice/server.go | 2 +- go/vt/vtgate/plan_execute.go | 5 +- go/vt/vtgate/plugin_mysql_server.go | 4 +- go/vt/vtgate/vtgate.go | 13 +- go/vt/vtgate/vtgate_test.go | 35 +- go/vt/vtgate/vtgateconn/vtgateconn.go | 6 +- go/vt/vtgate/vtgateservice/interface.go | 2 +- go/vtbench/client.go | 2 +- proto/vtgate.proto | 2 + 40 files changed, 687 insertions(+), 573 deletions(-) diff --git a/go/cmd/vtgateclienttest/services/callerid.go b/go/cmd/vtgateclienttest/services/callerid.go index 0e4a7da8495..f66644d3996 100644 --- a/go/cmd/vtgateclienttest/services/callerid.go +++ b/go/cmd/vtgateclienttest/services/callerid.go @@ -75,11 +75,18 @@ func (c *callerIDClient) checkCallerID(ctx context.Context, received string) (bo return true, fmt.Errorf("SUCCESS: callerid matches") } -func (c *callerIDClient) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) { +func (c *callerIDClient) Execute( + ctx context.Context, + mysqlCtx vtgateservice.MySQLConnection, + session *vtgatepb.Session, + sql string, + bindVariables map[string]*querypb.BindVariable, + prepared bool, +) (*vtgatepb.Session, *sqltypes.Result, error) { if ok, err := c.checkCallerID(ctx, sql); ok { return session, nil, err } - return c.fallbackClient.Execute(ctx, mysqlCtx, session, sql, bindVariables) + return c.fallbackClient.Execute(ctx, mysqlCtx, session, sql, bindVariables, prepared) } func (c *callerIDClient) ExecuteBatch(ctx context.Context, session *vtgatepb.Session, sqlList []string, bindVariablesList []map[string]*querypb.BindVariable) (*vtgatepb.Session, []sqltypes.QueryResponse, error) { diff --git a/go/cmd/vtgateclienttest/services/echo.go b/go/cmd/vtgateclienttest/services/echo.go index 2746d8e3ad9..7ffe5b1cfd5 100644 --- a/go/cmd/vtgateclienttest/services/echo.go +++ b/go/cmd/vtgateclienttest/services/echo.go @@ -98,7 +98,14 @@ func echoQueryResult(vals map[string]any) *sqltypes.Result { return qr } -func (c *echoClient) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) { +func (c *echoClient) Execute( + ctx context.Context, + mysqlCtx vtgateservice.MySQLConnection, + session *vtgatepb.Session, + sql string, + bindVariables map[string]*querypb.BindVariable, + prepared bool, +) (*vtgatepb.Session, *sqltypes.Result, error) { if strings.HasPrefix(sql, EchoPrefix) { return session, echoQueryResult(map[string]any{ "callerId": callerid.EffectiveCallerIDFromContext(ctx), @@ -107,7 +114,7 @@ func (c *echoClient) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLCo "session": session, }), nil } - return c.fallbackClient.Execute(ctx, mysqlCtx, session, sql, bindVariables) + return c.fallbackClient.Execute(ctx, mysqlCtx, session, sql, bindVariables, prepared) } func (c *echoClient) StreamExecute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable, callback func(*sqltypes.Result) error) (*vtgatepb.Session, error) { diff --git a/go/cmd/vtgateclienttest/services/errors.go b/go/cmd/vtgateclienttest/services/errors.go index d3af513ee22..f1438a105e4 100644 --- a/go/cmd/vtgateclienttest/services/errors.go +++ b/go/cmd/vtgateclienttest/services/errors.go @@ -110,14 +110,21 @@ func trimmedRequestToError(received string) error { } } -func (c *errorClient) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) { +func (c *errorClient) Execute( + ctx context.Context, + mysqlCtx vtgateservice.MySQLConnection, + session *vtgatepb.Session, + sql string, + bindVariables map[string]*querypb.BindVariable, + prepared bool, +) (*vtgatepb.Session, *sqltypes.Result, error) { if err := requestToPartialError(sql, session); err != nil { return session, nil, err } if err := requestToError(sql); err != nil { return session, nil, err } - return c.fallbackClient.Execute(ctx, mysqlCtx, session, sql, bindVariables) + return c.fallbackClient.Execute(ctx, mysqlCtx, session, sql, bindVariables, prepared) } func (c *errorClient) ExecuteBatch(ctx context.Context, session *vtgatepb.Session, sqlList []string, bindVariablesList []map[string]*querypb.BindVariable) (*vtgatepb.Session, []sqltypes.QueryResponse, error) { diff --git a/go/cmd/vtgateclienttest/services/fallback.go b/go/cmd/vtgateclienttest/services/fallback.go index e4de337b72f..00ad33776df 100644 --- a/go/cmd/vtgateclienttest/services/fallback.go +++ b/go/cmd/vtgateclienttest/services/fallback.go @@ -40,8 +40,15 @@ func newFallbackClient(fallback vtgateservice.VTGateService) fallbackClient { return fallbackClient{fallback: fallback} } -func (c fallbackClient) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) { - return c.fallback.Execute(ctx, mysqlCtx, session, sql, bindVariables) +func (c fallbackClient) Execute( + ctx context.Context, + mysqlCtx vtgateservice.MySQLConnection, + session *vtgatepb.Session, + sql string, + bindVariables map[string]*querypb.BindVariable, + prepared bool, +) (*vtgatepb.Session, *sqltypes.Result, error) { + return c.fallback.Execute(ctx, mysqlCtx, session, sql, bindVariables, prepared) } func (c fallbackClient) ExecuteBatch(ctx context.Context, session *vtgatepb.Session, sqlList []string, bindVariablesList []map[string]*querypb.BindVariable) (*vtgatepb.Session, []sqltypes.QueryResponse, error) { diff --git a/go/cmd/vtgateclienttest/services/terminal.go b/go/cmd/vtgateclienttest/services/terminal.go index 59e57928002..ad1937566f1 100644 --- a/go/cmd/vtgateclienttest/services/terminal.go +++ b/go/cmd/vtgateclienttest/services/terminal.go @@ -43,7 +43,14 @@ func newTerminalClient() *terminalClient { return &terminalClient{} } -func (c *terminalClient) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) { +func (c *terminalClient) Execute( + ctx context.Context, + mysqlCtx vtgateservice.MySQLConnection, + session *vtgatepb.Session, + sql string, + bindVariables map[string]*querypb.BindVariable, + prepared bool, +) (*vtgatepb.Session, *sqltypes.Result, error) { if sql == "quit://" { log.Fatal("Received quit:// query. Going down.") } diff --git a/go/test/endtoend/cluster/cluster_process.go b/go/test/endtoend/cluster/cluster_process.go index ed61f7fd0c9..dd5029f91d3 100644 --- a/go/test/endtoend/cluster/cluster_process.go +++ b/go/test/endtoend/cluster/cluster_process.go @@ -958,7 +958,7 @@ func (cluster *LocalProcessCluster) ExecOnVTGate(ctx context.Context, addr strin session := conn.Session(target, opts) defer conn.Close() - return session.Execute(ctx, sql, bindvars) + return session.Execute(ctx, sql, bindvars, false) } // StreamTabletHealth invokes a HealthStream on a local cluster Vttablet and diff --git a/go/test/endtoend/cluster/cluster_util.go b/go/test/endtoend/cluster/cluster_util.go index 18f78dcb3d0..962120fedbc 100644 --- a/go/test/endtoend/cluster/cluster_util.go +++ b/go/test/endtoend/cluster/cluster_util.go @@ -275,7 +275,7 @@ func positionAtLeast(t *testing.T, tablet *Vttablet, a string, b string) bool { // ExecuteQueriesUsingVtgate sends query to vtgate using vtgate session. func ExecuteQueriesUsingVtgate(t *testing.T, session *vtgateconn.VTGateSession, query string) { - _, err := session.Execute(context.Background(), query, nil) + _, err := session.Execute(context.Background(), query, nil, false) require.Nil(t, err) } diff --git a/go/test/endtoend/recovery/recovery_util.go b/go/test/endtoend/recovery/recovery_util.go index f862b30a9b3..7118507b685 100644 --- a/go/test/endtoend/recovery/recovery_util.go +++ b/go/test/endtoend/recovery/recovery_util.go @@ -45,7 +45,7 @@ var ( // VerifyQueriesUsingVtgate verifies queries using vtgate. func VerifyQueriesUsingVtgate(t *testing.T, session *vtgateconn.VTGateSession, query string, value string) { - qr, err := session.Execute(context.Background(), query, nil) + qr, err := session.Execute(context.Background(), query, nil, false) require.Nil(t, err) assert.Equal(t, value, fmt.Sprintf("%v", qr.Rows[0][0])) } diff --git a/go/vt/proto/vtgate/vtgate.pb.go b/go/vt/proto/vtgate/vtgate.pb.go index 2426d58acf2..c025506ebdf 100644 --- a/go/vt/proto/vtgate/vtgate.pb.go +++ b/go/vt/proto/vtgate/vtgate.pb.go @@ -566,6 +566,7 @@ type ExecuteRequest struct { Session *Session `protobuf:"bytes,2,opt,name=session,proto3" json:"session,omitempty"` // query is the query and bind variables to execute. Query *query.BoundQuery `protobuf:"bytes,3,opt,name=query,proto3" json:"query,omitempty"` + Prepared bool `protobuf:"varint,8,opt,name=prepared,proto3" json:"prepared,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -621,6 +622,13 @@ func (x *ExecuteRequest) GetQuery() *query.BoundQuery { return nil } +func (x *ExecuteRequest) GetPrepared() bool { + if x != nil { + return x.Prepared + } + return false +} + // ExecuteResponse is the returned value from Execute. type ExecuteResponse struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -1743,7 +1751,7 @@ var file_vtgate_proto_rawDesc = string([]byte{ 0x6f, 0x75, 0x74, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x67, 0x74, 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x47, 0x74, - 0x69, 0x64, 0x73, 0x22, 0xaa, 0x01, 0x0a, 0x0e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, + 0x69, 0x64, 0x73, 0x22, 0xc6, 0x01, 0x0a, 0x0e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x44, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, @@ -1752,150 +1760,152 @@ var file_vtgate_proto_rawDesc = string([]byte{ 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x27, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, - 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, - 0x22, 0x8f, 0x01, 0x0a, 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x50, 0x43, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x29, 0x0a, 0x07, 0x73, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, - 0x74, 0x67, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x22, 0xb3, 0x01, 0x0a, 0x13, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x42, 0x61, - 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x61, + 0x79, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x70, + 0x61, 0x72, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x70, 0x72, 0x65, 0x70, + 0x61, 0x72, 0x65, 0x64, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, + 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x22, 0x8f, 0x01, 0x0a, + 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x25, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, + 0x65, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0xb3, + 0x01, 0x0a, 0x13, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, + 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x44, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, + 0x65, 0x72, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, 0x2e, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x2b, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x11, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x4a, 0x04, 0x08, 0x04, + 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, + 0x08, 0x07, 0x10, 0x08, 0x22, 0x9a, 0x01, 0x0a, 0x14, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, + 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, + 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, 0x2e, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x30, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x16, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x57, + 0x69, 0x74, 0x68, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x73, 0x22, 0xaa, 0x01, 0x0a, 0x14, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x78, 0x65, 0x63, + 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x44, 0x52, 0x08, - 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, - 0x74, 0x65, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x42, 0x6f, 0x75, - 0x6e, 0x64, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, - 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x06, - 0x10, 0x07, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x22, 0x9a, 0x01, 0x0a, 0x14, 0x45, 0x78, 0x65, - 0x63, 0x75, 0x74, 0x65, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, + 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, + 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, + 0x79, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x03, + 0x10, 0x04, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x22, 0x6e, + 0x0a, 0x15, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x5d, + 0x0a, 0x19, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x09, 0x63, + 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, + 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x44, 0x52, + 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x74, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x74, 0x69, 0x64, 0x22, 0x1c, 0x0a, + 0x1a, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xef, 0x02, 0x0a, 0x0c, + 0x56, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x23, 0x0a, 0x0d, + 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x69, 0x7a, 0x65, 0x5f, 0x73, 0x6b, 0x65, 0x77, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x69, 0x7a, 0x65, 0x53, 0x6b, 0x65, + 0x77, 0x12, 0x2d, 0x0a, 0x12, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x5f, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x68, + 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, + 0x12, 0x26, 0x0a, 0x0f, 0x73, 0x74, 0x6f, 0x70, 0x5f, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x68, + 0x61, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x73, 0x74, 0x6f, 0x70, 0x4f, + 0x6e, 0x52, 0x65, 0x73, 0x68, 0x61, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x65, 0x6c, 0x6c, + 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x65, 0x6c, 0x6c, 0x73, 0x12, 0x27, + 0x0a, 0x0f, 0x63, 0x65, 0x6c, 0x6c, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x65, 0x6c, 0x6c, 0x50, 0x72, 0x65, + 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x61, 0x62, 0x6c, 0x65, + 0x74, 0x5f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x74, + 0x61, 0x62, 0x6c, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x3c, 0x0a, 0x1a, 0x73, 0x74, + 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x68, 0x65, + 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, + 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x48, 0x65, + 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x73, 0x12, 0x43, 0x0a, 0x1e, 0x69, 0x6e, 0x63, 0x6c, + 0x75, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6a, 0x6f, 0x75, 0x72, + 0x6e, 0x61, 0x6c, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x1b, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x52, 0x65, 0x73, 0x68, 0x61, 0x72, 0x64, + 0x4a, 0x6f, 0x75, 0x72, 0x6e, 0x61, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xf6, 0x01, + 0x0a, 0x0e, 0x56, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, + 0x65, 0x72, 0x49, 0x44, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x64, 0x12, 0x35, + 0x0a, 0x0b, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, + 0x61, 0x62, 0x6c, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x27, 0x0a, 0x05, 0x76, 0x67, 0x74, 0x69, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x62, 0x69, 0x6e, 0x6c, 0x6f, 0x67, 0x64, 0x61, 0x74, + 0x61, 0x2e, 0x56, 0x47, 0x74, 0x69, 0x64, 0x52, 0x05, 0x76, 0x67, 0x74, 0x69, 0x64, 0x12, 0x2a, + 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x62, 0x69, 0x6e, 0x6c, 0x6f, 0x67, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x05, 0x66, 0x6c, + 0x61, 0x67, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x76, 0x74, 0x67, 0x61, + 0x74, 0x65, 0x2e, 0x56, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x52, + 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x22, 0x3d, 0x0a, 0x0f, 0x56, 0x53, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x62, 0x69, 0x6e, 0x6c, + 0x6f, 0x67, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x56, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x92, 0x01, 0x0a, 0x0e, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, + 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, + 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x44, 0x52, 0x08, 0x63, 0x61, + 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, + 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x27, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x11, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0xac, 0x01, 0x0a, 0x0f, 0x50, + 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, + 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, + 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, 0x2e, + 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x24, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0c, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x52, 0x06, + 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x70, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x6e, 0x0a, 0x13, 0x43, 0x6c, 0x6f, + 0x73, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, + 0x65, 0x72, 0x49, 0x44, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x64, 0x12, 0x29, + 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3d, 0x0a, 0x14, 0x43, 0x6c, 0x6f, + 0x73, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, - 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, - 0x74, 0x65, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x52, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x57, 0x69, 0x74, 0x68, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x07, 0x72, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0xaa, 0x01, 0x0a, 0x14, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, - 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, - 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x65, 0x72, - 0x49, 0x44, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x05, - 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x71, 0x75, - 0x65, 0x72, 0x79, 0x2e, 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x05, - 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, 0x2e, - 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, - 0x10, 0x06, 0x22, 0x6e, 0x0a, 0x15, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x78, 0x65, 0x63, - 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x72, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x71, 0x75, - 0x65, 0x72, 0x79, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, - 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, - 0x65, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x22, 0x5d, 0x0a, 0x19, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x54, 0x72, 0x61, - 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x2c, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x65, - 0x72, 0x49, 0x44, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, - 0x04, 0x64, 0x74, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x74, 0x69, - 0x64, 0x22, 0x1c, 0x0a, 0x1a, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0xef, 0x02, 0x0a, 0x0c, 0x56, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x46, 0x6c, 0x61, 0x67, 0x73, - 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x69, 0x7a, 0x65, 0x5f, 0x73, 0x6b, 0x65, - 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x69, 0x7a, - 0x65, 0x53, 0x6b, 0x65, 0x77, 0x12, 0x2d, 0x0a, 0x12, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, - 0x61, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x11, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x76, 0x61, 0x6c, 0x12, 0x26, 0x0a, 0x0f, 0x73, 0x74, 0x6f, 0x70, 0x5f, 0x6f, 0x6e, 0x5f, - 0x72, 0x65, 0x73, 0x68, 0x61, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x73, - 0x74, 0x6f, 0x70, 0x4f, 0x6e, 0x52, 0x65, 0x73, 0x68, 0x61, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, - 0x63, 0x65, 0x6c, 0x6c, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x65, 0x6c, - 0x6c, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x65, 0x6c, 0x6c, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x65, - 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x65, 0x6c, - 0x6c, 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x74, 0x5f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x3c, - 0x0a, 0x1a, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x5f, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x73, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x18, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x73, 0x12, 0x43, 0x0a, 0x1e, - 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, - 0x6a, 0x6f, 0x75, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x08, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x52, 0x65, 0x73, - 0x68, 0x61, 0x72, 0x64, 0x4a, 0x6f, 0x75, 0x72, 0x6e, 0x61, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x73, 0x22, 0xf6, 0x01, 0x0a, 0x0e, 0x56, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, - 0x43, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x44, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, - 0x49, 0x64, 0x12, 0x35, 0x0a, 0x0b, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x64, 0x61, - 0x74, 0x61, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x27, 0x0a, 0x05, 0x76, 0x67, 0x74, - 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x62, 0x69, 0x6e, 0x6c, 0x6f, - 0x67, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x56, 0x47, 0x74, 0x69, 0x64, 0x52, 0x05, 0x76, 0x67, 0x74, - 0x69, 0x64, 0x12, 0x2a, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x62, 0x69, 0x6e, 0x6c, 0x6f, 0x67, 0x64, 0x61, 0x74, 0x61, 0x2e, - 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x2a, - 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, - 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, 0x2e, 0x56, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x46, 0x6c, - 0x61, 0x67, 0x73, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x22, 0x3d, 0x0a, 0x0f, 0x56, 0x53, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, - 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, - 0x62, 0x69, 0x6e, 0x6c, 0x6f, 0x67, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x56, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x92, 0x01, 0x0a, 0x0e, 0x50, 0x72, - 0x65, 0x70, 0x61, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x09, - 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x44, - 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, - 0x67, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x27, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x42, 0x6f, 0x75, - 0x6e, 0x64, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0xac, - 0x01, 0x0a, 0x0f, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, - 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, - 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x46, 0x69, 0x65, - 0x6c, 0x64, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x0b, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x6e, 0x0a, - 0x13, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, - 0x43, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x44, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, - 0x49, 0x64, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3d, 0x0a, - 0x14, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x50, 0x43, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2a, 0x44, 0x0a, 0x0f, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x12, - 0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x49, 0x4e, 0x47, 0x4c, 0x45, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, - 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x57, 0x4f, 0x50, 0x43, - 0x10, 0x03, 0x2a, 0x3c, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64, 0x65, - 0x72, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x07, 0x0a, - 0x03, 0x50, 0x52, 0x45, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4f, 0x53, 0x54, 0x10, 0x02, - 0x12, 0x0e, 0x0a, 0x0a, 0x41, 0x55, 0x54, 0x4f, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x03, - 0x42, 0x36, 0x0a, 0x0f, 0x69, 0x6f, 0x2e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x5a, 0x23, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6f, 0x2f, 0x76, - 0x69, 0x74, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x76, 0x74, 0x67, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2a, 0x44, 0x0a, 0x0f, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x55, + 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, + 0x53, 0x49, 0x4e, 0x47, 0x4c, 0x45, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x55, 0x4c, 0x54, + 0x49, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x57, 0x4f, 0x50, 0x43, 0x10, 0x03, 0x2a, 0x3c, + 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x0a, 0x0a, + 0x06, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x52, 0x45, + 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4f, 0x53, 0x54, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, + 0x41, 0x55, 0x54, 0x4f, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x03, 0x42, 0x36, 0x0a, 0x0f, + 0x69, 0x6f, 0x2e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5a, + 0x23, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6f, 0x2f, 0x76, 0x69, 0x74, 0x65, 0x73, + 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x74, + 0x67, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, }) var ( diff --git a/go/vt/proto/vtgate/vtgate_vtproto.pb.go b/go/vt/proto/vtgate/vtgate_vtproto.pb.go index 67c5df2a18c..383ea6300eb 100644 --- a/go/vt/proto/vtgate/vtgate_vtproto.pb.go +++ b/go/vt/proto/vtgate/vtgate_vtproto.pb.go @@ -186,6 +186,7 @@ func (m *ExecuteRequest) CloneVT() *ExecuteRequest { r.CallerId = m.CallerId.CloneVT() r.Session = m.Session.CloneVT() r.Query = m.Query.CloneVT() + r.Prepared = m.Prepared if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) copy(r.unknownFields, m.unknownFields) @@ -1021,6 +1022,16 @@ func (m *ExecuteRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if m.Prepared { + i-- + if m.Prepared { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } if m.Query != nil { size, err := m.Query.MarshalToSizedBufferVT(dAtA[:i]) if err != nil { @@ -2122,6 +2133,9 @@ func (m *ExecuteRequest) SizeVT() (n int) { l = m.Query.SizeVT() n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } + if m.Prepared { + n += 2 + } n += len(m.unknownFields) return n } @@ -4128,6 +4142,26 @@ func (m *ExecuteRequest) UnmarshalVT(dAtA []byte) error { return err } iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Prepared", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Prepared = bool(v != 0) default: iNdEx = preIndex skippy, err := protohelpers.Skip(dAtA[iNdEx:]) diff --git a/go/vt/vitessdriver/driver.go b/go/vt/vitessdriver/driver.go index 4a965399e9c..25da8c3bb8d 100644 --- a/go/vt/vitessdriver/driver.go +++ b/go/vt/vitessdriver/driver.go @@ -491,7 +491,7 @@ func (c *conn) Exec(query string, args []driver.Value) (driver.Result, error) { return nil, err } - qr, err := c.session.Execute(ctx, query, bindVars) + qr, err := c.session.Execute(ctx, query, bindVars, false) if err != nil { return nil, err } @@ -507,7 +507,7 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name if err != nil { return nil, err } - qr, err := c.session.Execute(ctx, query, bv) + qr, err := c.session.Execute(ctx, query, bv, false) if err != nil { return nil, err } @@ -529,7 +529,7 @@ func (c *conn) Query(query string, args []driver.Value) (driver.Rows, error) { return newStreamingRows(stream, c.convert), nil } - qr, err := c.session.Execute(ctx, query, bindVars) + qr, err := c.session.Execute(ctx, query, bindVars, false) if err != nil { return nil, err } @@ -555,7 +555,7 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam return newStreamingRows(stream, c.convert), nil } - qr, err := c.session.Execute(ctx, query, bv) + qr, err := c.session.Execute(ctx, query, bv, false) if err != nil { return nil, err } diff --git a/go/vt/vitessdriver/fakeserver_test.go b/go/vt/vitessdriver/fakeserver_test.go index 139075e03c1..c7529835c7d 100644 --- a/go/vt/vitessdriver/fakeserver_test.go +++ b/go/vt/vitessdriver/fakeserver_test.go @@ -48,7 +48,14 @@ func (q *queryExecute) Equal(q2 *queryExecute) bool { } // Execute is part of the VTGateService interface -func (f *fakeVTGateService) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) { +func (f *fakeVTGateService) Execute( + ctx context.Context, + mysqlCtx vtgateservice.MySQLConnection, + session *vtgatepb.Session, + sql string, + bindVariables map[string]*querypb.BindVariable, + prepared bool, +) (*vtgatepb.Session, *sqltypes.Result, error) { execCase, ok := execMap[sql] if !ok { return session, nil, fmt.Errorf("no match for: %s", sql) diff --git a/go/vt/vtexplain/vtexplain_vtgate.go b/go/vt/vtexplain/vtexplain_vtgate.go index 155fe6de743..7d25758a30e 100644 --- a/go/vt/vtexplain/vtexplain_vtgate.go +++ b/go/vt/vtexplain/vtexplain_vtgate.go @@ -243,7 +243,7 @@ func (vte *VTExplain) vtgateExecute(sql string) ([]*engine.Plan, map[string]*Tab // This will ensure that the commit/rollback order is predictable. vte.sortShardSession() - _, err := vte.vtgateExecutor.Execute(context.Background(), nil, "VtexplainExecute", econtext.NewSafeSession(vte.vtgateSession), sql, nil) + _, err := vte.vtgateExecutor.Execute(context.Background(), nil, "VtexplainExecute", econtext.NewSafeSession(vte.vtgateSession), sql, nil, false) if err != nil { for _, tc := range vte.explainTopo.TabletConns { tc.tabletQueries = nil diff --git a/go/vt/vtgate/autocommit_test.go b/go/vt/vtgate/autocommit_test.go index 2e65cefbabe..33d78be889c 100644 --- a/go/vt/vtgate/autocommit_test.go +++ b/go/vt/vtgate/autocommit_test.go @@ -26,7 +26,6 @@ import ( querypb "vitess.io/vitess/go/vt/proto/query" vtgatepb "vitess.io/vitess/go/vt/proto/vtgate" vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" - econtext "vitess.io/vitess/go/vt/vtgate/executorcontext" ) // This file contains tests for all the autocommit code paths @@ -382,7 +381,7 @@ func TestAutocommitTransactionStarted(t *testing.T) { // single shard query - no savepoint needed sql := "update `user` set a = 2 where id = 1" - _, err := executor.Execute(context.Background(), nil, "TestExecute", econtext.NewSafeSession(session), sql, map[string]*querypb.BindVariable{}) + _, err := executorExec(context.Background(), executor, session, sql, map[string]*querypb.BindVariable{}) require.NoError(t, err) require.Len(t, sbc1.Queries, 1) require.Equal(t, sql, sbc1.Queries[0].Sql) @@ -394,7 +393,7 @@ func TestAutocommitTransactionStarted(t *testing.T) { // multi shard query - savepoint needed sql = "update `user` set a = 2 where id in (1, 4)" expectedSql := "update `user` set a = 2 where id in ::__vals" - _, err = executor.Execute(context.Background(), nil, "TestExecute", econtext.NewSafeSession(session), sql, map[string]*querypb.BindVariable{}) + _, err = executorExec(context.Background(), executor, session, sql, map[string]*querypb.BindVariable{}) require.NoError(t, err) require.Len(t, sbc1.Queries, 2) require.Contains(t, sbc1.Queries[0].Sql, "savepoint") @@ -413,7 +412,7 @@ func TestAutocommitDirectTarget(t *testing.T) { } sql := "insert into `simple`(val) values ('val')" - _, err := executor.Execute(context.Background(), nil, "TestExecute", econtext.NewSafeSession(session), sql, map[string]*querypb.BindVariable{}) + _, err := executorExec(context.Background(), executor, session, sql, map[string]*querypb.BindVariable{}) require.NoError(t, err) assertQueries(t, sbclookup, []*querypb.BoundQuery{{ @@ -434,7 +433,7 @@ func TestAutocommitDirectRangeTarget(t *testing.T) { } sql := "delete from sharded_user_msgs limit 1000" - _, err := executor.Execute(context.Background(), nil, "TestExecute", econtext.NewSafeSession(session), sql, map[string]*querypb.BindVariable{}) + _, err := executorExec(context.Background(), executor, session, sql, map[string]*querypb.BindVariable{}) require.NoError(t, err) assertQueries(t, sbc1, []*querypb.BoundQuery{{ @@ -451,5 +450,5 @@ func autocommitExec(executor *Executor, sql string) (*sqltypes.Result, error) { TransactionMode: vtgatepb.TransactionMode_MULTI, } - return executor.Execute(context.Background(), nil, "TestExecute", econtext.NewSafeSession(session), sql, map[string]*querypb.BindVariable{}) + return executorExec(context.Background(), executor, session, sql, map[string]*querypb.BindVariable{}) } diff --git a/go/vt/vtgate/bench_test.go b/go/vt/vtgate/bench_test.go index c2336662c69..d1875f00508 100644 --- a/go/vt/vtgate/bench_test.go +++ b/go/vt/vtgate/bench_test.go @@ -70,6 +70,7 @@ func BenchmarkWithNormalizer(b *testing.B) { }, benchQuery, nil, + false, ) if err != nil { panic(err) @@ -92,6 +93,7 @@ func BenchmarkWithoutNormalizer(b *testing.B) { }, benchQuery, nil, + false, ) if err != nil { panic(err) diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index 93e87ea9ba6..3e4b1be7efd 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -229,14 +229,22 @@ func NewExecutor( } // Execute executes a non-streaming query. -func (e *Executor) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, method string, safeSession *econtext.SafeSession, sql string, bindVars map[string]*querypb.BindVariable) (result *sqltypes.Result, err error) { +func (e *Executor) Execute( + ctx context.Context, + mysqlCtx vtgateservice.MySQLConnection, + method string, + safeSession *econtext.SafeSession, + sql string, + bindVars map[string]*querypb.BindVariable, + prepared bool, +) (result *sqltypes.Result, err error) { span, ctx := trace.NewSpan(ctx, "executor.Execute") span.Annotate("method", method) trace.AnnotateSQL(span, sqlparser.Preview(sql)) defer span.Finish() logStats := logstats.NewLogStats(ctx, method, sql, safeSession.GetSessionUUID(), bindVars, streamlog.GetQueryLogConfig()) - stmtType, result, err := e.execute(ctx, mysqlCtx, safeSession, sql, bindVars, logStats) + stmtType, result, err := e.execute(ctx, mysqlCtx, safeSession, sql, bindVars, prepared, logStats) logStats.Error = err if result == nil { saveSessionStats(safeSession, stmtType, 0, 0, err) @@ -377,7 +385,7 @@ func (e *Executor) StreamExecute( return err } - err = e.newExecute(ctx, mysqlCtx, safeSession, sql, bindVars, logStats, resultHandler, srr.storeResultStats) + err = e.newExecute(ctx, mysqlCtx, safeSession, sql, bindVars, false, logStats, resultHandler, srr.storeResultStats) logStats.Error = err saveSessionStats(safeSession, srr.stmtType, srr.rowsAffected, srr.rowsReturned, err) @@ -429,11 +437,11 @@ func saveSessionStats(safeSession *econtext.SafeSession, stmtType sqlparser.Stat } } -func (e *Executor) execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, safeSession *econtext.SafeSession, sql string, bindVars map[string]*querypb.BindVariable, logStats *logstats.LogStats) (sqlparser.StatementType, *sqltypes.Result, error) { +func (e *Executor) execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, safeSession *econtext.SafeSession, sql string, bindVars map[string]*querypb.BindVariable, prepared bool, logStats *logstats.LogStats) (sqlparser.StatementType, *sqltypes.Result, error) { var err error var qr *sqltypes.Result var stmtType sqlparser.StatementType - err = e.newExecute(ctx, mysqlCtx, safeSession, sql, bindVars, logStats, func(ctx context.Context, plan *engine.Plan, vc *econtext.VCursorImpl, bindVars map[string]*querypb.BindVariable, time time.Time) error { + err = e.newExecute(ctx, mysqlCtx, safeSession, sql, bindVars, prepared, logStats, func(ctx context.Context, plan *engine.Plan, vc *econtext.VCursorImpl, bindVars map[string]*querypb.BindVariable, time time.Time) error { stmtType = plan.Type qr, err = e.executePlan(ctx, safeSession, plan, vc, bindVars, logStats, time) return err diff --git a/go/vt/vtgate/executor_ddl_test.go b/go/vt/vtgate/executor_ddl_test.go index bf117856e08..08c4091b41b 100644 --- a/go/vt/vtgate/executor_ddl_test.go +++ b/go/vt/vtgate/executor_ddl_test.go @@ -60,7 +60,7 @@ func TestDDLFlags(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: KsTestUnsharded}) enableDirectDDL.Set(testcase.enableDirectDDL) enableOnlineDDL.Set(testcase.enableOnlineDDL) - _, err := executor.Execute(ctx, nil, "TestDDLFlags", session, testcase.sql, nil) + _, err := executor.Execute(ctx, nil, "TestDDLFlags", session, testcase.sql, nil, false) if testcase.wantErr { require.EqualError(t, err, testcase.err) } else { diff --git a/go/vt/vtgate/executor_dml_test.go b/go/vt/vtgate/executor_dml_test.go index e791acceb6b..1078d4203e1 100644 --- a/go/vt/vtgate/executor_dml_test.go +++ b/go/vt/vtgate/executor_dml_test.go @@ -238,9 +238,9 @@ func TestUpdateInTransactionLookupDefaultReadLock(t *testing.T) { safeSession := econtext.NewSafeSession(&vtgatepb.Session{InTransaction: true}) _, err := executorExecSession(ctx, executor, + safeSession, "update t2_lookup set lu_col = 5 where nv_lu_col = 2", nil, - safeSession.Session, ) require.NoError(t, err) @@ -300,9 +300,9 @@ func TestUpdateInTransactionLookupExclusiveReadLock(t *testing.T) { safeSession := econtext.NewSafeSession(&vtgatepb.Session{InTransaction: true}) _, err := executorExecSession(ctx, executor, + safeSession, "update t2_lookup set lu_col = 5 where erl_lu_col = 2", nil, - safeSession.Session, ) require.NoError(t, err) @@ -362,9 +362,9 @@ func TestUpdateInTransactionLookupSharedReadLock(t *testing.T) { safeSession := econtext.NewSafeSession(&vtgatepb.Session{InTransaction: true}) _, err := executorExecSession(ctx, executor, + safeSession, "update t2_lookup set lu_col = 5 where srl_lu_col = 2", nil, - safeSession.Session, ) require.NoError(t, err) @@ -424,9 +424,9 @@ func TestUpdateInTransactionLookupNoReadLock(t *testing.T) { safeSession := econtext.NewSafeSession(&vtgatepb.Session{InTransaction: true}) _, err := executorExecSession(ctx, executor, + safeSession, "update t2_lookup set lu_col = 5 where nrl_lu_col = 2", nil, - safeSession.Session, ) require.NoError(t, err) @@ -1474,7 +1474,7 @@ func TestInsertShardedAutocommitLookup(t *testing.T) { ` executor, sbc1, sbc2, sbclookup, ctx := createCustomExecutor(t, vschema, config.DefaultMySQLVersion) - _, err := executorExecSession(ctx, executor, "insert into user(id, v, name, music) values (1, 2, 'myname', 'star')", nil, &vtgatepb.Session{}) + _, err := executorExec(ctx, executor, &vtgatepb.Session{}, "insert into user(id, v, name, music) values (1, 2, 'myname', 'star')", nil) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{{ Sql: "insert into `user`(id, v, `name`, music) values (:_Id_0, 2, :_name_0, :_music_0)", @@ -2075,6 +2075,7 @@ func TestInsertPartialFail1(t *testing.T) { econtext.NewSafeSession(&vtgatepb.Session{InTransaction: true}), "insert into user(id, v, name) values (1, 2, 'myname')", nil, + false, ) require.Error(t, err) } @@ -2096,6 +2097,7 @@ func TestInsertPartialFail2(t *testing.T) { safeSession, "insert into user(id, v, name) values (1, 2, 'myname')", nil, + false, ) want := "reverted partial DML execution failure" @@ -2659,7 +2661,7 @@ func TestReservedConnDML(t *testing.T) { session := econtext.NewAutocommitSession(&vtgatepb.Session{EnableSystemSettings: true}) - _, err := executor.Execute(ctx, nil, "TestReservedConnDML", session, "use "+KsTestUnsharded, nil) + _, err := executor.Execute(ctx, nil, "TestReservedConnDML", session, "use "+KsTestUnsharded, nil, false) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{ @@ -2668,24 +2670,24 @@ func TestReservedConnDML(t *testing.T) { sbc.SetResults([]*sqltypes.Result{ sqltypes.MakeTestResult(sqltypes.MakeTestFields("id", "int64"), "1"), }) - _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "set default_week_format = 1", nil) + _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "set default_week_format = 1", nil, false) require.NoError(t, err) assertQueries(t, sbc, wantQueries) - _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "begin", nil) + _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "begin", nil, false) require.NoError(t, err) wantQueries = append(wantQueries, &querypb.BoundQuery{Sql: "set default_week_format = 1", BindVariables: map[string]*querypb.BindVariable{}}, &querypb.BoundQuery{Sql: "insert into `simple`() values ()", BindVariables: map[string]*querypb.BindVariable{}}) - _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "insert into `simple`() values ()", nil) + _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "insert into `simple`() values ()", nil, false) require.NoError(t, err) assertQueries(t, sbc, wantQueries) - _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "commit", nil) + _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "commit", nil, false) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "begin", nil) + _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "begin", nil, false) require.NoError(t, err) sbc.EphemeralShardErr = sqlerror.NewSQLError(sqlerror.CRServerGone, sqlerror.SSNetError, "connection gone") @@ -2693,11 +2695,11 @@ func TestReservedConnDML(t *testing.T) { wantQueries = append(wantQueries, &querypb.BoundQuery{Sql: "set default_week_format = 1", BindVariables: map[string]*querypb.BindVariable{}}, &querypb.BoundQuery{Sql: "insert into `simple`() values ()", BindVariables: map[string]*querypb.BindVariable{}}) - _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "insert into `simple`() values ()", nil) + _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "insert into `simple`() values ()", nil, false) require.NoError(t, err) assertQueries(t, sbc, wantQueries) - _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "commit", nil) + _, err = executor.Execute(ctx, nil, "TestReservedConnDML", session, "commit", nil, false) require.NoError(t, err) } @@ -2797,7 +2799,7 @@ func TestPartialVindexInsertQueryFailure(t *testing.T) { require.True(t, session.GetAutocommit()) require.False(t, session.InTransaction()) - _, err := executorExecSession(ctx, executor, "begin", nil, session.Session) + _, err := executorExecSession(ctx, executor, session, "begin", nil) require.NoError(t, err) require.True(t, session.GetAutocommit()) require.True(t, session.InTransaction()) @@ -2818,7 +2820,7 @@ func TestPartialVindexInsertQueryFailure(t *testing.T) { BindVariables: map[string]*querypb.BindVariable{}, }} - _, err = executorExecSession(ctx, executor, "insert into t1(id, unq_col) values (1, 1), (2, 3)", nil, session.Session) + _, err = executorExecSession(ctx, executor, session, "insert into t1(id, unq_col) values (1, 1), (2, 3)", nil) require.Error(t, err) require.Contains(t, err.Error(), "reverted partial DML execution failure") require.True(t, session.GetAutocommit()) @@ -2860,7 +2862,7 @@ func TestPartialVindexInsertQueryFailureAutoCommit(t *testing.T) { }, }} - _, err := executorExecSession(ctx, executor, "insert into t1(id, unq_col) values (1, 1), (2, 3)", nil, session.Session) + _, err := executorExecSession(ctx, executor, session, "insert into t1(id, unq_col) values (1, 1), (2, 3)", nil) require.Error(t, err) assert.Contains(t, err.Error(), "transaction rolled back to reverse changes of partial DML execution") assert.True(t, session.GetAutocommit()) @@ -2888,11 +2890,11 @@ func TestMultiInternalSavepoint(t *testing.T) { executor, sbc1, sbc2, _, ctx := createExecutorEnv(t) session := econtext.NewAutocommitSession(&vtgatepb.Session{}) - _, err := executorExecSession(ctx, executor, "begin", nil, session.Session) + _, err := executorExec(ctx, executor, session.Session, "begin", nil) require.NoError(t, err) // this query goes to multiple shards so internal savepoint will be created. - _, err = executorExecSession(ctx, executor, "insert into user_extra(user_id) values (1), (4)", nil, session.Session) + _, err = executorExec(ctx, executor, session.Session, "insert into user_extra(user_id) values (1), (4)", nil) require.NoError(t, err) wantQ := []*querypb.BoundQuery{{ @@ -2908,7 +2910,7 @@ func TestMultiInternalSavepoint(t *testing.T) { require.Len(t, sbc2.Queries, 0) sbc1.Queries = nil - _, err = executorExecSession(ctx, executor, "insert into user_extra(user_id) values (3), (6)", nil, session.Session) + _, err = executorExec(ctx, executor, session.Session, "insert into user_extra(user_id) values (3), (6)", nil) require.NoError(t, err) wantQ = []*querypb.BoundQuery{{ Sql: "savepoint x", @@ -2968,19 +2970,19 @@ func TestInsertSelectFromDual(t *testing.T) { // set result for dual query. sbc1.SetResults([]*sqltypes.Result{sqltypes.MakeTestResult(sqltypes.MakeTestFields("1|2|myname", "int64|int64|varchar"), "1|2|myname")}) - _, err := executor.Execute(context.Background(), nil, "TestInsertSelect", session, wQuery, nil) + _, err := executorExecSession(context.Background(), executor, session, wQuery, nil) require.NoError(t, err) - _, err = executor.Execute(context.Background(), nil, "TestInsertSelect", session, query, nil) + _, err = executorExecSession(context.Background(), executor, session, query, nil) require.NoError(t, err) assertQueries(t, sbc1, wantQueries) assertQueries(t, sbc2, nil) assertQueries(t, sbclookup, wantlkpQueries) - testQueryLog(t, executor, logChan, "TestInsertSelect", "SET", wQuery, 0) + testQueryLog(t, executor, logChan, "TestExecute", "SET", wQuery, 0) testQueryLog(t, executor, logChan, "VindexCreate", "INSERT", "insert into name_user_map(`name`, user_id) values (:name_0, :user_id_0)", 1) - testQueryLog(t, executor, logChan, "TestInsertSelect", "INSERT", "insert into `user`(id, v, `name`) select 1, 2, 'myname' from dual", 2) + testQueryLog(t, executor, logChan, "TestExecute", "INSERT", "insert into `user`(id, v, `name`) select 1, 2, 'myname' from dual", 2) }) } } @@ -3030,19 +3032,19 @@ func TestInsertSelectFromTable(t *testing.T) { sbc2.Queries = nil sbclookup.Queries = nil wQuery := fmt.Sprintf("set @@workload = %s", workload) - _, err := executor.Execute(context.Background(), nil, "TestInsertSelect", session, wQuery, nil) + _, err := executorExecSession(context.Background(), executor, session, wQuery, nil) require.NoError(t, err) - _, err = executor.Execute(context.Background(), nil, "TestInsertSelect", session, query, nil) + _, err = executorExecSession(context.Background(), executor, session, query, nil) require.NoError(t, err) assertQueries(t, sbc1, wantQueries) assertQueries(t, sbc2, wantQueries[:1]) // select scatter query went scatter. assertQueries(t, sbclookup, wantlkpQueries) - testQueryLog(t, executor, logChan, "TestInsertSelect", "SET", wQuery, 0) + testQueryLog(t, executor, logChan, "TestExecute", "SET", wQuery, 0) testQueryLog(t, executor, logChan, "VindexCreate", "INSERT", "insert into name_user_map(`name`, user_id) values (:name_0, :user_id_0), (:name_1, :user_id_1), (:name_2, :user_id_2), (:name_3, :user_id_3), (:name_4, :user_id_4), (:name_5, :user_id_5), (:name_6, :user_id_6), (:name_7, :user_id_7)", 1) - testQueryLog(t, executor, logChan, "TestInsertSelect", "INSERT", "insert into `user`(id, `name`) select c1, c2 from music", 9) // 8 from select and 1 from insert. + testQueryLog(t, executor, logChan, "TestExecute", "INSERT", "insert into `user`(id, `name`) select c1, c2 from music", 9) // 8 from select and 1 from insert. } } @@ -3144,59 +3146,58 @@ func TestDeleteMultiTable(t *testing.T) { // TestSessionRowsAffected test that rowsAffected is set correctly for each shard session. func TestSessionRowsAffected(t *testing.T) { - method := t.Name() executor, _, sbc4060, _, ctx := createExecutorEnv(t) session := econtext.NewAutocommitSession(&vtgatepb.Session{}) // start the transaction - _, err := executor.Execute(ctx, nil, method, session, "begin", nil) + _, err := executorExecSession(ctx, executor, session, "begin", nil) require.NoError(t, err) // -20 - select query - _, err = executor.Execute(ctx, nil, method, session, "select * from user where id = 1", nil) + _, err = executorExecSession(ctx, executor, session, "select * from user where id = 1", nil) require.NoError(t, err) require.Len(t, session.ShardSessions, 1) require.False(t, session.ShardSessions[0].RowsAffected) // -20 - update query (rows affected) - _, err = executor.Execute(ctx, nil, method, session, "update user set foo = 41 where id = 1", nil) + _, err = executorExecSession(ctx, executor, session, "update user set foo = 41 where id = 1", nil) require.NoError(t, err) require.True(t, session.ShardSessions[0].RowsAffected) // e0- - select query - _, err = executor.Execute(ctx, nil, method, session, "select * from user where id = 7", nil) + _, err = executorExecSession(ctx, executor, session, "select * from user where id = 7", nil) require.NoError(t, err) assert.Len(t, session.ShardSessions, 2) require.False(t, session.ShardSessions[1].RowsAffected) // c0-e0 - update query (rows affected) - _, err = executor.Execute(ctx, nil, method, session, "update user set foo = 42 where id = 5", nil) + _, err = executorExecSession(ctx, executor, session, "update user set foo = 42 where id = 5", nil) require.NoError(t, err) require.Len(t, session.ShardSessions, 3) require.True(t, session.ShardSessions[2].RowsAffected) // 40-60 - update query (no rows affected) sbc4060.SetResults([]*sqltypes.Result{{RowsAffected: 0}}) - _, err = executor.Execute(ctx, nil, method, session, "update user set foo = 42 where id = 3", nil) + _, err = executorExecSession(ctx, executor, session, "update user set foo = 42 where id = 3", nil) require.NoError(t, err) assert.Len(t, session.ShardSessions, 4) require.False(t, session.ShardSessions[3].RowsAffected) // 40-60 - select query - _, err = executor.Execute(ctx, nil, method, session, "select * from user where id = 3", nil) + _, err = executorExecSession(ctx, executor, session, "select * from user where id = 3", nil) require.NoError(t, err) require.False(t, session.ShardSessions[3].RowsAffected) // 40-60 - delete query (rows affected) - _, err = executor.Execute(ctx, nil, method, session, "delete from user where id = 3", nil) + _, err = executorExecSession(ctx, executor, session, "delete from user where id = 3", nil) require.NoError(t, err) require.True(t, session.ShardSessions[0].RowsAffected) require.False(t, session.ShardSessions[1].RowsAffected) require.True(t, session.ShardSessions[2].RowsAffected) require.True(t, session.ShardSessions[3].RowsAffected) - _, err = executor.Execute(ctx, nil, method, session, "commit", nil) + _, err = executorExecSession(ctx, executor, session, "commit", nil) require.NoError(t, err) require.Zero(t, session.ShardSessions) } diff --git a/go/vt/vtgate/executor_framework_test.go b/go/vt/vtgate/executor_framework_test.go index 543d625de80..88455e8331f 100644 --- a/go/vt/vtgate/executor_framework_test.go +++ b/go/vt/vtgate/executor_framework_test.go @@ -320,26 +320,16 @@ func createExecutorEnvWithPrimaryReplicaConn(t testing.TB, ctx context.Context, return executor, primary, replica } -func executorExecSession(ctx context.Context, executor *Executor, sql string, bv map[string]*querypb.BindVariable, session *vtgatepb.Session) (*sqltypes.Result, error) { - return executor.Execute( - ctx, - nil, - "TestExecute", - econtext.NewSafeSession(session), - sql, - bv) +func executorExecSession(ctx context.Context, executor *Executor, session *econtext.SafeSession, sql string, bv map[string]*querypb.BindVariable) (*sqltypes.Result, error) { + return executor.Execute(ctx, nil, "TestExecute", session, sql, bv, false) } func executorExec(ctx context.Context, executor *Executor, session *vtgatepb.Session, sql string, bv map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - return executorExecSession(ctx, executor, sql, bv, session) + return executorExecSession(ctx, executor, econtext.NewSafeSession(session), sql, bv) } func executorPrepare(ctx context.Context, executor *Executor, session *vtgatepb.Session, sql string) ([]*querypb.Field, uint16, error) { - return executor.Prepare( - ctx, - "TestExecute", - econtext.NewSafeSession(session), - sql) + return executor.Prepare(ctx, "TestExecute", econtext.NewSafeSession(session), sql) } func executorStream(ctx context.Context, executor *Executor, sql string) (qr *sqltypes.Result, err error) { diff --git a/go/vt/vtgate/executor_scatter_stats_test.go b/go/vt/vtgate/executor_scatter_stats_test.go index b665f850a23..487b2ea4df6 100644 --- a/go/vt/vtgate/executor_scatter_stats_test.go +++ b/go/vt/vtgate/executor_scatter_stats_test.go @@ -32,7 +32,7 @@ func TestScatterStatsWithNoScatterQuery(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "@primary"}) - _, err := executor.Execute(ctx, nil, "TestExecutorResultsExceeded", session, "select * from main1", nil) + _, err := executorExecSession(ctx, executor, session, "select * from main1", nil) require.NoError(t, err) result, err := executor.gatherScatterStats() @@ -44,7 +44,7 @@ func TestScatterStatsWithSingleScatterQuery(t *testing.T) { executor, _, _, _, ctx := createExecutorEnv(t) session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "@primary"}) - _, err := executor.Execute(ctx, nil, "TestExecutorResultsExceeded", session, "select * from user", nil) + _, err := executorExecSession(ctx, executor, session, "select * from user", nil) require.NoError(t, err) result, err := executor.gatherScatterStats() @@ -56,17 +56,17 @@ func TestScatterStatsHttpWriting(t *testing.T) { executor, _, _, _, ctx := createExecutorEnv(t) session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "@primary"}) - _, err := executor.Execute(ctx, nil, "TestExecutorResultsExceeded", session, "select * from user", nil) + _, err := executorExecSession(ctx, executor, session, "select * from user", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecutorResultsExceeded", session, "select * from user where Id = 15", nil) + _, err = executorExecSession(ctx, executor, session, "select * from user where Id = 15", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecutorResultsExceeded", session, "select * from user where Id > 15", nil) + _, err = executorExecSession(ctx, executor, session, "select * from user where Id > 15", nil) require.NoError(t, err) query4 := "select * from user as u1 join user as u2 on u1.Id = u2.Id" - _, err = executor.Execute(ctx, nil, "TestExecutorResultsExceeded", session, query4, nil) + _, err = executorExecSession(ctx, executor, session, query4, nil) require.NoError(t, err) time.Sleep(500 * time.Millisecond) diff --git a/go/vt/vtgate/executor_select_test.go b/go/vt/vtgate/executor_select_test.go index 7213f54a233..20290922bca 100644 --- a/go/vt/vtgate/executor_select_test.go +++ b/go/vt/vtgate/executor_select_test.go @@ -64,7 +64,7 @@ func TestSelectNext(t *testing.T) { // Autocommit session := econtext.NewAutocommitSession(&vtgatepb.Session{}) - _, err := executor.Execute(context.Background(), nil, "TestSelectNext", session, query, bv) + _, err := executorExecSession(context.Background(), executor, session, query, bv) require.NoError(t, err) utils.MustMatch(t, wantQueries, sbclookup.Queries) @@ -75,7 +75,7 @@ func TestSelectNext(t *testing.T) { // Txn session = econtext.NewAutocommitSession(&vtgatepb.Session{}) session.Session.InTransaction = true - _, err = executor.Execute(context.Background(), nil, "TestSelectNext", session, query, bv) + _, err = executorExecSession(context.Background(), executor, session, query, bv) require.NoError(t, err) utils.MustMatch(t, wantQueries, sbclookup.Queries) @@ -86,7 +86,7 @@ func TestSelectNext(t *testing.T) { // Reserve session = econtext.NewAutocommitSession(&vtgatepb.Session{}) session.Session.InReservedConn = true - _, err = executor.Execute(context.Background(), nil, "TestSelectNext", session, query, bv) + _, err = executorExecSession(context.Background(), executor, session, query, bv) require.NoError(t, err) utils.MustMatch(t, wantQueries, sbclookup.Queries) @@ -98,7 +98,7 @@ func TestSelectNext(t *testing.T) { session = econtext.NewAutocommitSession(&vtgatepb.Session{}) session.Session.InReservedConn = true session.Session.InTransaction = true - _, err = executor.Execute(context.Background(), nil, "TestSelectNext", session, query, bv) + _, err = executorExecSession(context.Background(), executor, session, query, bv) require.NoError(t, err) utils.MustMatch(t, wantQueries, sbclookup.Queries) @@ -113,7 +113,7 @@ func TestSelectDBA(t *testing.T) { _, err := executor.Execute(context.Background(), nil, "TestSelectDBA", econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}), query, map[string]*querypb.BindVariable{}, - ) + false) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{{Sql: query, BindVariables: map[string]*querypb.BindVariable{}}} utils.MustMatch(t, wantQueries, sbc1.Queries) @@ -123,7 +123,7 @@ func TestSelectDBA(t *testing.T) { _, err = executor.Execute(context.Background(), nil, "TestSelectDBA", econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}), query, map[string]*querypb.BindVariable{}, - ) + false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{{ Sql: "select count(*) from INFORMATION_SCHEMA.`TABLES` as ist where ist.table_schema = :__vtschemaname /* VARCHAR */ and ist.table_name = :ist_table_name /* VARCHAR */", @@ -139,7 +139,7 @@ func TestSelectDBA(t *testing.T) { _, err = executor.Execute(context.Background(), nil, "TestSelectDBA", econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}), query, map[string]*querypb.BindVariable{}, - ) + false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{{ Sql: "select 1 from information_schema.table_constraints where constraint_schema = :__vtschemaname /* VARCHAR */ and table_name = :table_name /* VARCHAR */", @@ -155,7 +155,7 @@ func TestSelectDBA(t *testing.T) { _, err = executor.Execute(context.Background(), nil, "TestSelectDBA", econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}), query, map[string]*querypb.BindVariable{}, - ) + false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{{ Sql: "select 1 from information_schema.table_constraints where constraint_schema = :__vtschemaname /* VARCHAR */", @@ -184,10 +184,10 @@ func TestSystemVariablesMySQLBelow80(t *testing.T) { }}, }}) - _, err := executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}) + _, err := executorExecSession(context.Background(), executor, session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}) require.NoError(t, err) - _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}) + _, err = executorExecSession(context.Background(), executor, session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}) require.NoError(t, err) require.True(t, session.InReservedConn()) @@ -217,11 +217,11 @@ func TestSystemVariablesWithSetVarDisabled(t *testing.T) { }}, }}) - _, err := executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}) + _, err := executorExecSession(context.Background(), executor, session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}) require.NoError(t, err) require.True(t, session.InReservedConn()) - _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}) + _, err = executorExecSession(context.Background(), executor, session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{ @@ -239,10 +239,10 @@ func TestSetSystemVariablesTx(t *testing.T) { session := econtext.NewAutocommitSession(&vtgatepb.Session{EnableSystemSettings: true, TargetString: "TestExecutor"}) - _, err := executor.Execute(context.Background(), nil, "TestBegin", session, "begin", map[string]*querypb.BindVariable{}) + _, err := executor.Execute(context.Background(), nil, "TestBegin", session, "begin", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) - _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) require.NotZero(t, session.ShardSessions) @@ -257,14 +257,14 @@ func TestSetSystemVariablesTx(t *testing.T) { }}, }}) - _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) require.False(t, session.InReservedConn()) - _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) - _, err = executor.Execute(context.Background(), nil, "TestCommit", session, "commit", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestCommit", session, "commit", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) require.False(t, session.InReservedConn()) @@ -295,10 +295,10 @@ func TestSetSystemVariables(t *testing.T) { sqltypes.NewVarChar("only_full_group_by"), }}, }}) - _, err := executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}) + _, err := executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) - _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) require.False(t, session.InReservedConn()) wantQueries := []*querypb.BoundQuery{ @@ -310,7 +310,7 @@ func TestSetSystemVariables(t *testing.T) { // Execute a select with a comment that needs a query hint - _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select /* comment */ 1 from information_schema.table", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select /* comment */ 1 from information_schema.table", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) require.False(t, session.InReservedConn()) wantQueries = []*querypb.BoundQuery{ @@ -327,7 +327,7 @@ func TestSetSystemVariables(t *testing.T) { sqltypes.NewVarChar("0"), }}, }}) - _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@sql_safe_updates = 0", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@sql_safe_updates = 0", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) require.False(t, session.InReservedConn()) wantQueries = []*querypb.BoundQuery{ @@ -336,7 +336,7 @@ func TestSetSystemVariables(t *testing.T) { utils.MustMatch(t, wantQueries, lookup.Queries) lookup.Queries = nil - _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @var = @@sql_mode", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @var = @@sql_mode", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) require.False(t, session.InReservedConn()) require.Nil(t, lookup.Queries) @@ -350,7 +350,7 @@ func TestSetSystemVariables(t *testing.T) { sqltypes.NewVarChar("4"), }}, }}) - _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @x = @@sql_mode, @y = @@max_tmp_tables", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @x = @@sql_mode, @y = @@max_tmp_tables", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) require.False(t, session.InReservedConn()) wantQueries = []*querypb.BoundQuery{ @@ -373,11 +373,11 @@ func TestSetSystemVariables(t *testing.T) { sqltypes.NewVarChar("1"), }}, }}) - _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@max_tmp_tables = 1", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@max_tmp_tables = 1", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) require.True(t, session.InReservedConn()) - _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select 1 from information_schema.table", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{ @@ -421,11 +421,11 @@ func TestSetSystemVariablesWithSetVarInvalidSQLMode(t *testing.T) { }}, }}) - _, err := executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@sql_mode = ''", map[string]*querypb.BindVariable{}) + _, err := executor.Execute(context.Background(), nil, "TestSetStmt", session, "set @@sql_mode = ''", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) require.False(t, session.InReservedConn()) - _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select age, city from user group by age", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select age, city from user group by age", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{ {Sql: "select @@sql_mode orig, '' new"}, @@ -433,7 +433,7 @@ func TestSetSystemVariablesWithSetVarInvalidSQLMode(t *testing.T) { } utils.MustMatch(t, wantQueries, sbc1.Queries) - _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select age, city+1 from user group by age", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSelect", session, "select age, city+1 from user group by age", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{ {Sql: "select @@sql_mode orig, '' new"}, @@ -449,11 +449,11 @@ func TestSelectVindexFunc(t *testing.T) { query := "select * from hash_index where id = 1" session := econtext.NewAutocommitSession(&vtgatepb.Session{}) - _, err := executor.Execute(context.Background(), nil, "TestSelectVindexFunc", session, query, nil) + _, err := executor.Execute(context.Background(), nil, "TestSelectVindexFunc", session, query, nil, false) require.ErrorContains(t, err, "VT09005: no database selected") session.TargetString = KsTestSharded - _, err = executor.Execute(context.Background(), nil, "TestSelectVindexFunc", session, query, nil) + _, err = executor.Execute(context.Background(), nil, "TestSelectVindexFunc", session, query, nil, false) require.NoError(t, err) } @@ -463,7 +463,7 @@ func TestCreateTableValidTimestamp(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor", SystemVariables: map[string]string{"sql_mode": "ALLOW_INVALID_DATES"}}) query := "create table aa(t timestamp default 0)" - _, err := executor.Execute(context.Background(), nil, "TestSelect", session, query, map[string]*querypb.BindVariable{}) + _, err := executor.Execute(context.Background(), nil, "TestSelect", session, query, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) assert.True(t, session.InReservedConn()) @@ -482,7 +482,7 @@ func TestGen4SelectDBA(t *testing.T) { _, err := executor.Execute(context.Background(), nil, "TestSelectDBA", econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}), query, map[string]*querypb.BindVariable{}, - ) + false) require.NoError(t, err) expected := "select CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, TABLE_SCHEMA, TABLE_NAME, CONSTRAINT_TYPE, `ENFORCED` from INFORMATION_SCHEMA.TABLE_CONSTRAINTS" wantQueries := []*querypb.BoundQuery{{Sql: expected, BindVariables: map[string]*querypb.BindVariable{}}} @@ -493,7 +493,7 @@ func TestGen4SelectDBA(t *testing.T) { _, err = executor.Execute(context.Background(), nil, "TestSelectDBA", econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}), query, map[string]*querypb.BindVariable{}, - ) + false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{{ Sql: "select count(*) from INFORMATION_SCHEMA.`TABLES` as ist where ist.table_schema = :__vtschemaname /* VARCHAR */ and ist.table_name = :ist_table_name1 /* VARCHAR */", @@ -511,7 +511,7 @@ func TestGen4SelectDBA(t *testing.T) { _, err = executor.Execute(context.Background(), nil, "TestSelectDBA", econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}), query, map[string]*querypb.BindVariable{}, - ) + false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{{ Sql: "select :vtg1 /* INT64 */ from information_schema.table_constraints where constraint_schema = :__vtschemaname /* VARCHAR */ and table_name = :table_name1 /* VARCHAR */", @@ -527,7 +527,7 @@ func TestGen4SelectDBA(t *testing.T) { sbc1.Queries = nil query = "select 1 from information_schema.table_constraints where constraint_schema = 'vt_ks'" - _, err = executor.Execute(context.Background(), nil, "TestSelectDBA", econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}), query, map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestSelectDBA", econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}), query, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{{ Sql: "select :vtg1 /* INT64 */ from information_schema.table_constraints where constraint_schema = :__vtschemaname /* VARCHAR */", @@ -541,10 +541,9 @@ func TestGen4SelectDBA(t *testing.T) { sbc1.Queries = nil query = "select t.table_schema,t.table_name,c.column_name,c.column_type from tables t join columns c on c.table_schema = t.table_schema and c.table_name = t.table_name where t.table_schema = 'TestExecutor' and c.table_schema = 'TestExecutor' order by t.table_schema,t.table_name,c.column_name" - _, err = executor.Execute(context.Background(), nil, "TestSelectDBA", + _, err = executorExecSession(context.Background(), executor, econtext.NewSafeSession(&vtgatepb.Session{TargetString: "information_schema"}), - query, map[string]*querypb.BindVariable{}, - ) + query, map[string]*querypb.BindVariable{}) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{{ Sql: "select t.table_schema, t.table_name, c.column_name, c.column_type from information_schema.`tables` as t, information_schema.`columns` as c where t.table_schema = :__vtschemaname /* VARCHAR */ and c.table_schema = :__vtschemaname /* VARCHAR */ and c.table_schema = t.table_schema and c.table_name = t.table_name order by t.table_schema asc, t.table_name asc, c.column_name asc", @@ -1078,18 +1077,11 @@ func TestLastInsertIDInSubQueryExpression(t *testing.T) { func TestSelectDatabase(t *testing.T) { executor, _, _, _, _ := createExecutorEnvWithConfig(t, createExecutorConfigWithNormalizer()) sql := "select database()" - newSession := &vtgatepb.Session{ - TargetString: "@primary", + session := &vtgatepb.Session{ + TargetString: "TestExecutor@primary", } - session := econtext.NewSafeSession(newSession) - session.TargetString = "TestExecutor@primary" - result, err := executor.Execute( - context.Background(), - nil, - "TestExecute", - session, - sql, - map[string]*querypb.BindVariable{}) + + result, err := executorExec(context.Background(), executor, session, sql, map[string]*querypb.BindVariable{}) wantResult := &sqltypes.Result{ Fields: []*querypb.Field{ {Name: "database()", Type: sqltypes.VarChar, Charset: uint32(collations.MySQL8().DefaultConnectionCharset())}, @@ -3421,25 +3413,25 @@ func TestSelectScatterFails(t *testing.T) { logChan := executor.queryLogger.Subscribe("Test") defer executor.queryLogger.Unsubscribe(logChan) - _, err := executorExecSession(ctx, executor, "select id from `user`", nil, sess) + _, err := executorExec(ctx, executor, sess, "select id from `user`", nil) require.Error(t, err) assert.Contains(t, err.Error(), "scatter") // Run the test again, to ensure it behaves the same for a cached query - _, err = executorExecSession(ctx, executor, "select id from `user`", nil, sess) + _, err = executorExec(ctx, executor, sess, "select id from `user`", nil) require.Error(t, err) assert.Contains(t, err.Error(), "scatter") - _, err = executorExecSession(ctx, executor, "select /*vt+ ALLOW_SCATTER */ id from user", nil, sess) + _, err = executorExec(ctx, executor, sess, "select /*vt+ ALLOW_SCATTER */ id from user", nil) require.NoError(t, err) - _, err = executorExecSession(ctx, executor, "begin", nil, sess) + _, err = executorExec(ctx, executor, sess, "begin", nil) require.NoError(t, err) - _, err = executorExecSession(ctx, executor, "commit", nil, sess) + _, err = executorExec(ctx, executor, sess, "commit", nil) require.NoError(t, err) - _, err = executorExecSession(ctx, executor, "savepoint a", nil, sess) + _, err = executorExec(ctx, executor, sess, "savepoint a", nil) require.NoError(t, err) } @@ -3452,7 +3444,7 @@ func TestGen4SelectStraightJoin(t *testing.T) { "TestGen4SelectStraightJoin", session, query, map[string]*querypb.BindVariable{}, - ) + false) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{ { @@ -3469,7 +3461,7 @@ func TestGen4MultiColumnVindexEqual(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) query := "select * from user_region where cola = 1 and colb = 2" - _, err := executor.Execute(context.Background(), nil, "TestGen4MultiColumnVindex", session, query, map[string]*querypb.BindVariable{}) + _, err := executor.Execute(context.Background(), nil, "TestGen4MultiColumnVindex", session, query, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{ { @@ -3486,7 +3478,7 @@ func TestGen4MultiColumnVindexEqual(t *testing.T) { sbc1.Queries = nil query = "select * from user_region where cola = 17984 and colb = 1" - _, err = executor.Execute(context.Background(), nil, "TestGen4MultiColumnVindex", session, query, map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestGen4MultiColumnVindex", session, query, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{ { @@ -3506,7 +3498,7 @@ func TestGen4MultiColumnVindexIn(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) query := "select * from user_region where cola IN (1,17984) and colb IN (2,3,4)" - _, err := executor.Execute(context.Background(), nil, "TestGen4MultiColumnVindex", session, query, map[string]*querypb.BindVariable{}) + _, err := executor.Execute(context.Background(), nil, "TestGen4MultiColumnVindex", session, query, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) bv1, _ := sqltypes.BuildBindVariable([]int64{1}) bv2, _ := sqltypes.BuildBindVariable([]int64{17984}) @@ -3543,7 +3535,7 @@ func TestGen4MultiColMixedColComparision(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) query := "select * from user_region where colb = 2 and cola IN (1,17984)" - _, err := executor.Execute(context.Background(), nil, "TestGen4MultiColMixedColComparision", session, query, map[string]*querypb.BindVariable{}) + _, err := executor.Execute(context.Background(), nil, "TestGen4MultiColMixedColComparision", session, query, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) bvtg1 := sqltypes.Int64BindVariable(2) bvtg2, _ := sqltypes.BuildBindVariable([]int64{1, 17984}) @@ -3578,7 +3570,7 @@ func TestGen4MultiColBestVindexSel(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) query := "select * from user_region where colb = 2 and cola IN (1,17984) and cola = 1" - _, err := executor.Execute(context.Background(), nil, "TestGen4MultiColBestVindexSel", session, query, map[string]*querypb.BindVariable{}) + _, err := executor.Execute(context.Background(), nil, "TestGen4MultiColBestVindexSel", session, query, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) bvtg2, _ := sqltypes.BuildBindVariable([]int64{1, 17984}) wantQueries := []*querypb.BoundQuery{ @@ -3598,7 +3590,7 @@ func TestGen4MultiColBestVindexSel(t *testing.T) { sbc1.Queries = nil query = "select * from user_region where colb in (10,20) and cola IN (1,17984) and cola = 1 and colb = 2" - _, err = executor.Execute(context.Background(), nil, "TestGen4MultiColBestVindexSel", session, query, map[string]*querypb.BindVariable{}) + _, err = executor.Execute(context.Background(), nil, "TestGen4MultiColBestVindexSel", session, query, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) bvtg1, _ := sqltypes.BuildBindVariable([]int64{10, 20}) @@ -3622,7 +3614,7 @@ func TestGen4MultiColMultiEqual(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) query := "select * from user_region where (cola,colb) in ((17984,2),(17984,3))" - _, err := executor.Execute(context.Background(), nil, "TestGen4MultiColMultiEqual", session, query, map[string]*querypb.BindVariable{}) + _, err := executor.Execute(context.Background(), nil, "TestGen4MultiColMultiEqual", session, query, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{ { @@ -3789,7 +3781,7 @@ func TestRegionRange(t *testing.T) { for _, tcase := range tcases { t.Run(strconv.Itoa(tcase.regionID), func(t *testing.T) { sql := fmt.Sprintf("select * from user_region where cola = %d", tcase.regionID) - _, err := executor.Execute(context.Background(), nil, "TestRegionRange", econtext.NewAutocommitSession(&vtgatepb.Session{}), sql, nil) + _, err := executor.Execute(context.Background(), nil, "TestRegionRange", econtext.NewAutocommitSession(&vtgatepb.Session{}), sql, nil, false) require.NoError(t, err) count := 0 for _, sbc := range conns { @@ -3841,7 +3833,7 @@ func TestMultiCol(t *testing.T) { for _, tcase := range tcases { t.Run(fmt.Sprintf("%d_%d_%d", tcase.cola, tcase.colb, tcase.colc), func(t *testing.T) { sql := fmt.Sprintf("select * from multicoltbl where cola = %d and colb = %d and colc = '%d'", tcase.cola, tcase.colb, tcase.colc) - _, err := executor.Execute(ctx, nil, "TestMultiCol", session, sql, nil) + _, err := executor.Execute(ctx, nil, "TestMultiCol", session, sql, nil, false) require.NoError(t, err) var shards []string for _, sbc := range conns { @@ -3930,7 +3922,7 @@ func TestMultiColPartial(t *testing.T) { for _, tcase := range tcases { t.Run(tcase.where, func(t *testing.T) { sql := fmt.Sprintf("select * from multicoltbl where %s", tcase.where) - _, err := executor.Execute(ctx, nil, "TestMultiCol", session, sql, nil) + _, err := executor.Execute(ctx, nil, "TestMultiCol", session, sql, nil, false) require.NoError(t, err) var shards []string for _, sbc := range conns { @@ -4214,7 +4206,7 @@ func TestSelectAggregationRandom(t *testing.T) { defer executor.Close() session := econtext.NewAutocommitSession(&vtgatepb.Session{}) - rs, err := executor.Execute(context.Background(), nil, "TestSelectCFC", session, "select /*vt+ PLANNER=gen4 */ A.a, A.b, (A.a / A.b) as c from (select sum(a) as a, sum(b) as b from user) A", nil) + rs, err := executor.Execute(context.Background(), nil, "TestSelectCFC", session, "select /*vt+ PLANNER=gen4 */ A.a, A.b, (A.a / A.b) as c from (select sum(a) as a, sum(b) as b from user) A", nil, false) require.NoError(t, err) assert.Equal(t, `[[DECIMAL(10) DECIMAL(1) DECIMAL(10.0000)]]`, fmt.Sprintf("%v", rs.Rows)) } @@ -4223,7 +4215,7 @@ func TestSelectDateTypes(t *testing.T) { executor, _, _, _, _ := createExecutorEnvWithConfig(t, createExecutorConfigWithNormalizer()) session := econtext.NewAutocommitSession(&vtgatepb.Session{}) - qr, err := executor.Execute(context.Background(), nil, "TestSelectDateTypes", session, "select '2020-01-01' + interval month(date_sub(FROM_UNIXTIME(1234), interval 1 month))-1 month", nil) + qr, err := executor.Execute(context.Background(), nil, "TestSelectDateTypes", session, "select '2020-01-01' + interval month(date_sub(FROM_UNIXTIME(1234), interval 1 month))-1 month", nil, false) require.NoError(t, err) require.Equal(t, sqltypes.Char, qr.Fields[0].Type) require.Equal(t, `[[CHAR("2020-12-01")]]`, fmt.Sprintf("%v", qr.Rows)) @@ -4233,11 +4225,11 @@ func TestSelectHexAndBit(t *testing.T) { executor, _, _, _, _ := createExecutorEnvWithConfig(t, createExecutorConfigWithNormalizer()) session := econtext.NewAutocommitSession(&vtgatepb.Session{}) - qr, err := executor.Execute(context.Background(), nil, "TestSelectHexAndBit", session, "select 0b1001, b'1001', 0x9, x'09'", nil) + qr, err := executor.Execute(context.Background(), nil, "TestSelectHexAndBit", session, "select 0b1001, b'1001', 0x9, x'09'", nil, false) require.NoError(t, err) require.Equal(t, `[[VARBINARY("\t") VARBINARY("\t") VARBINARY("\t") VARBINARY("\t")]]`, fmt.Sprintf("%v", qr.Rows)) - qr, err = executor.Execute(context.Background(), nil, "TestSelectHexAndBit", session, "select 1 + 0b1001, 1 + b'1001', 1 + 0x9, 1 + x'09'", nil) + qr, err = executor.Execute(context.Background(), nil, "TestSelectHexAndBit", session, "select 1 + 0b1001, 1 + b'1001', 1 + 0x9, 1 + x'09'", nil, false) require.NoError(t, err) require.Equal(t, `[[INT64(10) INT64(10) UINT64(10) UINT64(10)]]`, fmt.Sprintf("%v", qr.Rows)) } @@ -4248,7 +4240,7 @@ func TestSelectCFC(t *testing.T) { executor, _, _, _, _ := createExecutorEnvWithConfig(t, createExecutorConfigWithNormalizer()) session := econtext.NewAutocommitSession(&vtgatepb.Session{}) - _, err := executor.Execute(context.Background(), nil, "TestSelectCFC", session, "select /*vt+ PLANNER=gen4 */ c2 from tbl_cfc where c1 like 'A%'", nil) + _, err := executor.Execute(context.Background(), nil, "TestSelectCFC", session, "select /*vt+ PLANNER=gen4 */ c2 from tbl_cfc where c1 like 'A%'", nil, false) require.NoError(t, err) timeout := time.After(30 * time.Second) @@ -4276,7 +4268,7 @@ func TestSelectView(t *testing.T) { session := econtext.NewAutocommitSession(&vtgatepb.Session{}) - _, err = executor.Execute(context.Background(), nil, "TestSelectView", session, "select * from user_details_view", nil) + _, err = executor.Execute(context.Background(), nil, "TestSelectView", session, "select * from user_details_view", nil, false) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{{ Sql: "select id, col from (select `user`.id, user_extra.col from `user`, user_extra where `user`.id = user_extra.user_id) as user_details_view", @@ -4285,7 +4277,7 @@ func TestSelectView(t *testing.T) { utils.MustMatch(t, wantQueries, sbc.Queries) sbc.Queries = nil - _, err = executor.Execute(context.Background(), nil, "TestSelectView", session, "select * from user_details_view where id = 2", nil) + _, err = executor.Execute(context.Background(), nil, "TestSelectView", session, "select * from user_details_view where id = 2", nil, false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{{ Sql: "select id, col from (select `user`.id, user_extra.col from `user`, user_extra where `user`.id = :id /* INT64 */ and `user`.id = user_extra.user_id) as user_details_view", @@ -4296,7 +4288,7 @@ func TestSelectView(t *testing.T) { utils.MustMatch(t, wantQueries, sbc.Queries) sbc.Queries = nil - _, err = executor.Execute(context.Background(), nil, "TestSelectView", session, "select * from user_details_view where id in (1,2,3,4,5)", nil) + _, err = executor.Execute(context.Background(), nil, "TestSelectView", session, "select * from user_details_view where id in (1,2,3,4,5)", nil, false) require.NoError(t, err) bvtg1, _ := sqltypes.BuildBindVariable([]int64{1, 2, 3, 4, 5}) bvals, _ := sqltypes.BuildBindVariable([]int64{1, 2}) @@ -4319,7 +4311,7 @@ func TestWarmingReads(t *testing.T) { // Since queries on the replica will run in a separate go-routine, we need synchronization for the Queries field in the sandboxconn. replica.RequireQueriesLocking() - _, err := executor.Execute(ctx, nil, "TestWarmingReads", session, "select age, city from user", map[string]*querypb.BindVariable{}) + _, err := executor.Execute(ctx, nil, "TestWarmingReads", session, "select age, city from user", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{ {Sql: "select age, city from `user`"}, @@ -4334,7 +4326,7 @@ func TestWarmingReads(t *testing.T) { utils.MustMatch(t, wantQueriesReplica, replica.GetQueries()) replica.ClearQueries() - _, err = executor.Execute(ctx, nil, "TestWarmingReads", session, "select age, city from user /* already has a comment */ ", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(ctx, nil, "TestWarmingReads", session, "select age, city from user /* already has a comment */ ", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{ {Sql: "select age, city from `user` /* already has a comment */"}, @@ -4349,17 +4341,17 @@ func TestWarmingReads(t *testing.T) { utils.MustMatch(t, wantQueriesReplica, replica.GetQueries()) replica.ClearQueries() - _, err = executor.Execute(ctx, nil, "TestSelect", session, "insert into user (age, city) values (5, 'Boston')", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(ctx, nil, "TestSelect", session, "insert into user (age, city) values (5, 'Boston')", map[string]*querypb.BindVariable{}, false) waitUntilQueryCount(t, replica, 0) require.NoError(t, err) require.Nil(t, replica.GetQueries()) - _, err = executor.Execute(ctx, nil, "TestWarmingReads", session, "update user set age=5 where city='Boston'", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(ctx, nil, "TestWarmingReads", session, "update user set age=5 where city='Boston'", map[string]*querypb.BindVariable{}, false) waitUntilQueryCount(t, replica, 0) require.NoError(t, err) require.Nil(t, replica.GetQueries()) - _, err = executor.Execute(ctx, nil, "TestWarmingReads", session, "delete from user where city='Boston'", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(ctx, nil, "TestWarmingReads", session, "delete from user where city='Boston'", map[string]*querypb.BindVariable{}, false) waitUntilQueryCount(t, replica, 0) require.NoError(t, err) require.Nil(t, replica.GetQueries()) @@ -4367,7 +4359,7 @@ func TestWarmingReads(t *testing.T) { executor, primary, replica = createExecutorEnvWithPrimaryReplicaConn(t, ctx, 0) replica.RequireQueriesLocking() - _, err = executor.Execute(ctx, nil, "TestWarmingReads", session, "select age, city from user", map[string]*querypb.BindVariable{}) + _, err = executor.Execute(ctx, nil, "TestWarmingReads", session, "select age, city from user", map[string]*querypb.BindVariable{}, false) require.NoError(t, err) wantQueries = []*querypb.BoundQuery{ {Sql: "select age, city from `user`"}, @@ -4449,32 +4441,32 @@ func TestSysVarGlobalAndSession(t *testing.T) { sqltypes.MakeTestResult(sqltypes.MakeTestFields("reserve_execute", "uint64")), sqltypes.MakeTestResult(sqltypes.MakeTestFields("@@global.innodb_lock_wait_timeout", "uint64"), "20"), }) - qr, err := executor.Execute(context.Background(), nil, "TestSetStmt", session, + qr, err := executorExecSession(context.Background(), executor, session, "select @@innodb_lock_wait_timeout", nil) require.NoError(t, err) require.Equal(t, `[[UINT64(20)]]`, fmt.Sprintf("%v", qr.Rows)) - qr, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, + qr, err = executorExecSession(context.Background(), executor, session, "select @@global.innodb_lock_wait_timeout", nil) require.NoError(t, err) require.Equal(t, `[[UINT64(20)]]`, fmt.Sprintf("%v", qr.Rows)) - _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, + _, err = executorExecSession(context.Background(), executor, session, "set @@global.innodb_lock_wait_timeout = 120", nil) require.NoError(t, err) require.Empty(t, session.SystemVariables["innodb_lock_wait_timeout"]) - _, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, + _, err = executorExecSession(context.Background(), executor, session, "set @@innodb_lock_wait_timeout = 40", nil) require.NoError(t, err) require.EqualValues(t, "40", session.SystemVariables["innodb_lock_wait_timeout"]) - qr, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, + qr, err = executorExecSession(context.Background(), executor, session, "select @@innodb_lock_wait_timeout", nil) require.NoError(t, err) require.Equal(t, `[[INT64(40)]]`, fmt.Sprintf("%v", qr.Rows)) - qr, err = executor.Execute(context.Background(), nil, "TestSetStmt", session, + qr, err = executorExecSession(context.Background(), executor, session, "select @@global.innodb_lock_wait_timeout", nil) require.NoError(t, err) require.Equal(t, `[[UINT64(20)]]`, fmt.Sprintf("%v", qr.Rows)) diff --git a/go/vt/vtgate/executor_set_test.go b/go/vt/vtgate/executor_set_test.go index 310d885a134..c48232c5dd8 100644 --- a/go/vt/vtgate/executor_set_test.go +++ b/go/vt/vtgate/executor_set_test.go @@ -268,7 +268,7 @@ func TestExecutorSet(t *testing.T) { for i, tcase := range testcases { t.Run(fmt.Sprintf("%d-%s", i, tcase.in), func(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{Autocommit: true}) - _, err := executorEnv.Execute(ctx, nil, "TestExecute", session, tcase.in, nil) + _, err := executorExecSession(ctx, executorEnv, session, tcase.in, nil) if tcase.err == "" { require.NoError(t, err) utils.MustMatch(t, tcase.out, session.Session, "new executor") @@ -381,7 +381,7 @@ func TestExecutorSetOp(t *testing.T) { session.TargetString = KsTestUnsharded session.EnableSystemSettings = !tcase.disallowResConn sbclookup.SetResults([]*sqltypes.Result{tcase.result}) - _, err := executor.Execute(ctx, nil, "TestExecute", session, tcase.in, nil) + _, err := executorExecSession(ctx, executor, session, tcase.in, nil) require.NoError(t, err) utils.MustMatch(t, tcase.warning, session.Warnings, "") utils.MustMatch(t, tcase.sysVars, session.SystemVariables, "") @@ -396,7 +396,7 @@ func TestExecutorSetMetadata(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "@primary", Autocommit: true}) set := "set @@vitess_metadata.app_keyspace_v1= '1'" - _, err := executor.Execute(ctx, nil, "TestExecute", session, set, nil) + _, err := executorExecSession(ctx, executor, session, set, nil) assert.Equalf(t, vtrpcpb.Code_PERMISSION_DENIED, vterrors.Code(err), "expected error %v, got error: %v", vtrpcpb.Code_PERMISSION_DENIED, err) }) @@ -410,11 +410,11 @@ func TestExecutorSetMetadata(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "@primary", Autocommit: true}) set := "set @@vitess_metadata.app_keyspace_v1= '1'" - _, err := executor.Execute(ctx, nil, "TestExecute", session, set, nil) + _, err := executorExecSession(ctx, executor, session, set, nil) require.NoError(t, err, "%s error: %v", set, err) show := `show vitess_metadata variables like 'app\\_keyspace\\_v_'` - result, err := executor.Execute(ctx, nil, "TestExecute", session, show, nil) + result, err := executorExecSession(ctx, executor, session, show, nil) require.NoError(t, err) want := "1" @@ -423,11 +423,11 @@ func TestExecutorSetMetadata(t *testing.T) { // Update metadata set = "set @@vitess_metadata.app_keyspace_v2='2'" - _, err = executor.Execute(ctx, nil, "TestExecute", session, set, nil) + _, err = executorExecSession(ctx, executor, session, set, nil) require.NoError(t, err, "%s error: %v", set, err) show = `show vitess_metadata variables like 'app\\_keyspace\\_v%'` - gotqr, err := executor.Execute(ctx, nil, "TestExecute", session, show, nil) + gotqr, err := executorExecSession(ctx, executor, session, show, nil) require.NoError(t, err) wantqr := &sqltypes.Result{ @@ -443,7 +443,7 @@ func TestExecutorSetMetadata(t *testing.T) { assert.ElementsMatch(t, wantqr.Rows, gotqr.Rows) show = "show vitess_metadata variables" - gotqr, err = executor.Execute(ctx, nil, "TestExecute", session, show, nil) + gotqr, err = executorExecSession(ctx, executor, session, show, nil) require.NoError(t, err) assert.Equal(t, wantqr.Fields, gotqr.Fields) @@ -471,7 +471,7 @@ func TestPlanExecutorSetUDV(t *testing.T) { for _, tcase := range testcases { t.Run(tcase.in, func(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{Autocommit: true}) - _, err := executor.Execute(ctx, nil, "TestExecute", session, tcase.in, nil) + _, err := executorExecSession(ctx, executor, session, tcase.in, nil) if err != nil { require.EqualError(t, err, tcase.err) } else { @@ -522,7 +522,7 @@ func TestSetVar(t *testing.T) { sqltypes.MakeTestFields("orig|new", "varchar|varchar"), "|only_full_group_by")}) - _, err := executor.Execute(ctx, nil, "TestSetVar", session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}) + _, err := executorExecSession(ctx, executor, session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}) require.NoError(t, err) tcases := []struct { @@ -544,7 +544,7 @@ func TestSetVar(t *testing.T) { // reset reserved conn need. session.SetReservedConn(false) - _, err = executor.Execute(ctx, nil, "TestSetVar", session, tc.sql, map[string]*querypb.BindVariable{}) + _, err = executorExecSession(ctx, executor, session, tc.sql, map[string]*querypb.BindVariable{}) require.NoError(t, err) assert.Equal(t, tc.rc, session.InReservedConn()) }) @@ -565,11 +565,11 @@ func TestSetVarShowVariables(t *testing.T) { sqltypes.MakeTestResult(sqltypes.MakeTestFields("Variable_name|Value", "varchar|varchar"), "sql_mode|ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE")}) - _, err := executor.Execute(ctx, nil, "TestSetVar", session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}) + _, err := executorExecSession(ctx, executor, session, "set @@sql_mode = only_full_group_by", map[string]*querypb.BindVariable{}) require.NoError(t, err) // this should return the updated value of sql_mode. - qr, err := executor.Execute(ctx, nil, "TestSetVar", session, "show variables like 'sql_mode'", map[string]*querypb.BindVariable{}) + qr, err := executorExecSession(ctx, executor, session, "show variables like 'sql_mode'", map[string]*querypb.BindVariable{}) require.NoError(t, err) assert.False(t, session.InReservedConn(), "reserved connection should not be used") assert.Equal(t, `[[VARCHAR("sql_mode") VARCHAR("only_full_group_by")]]`, fmt.Sprintf("%v", qr.Rows)) @@ -611,7 +611,7 @@ func TestExecutorSetAndSelect(t *testing.T) { sqltypes.MakeTestResult(nil)}) // third one for new set query setQ := fmt.Sprintf("set %s = '%s'", tcase.sysVar, tcase.val) - _, err := e.Execute(ctx, nil, "TestExecutorSetAndSelect", session, setQ, nil) + _, err := executorExecSession(ctx, e, session, setQ, nil) require.NoError(t, err) } @@ -619,7 +619,7 @@ func TestExecutorSetAndSelect(t *testing.T) { // if the query reaches the shard, it will return REPEATABLE-READ isolation level. sbc.SetResults([]*sqltypes.Result{sqltypes.MakeTestResult(sqltypes.MakeTestFields(tcase.sysVar, "varchar"), "REPEATABLE-READ")}) - qr, err := e.Execute(ctx, nil, "TestExecutorSetAndSelect", session, selectQ, nil) + qr, err := executorExecSession(ctx, e, session, selectQ, nil) require.NoError(t, err) assert.Equal(t, tcase.exp, fmt.Sprintf("%v", qr.Rows)) }) @@ -634,12 +634,12 @@ func TestExecutorTimeZone(t *testing.T) { session := econtext.NewAutocommitSession(&vtgatepb.Session{TargetString: KsTestUnsharded, EnableSystemSettings: true}) session.SetSystemVariable("time_zone", "'+08:00'") - qr, err := e.Execute(ctx, nil, "TestExecutorSetAndSelect", session, "select now()", nil) + qr, err := executorExecSession(ctx, e, session, "select now()", nil) require.NoError(t, err) session.SetSystemVariable("time_zone", "'+02:00'") - qrWith, err := e.Execute(ctx, nil, "TestExecutorSetAndSelect", session, "select now()", nil) + qrWith, err := executorExecSession(ctx, e, session, "select now()", nil) require.NoError(t, err) assert.False(t, qr.Rows[0][0].Equal(qrWith.Rows[0][0]), "%v vs %v", qr.Rows[0][0].ToString(), qrWith.Rows[0][0].ToString()) diff --git a/go/vt/vtgate/executor_test.go b/go/vt/vtgate/executor_test.go index 9ca2e17909b..f1400db004b 100644 --- a/go/vt/vtgate/executor_test.go +++ b/go/vt/vtgate/executor_test.go @@ -152,11 +152,11 @@ func TestExecutorResultsExceeded(t *testing.T) { result2 := sqltypes.MakeTestResult(sqltypes.MakeTestFields("col", "int64"), "1", "2", "3", "4") sbclookup.SetResults([]*sqltypes.Result{result1, result2}) - _, err := executor.Execute(ctx, nil, "TestExecutorResultsExceeded", session, "select * from main1", nil) + _, err := executorExecSession(ctx, executor, session, "select * from main1", nil) require.NoError(t, err) assert.Equal(t, initial, warnings.Counts()["ResultsExceeded"], "warnings count") - _, err = executor.Execute(ctx, nil, "TestExecutorResultsExceeded", session, "select * from main1", nil) + _, err = executorExecSession(ctx, executor, session, "select * from main1", nil) require.NoError(t, err) assert.Equal(t, initial+1, warnings.Counts()["ResultsExceeded"], "warnings count") } @@ -186,7 +186,7 @@ func TestExecutorMaxMemoryRowsExceeded(t *testing.T) { stmt, err := sqlparser.NewTestParser().Parse(test.query) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecutorMaxMemoryRowsExceeded", session, test.query, nil) + _, err = executorExecSession(ctx, executor, session, test.query, nil) if sqlparser.IgnoreMaxMaxMemoryRowsDirective(stmt) { require.NoError(t, err, "no error when DirectiveIgnoreMaxMemoryRows is provided") } else { @@ -208,7 +208,7 @@ func TestExecutorTransactionsNoAutoCommit(t *testing.T) { defer executor.queryLogger.Unsubscribe(logChan) // begin. - _, err := executor.Execute(ctx, nil, "TestExecute", session, "begin", nil) + _, err := executorExecSession(ctx, executor, session, "begin", nil) require.NoError(t, err) wantSession := &vtgatepb.Session{InTransaction: true, TargetString: "@primary", SessionUUID: "suuid"} utils.MustMatch(t, wantSession, session.Session, "session") @@ -218,13 +218,13 @@ func TestExecutorTransactionsNoAutoCommit(t *testing.T) { assert.EqualValues(t, "suuid", logStats.SessionUUID, "logstats: expected non-empty SessionUUID") // commit. - _, err = executor.Execute(ctx, nil, "TestExecute", session, "select id from main1", nil) + _, err = executorExecSession(ctx, executor, session, "select id from main1", nil) require.NoError(t, err) logStats = testQueryLog(t, executor, logChan, "TestExecute", "SELECT", "select id from main1", 1) assert.EqualValues(t, 0, logStats.CommitTime, "logstats: expected zero CommitTime") assert.EqualValues(t, "suuid", logStats.SessionUUID, "logstats: expected non-empty SessionUUID") - _, err = executor.Execute(context.Background(), nil, "TestExecute", session, "commit", nil) + _, err = executorExecSession(context.Background(), executor, session, "commit", nil) require.NoError(t, err) wantSession = &vtgatepb.Session{TargetString: "@primary", SessionUUID: "suuid"} assert.Truef(t, proto.Equal(session.Session, wantSession), "begin: %v, want %v", session.Session, wantSession) @@ -234,11 +234,11 @@ func TestExecutorTransactionsNoAutoCommit(t *testing.T) { assert.EqualValues(t, "suuid", logStats.SessionUUID, "logstats: expected non-empty SessionUUID") // rollback. - _, err = executor.Execute(ctx, nil, "TestExecute", session, "begin", nil) + _, err = executorExecSession(ctx, executor, session, "begin", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "select id from main1", nil) + _, err = executorExecSession(ctx, executor, session, "select id from main1", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "rollback", nil) + _, err = executorExecSession(ctx, executor, session, "rollback", nil) require.NoError(t, err) wantSession = &vtgatepb.Session{TargetString: "@primary", SessionUUID: "suuid"} utils.MustMatch(t, wantSession, session.Session, "session") @@ -257,7 +257,7 @@ func TestExecutorTransactionsNoAutoCommit(t *testing.T) { // Prevent use of non-primary if in_transaction is on. session = econtext.NewSafeSession(&vtgatepb.Session{TargetString: "@primary", InTransaction: true}) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "use @replica", nil) + _, err = executorExecSession(ctx, executor, session, "use @replica", nil) require.EqualError(t, err, `can't execute the given command because you have an active transaction`) } @@ -271,7 +271,7 @@ func TestDirectTargetRewrites(t *testing.T) { } sql := "select database()" - _, err := executor.Execute(ctx, nil, "TestExecute", econtext.NewSafeSession(session), sql, map[string]*querypb.BindVariable{}) + _, err := executorExec(ctx, executor, session, sql, map[string]*querypb.BindVariable{}) require.NoError(t, err) assertQueries(t, sbclookup, []*querypb.BoundQuery{{ Sql: "select :__vtdbname as `database()` from dual", @@ -288,7 +288,7 @@ func TestExecutorTransactionsAutoCommit(t *testing.T) { defer executor.queryLogger.Unsubscribe(logChan) // begin. - _, err := executor.Execute(ctx, nil, "TestExecute", session, "begin", nil) + _, err := executorExecSession(ctx, executor, session, "begin", nil) require.NoError(t, err) wantSession := &vtgatepb.Session{InTransaction: true, TargetString: "@primary", Autocommit: true, SessionUUID: "suuid"} utils.MustMatch(t, wantSession, session.Session, "session") @@ -299,9 +299,9 @@ func TestExecutorTransactionsAutoCommit(t *testing.T) { assert.EqualValues(t, "suuid", logStats.SessionUUID, "logstats: expected non-empty SessionUUID") // commit. - _, err = executor.Execute(ctx, nil, "TestExecute", session, "select id from main1", nil) + _, err = executorExecSession(ctx, executor, session, "select id from main1", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "commit", nil) + _, err = executorExecSession(ctx, executor, session, "commit", nil) require.NoError(t, err) wantSession = &vtgatepb.Session{TargetString: "@primary", Autocommit: true, SessionUUID: "suuid"} utils.MustMatch(t, wantSession, session.Session, "session") @@ -315,11 +315,11 @@ func TestExecutorTransactionsAutoCommit(t *testing.T) { assert.EqualValues(t, "suuid", logStats.SessionUUID, "logstats: expected non-empty SessionUUID") // rollback. - _, err = executor.Execute(ctx, nil, "TestExecute", session, "begin", nil) + _, err = executorExecSession(ctx, executor, session, "begin", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "select id from main1", nil) + _, err = executorExecSession(ctx, executor, session, "select id from main1", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "rollback", nil) + _, err = executorExecSession(ctx, executor, session, "rollback", nil) require.NoError(t, err) wantSession = &vtgatepb.Session{TargetString: "@primary", Autocommit: true, SessionUUID: "suuid"} utils.MustMatch(t, wantSession, session.Session, "session") @@ -371,9 +371,9 @@ func TestExecutorTransactionsAutoCommitStreaming(t *testing.T) { assert.EqualValues(t, "suuid", logStats.SessionUUID, "logstats: expected non-empty SessionUUID") // commit. - _, err = executor.Execute(ctx, nil, "TestExecute", session, "select id from main1", nil) + _, err = executorExecSession(ctx, executor, session, "select id from main1", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "commit", nil) + _, err = executorExecSession(ctx, executor, session, "commit", nil) require.NoError(t, err) wantSession = &vtgatepb.Session{TargetString: "@primary", Autocommit: true, Options: oltpOptions, SessionUUID: "suuid"} utils.MustMatch(t, wantSession, session.Session, "session") @@ -387,11 +387,11 @@ func TestExecutorTransactionsAutoCommitStreaming(t *testing.T) { assert.EqualValues(t, "suuid", logStats.SessionUUID, "logstats: expected non-empty SessionUUID") // rollback. - _, err = executor.Execute(ctx, nil, "TestExecute", session, "begin", nil) + _, err = executorExecSession(ctx, executor, session, "begin", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "select id from main1", nil) + _, err = executorExecSession(ctx, executor, session, "select id from main1", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "rollback", nil) + _, err = executorExecSession(ctx, executor, session, "rollback", nil) require.NoError(t, err) wantSession = &vtgatepb.Session{TargetString: "@primary", Autocommit: true, Options: oltpOptions, SessionUUID: "suuid"} utils.MustMatch(t, wantSession, session.Session, "session") @@ -408,25 +408,25 @@ func TestExecutorDeleteMetadata(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "@primary", Autocommit: true}) set := "set @@vitess_metadata.app_v1= '1'" - _, err := executor.Execute(ctx, nil, "TestExecute", session, set, nil) + _, err := executorExecSession(ctx, executor, session, set, nil) assert.NoError(t, err, "%s error: %v", set, err) show := `show vitess_metadata variables like 'app\\_%'` - result, _ := executor.Execute(ctx, nil, "TestExecute", session, show, nil) + result, _ := executorExecSession(ctx, executor, session, show, nil) assert.Len(t, result.Rows, 1) // Fails if deleting key that doesn't exist delQuery := "set @@vitess_metadata.doesn't_exist=''" - _, err = executor.Execute(ctx, nil, "TestExecute", session, delQuery, nil) + _, err = executorExecSession(ctx, executor, session, delQuery, nil) assert.True(t, topo.IsErrType(err, topo.NoNode)) // Delete existing key, show should fail given the node doesn't exist delQuery = "set @@vitess_metadata.app_v1=''" - _, err = executor.Execute(ctx, nil, "TestExecute", session, delQuery, nil) + _, err = executorExecSession(ctx, executor, session, delQuery, nil) assert.NoError(t, err) show = `show vitess_metadata variables like 'app\\_%'` - _, err = executor.Execute(ctx, nil, "TestExecute", session, show, nil) + _, err = executorExecSession(ctx, executor, session, show, nil) assert.True(t, topo.IsErrType(err, topo.NoNode)) } @@ -440,7 +440,7 @@ func TestExecutorAutocommit(t *testing.T) { // autocommit = 0 startCount := sbclookup.CommitCount.Load() - _, err := executor.Execute(ctx, nil, "TestExecute", session, "select id from main1", nil) + _, err := executorExecSession(ctx, executor, session, "select id from main1", nil) require.NoError(t, err) wantSession := &vtgatepb.Session{TargetString: "@primary", InTransaction: true, FoundRows: 1, RowCount: -1} testSession := session.Session.CloneVT() @@ -456,7 +456,7 @@ func TestExecutorAutocommit(t *testing.T) { } // autocommit = 1 - _, err = executor.Execute(ctx, nil, "TestExecute", session, "set autocommit=1", nil) + _, err = executorExecSession(ctx, executor, session, "set autocommit=1", nil) require.NoError(t, err) _ = testQueryLog(t, executor, logChan, "TestExecute", "SET", "set @@autocommit = 1", 0) @@ -465,7 +465,7 @@ func TestExecutorAutocommit(t *testing.T) { t.Errorf("Commit count: %d, want %d", got, want) } - _, err = executor.Execute(ctx, nil, "TestExecute", session, "update main1 set id=1", nil) + _, err = executorExecSession(ctx, executor, session, "update main1 set id=1", nil) require.NoError(t, err) wantSession = &vtgatepb.Session{Autocommit: true, TargetString: "@primary", FoundRows: 0, RowCount: 1} utils.MustMatch(t, wantSession, session.Session, "session does not match for autocommit=1") @@ -477,11 +477,11 @@ func TestExecutorAutocommit(t *testing.T) { // autocommit = 1, "begin" session.ResetTx() startCount = sbclookup.CommitCount.Load() - _, err = executor.Execute(ctx, nil, "TestExecute", session, "begin", nil) + _, err = executorExecSession(ctx, executor, session, "begin", nil) require.NoError(t, err) _ = testQueryLog(t, executor, logChan, "TestExecute", "BEGIN", "begin", 0) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "update main1 set id=1", nil) + _, err = executorExecSession(ctx, executor, session, "update main1 set id=1", nil) require.NoError(t, err) wantSession = &vtgatepb.Session{InTransaction: true, Autocommit: true, TargetString: "@primary", FoundRows: 0, RowCount: 1} testSession = session.Session.CloneVT() @@ -499,7 +499,7 @@ func TestExecutorAutocommit(t *testing.T) { t.Errorf("logstats: expected non-zero RowsAffected") } - _, err = executor.Execute(ctx, nil, "TestExecute", session, "commit", nil) + _, err = executorExecSession(ctx, executor, session, "commit", nil) require.NoError(t, err) wantSession = &vtgatepb.Session{Autocommit: true, TargetString: "@primary"} if !proto.Equal(session.Session, wantSession) { @@ -513,14 +513,14 @@ func TestExecutorAutocommit(t *testing.T) { // transition autocommit from 0 to 1 in the middle of a transaction. startCount = sbclookup.CommitCount.Load() session = econtext.NewSafeSession(&vtgatepb.Session{TargetString: "@primary"}) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "begin", nil) + _, err = executorExecSession(ctx, executor, session, "begin", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "update main1 set id=1", nil) + _, err = executorExecSession(ctx, executor, session, "update main1 set id=1", nil) require.NoError(t, err) if got, want := sbclookup.CommitCount.Load(), startCount; got != want { t.Errorf("Commit count: %d, want %d", got, want) } - _, err = executor.Execute(ctx, nil, "TestExecute", session, "set autocommit=1", nil) + _, err = executorExecSession(ctx, executor, session, "set autocommit=1", nil) require.NoError(t, err) wantSession = &vtgatepb.Session{Autocommit: true, TargetString: "@primary"} if !proto.Equal(session.Session, wantSession) { @@ -544,7 +544,7 @@ func TestExecutorShowColumns(t *testing.T) { } for _, query := range queries { t.Run(query, func(t *testing.T) { - _, err := executor.Execute(ctx, nil, "TestExecute", session, query, nil) + _, err := executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantQueries := []*querypb.BoundQuery{{ @@ -589,28 +589,28 @@ func TestExecutorShow(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) for _, query := range []string{"show vitess_keyspaces", "show keyspaces"} { - qr, err := executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err := executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) assertMatchesNoOrder(t, `[[VARCHAR("TestUnsharded")] [VARCHAR("TestMultiCol")] [VARCHAR("TestXBadVSchema")] [VARCHAR("TestXBadSharding")] [VARCHAR("TestExecutor")]]`, fmt.Sprintf("%v", qr.Rows)) } for _, query := range []string{"show databases", "show DATABASES", "show schemas", "show SCHEMAS"} { - qr, err := executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err := executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) // Showing default tables (5+4[default]) assertMatchesNoOrder(t, `[[VARCHAR("TestUnsharded")] [VARCHAR("TestMultiCol")] [VARCHAR("TestXBadVSchema")] [VARCHAR("TestXBadSharding")] [VARCHAR("TestExecutor")]] [VARCHAR("information_schema")] [VARCHAR("mysql")] [VARCHAR("sys")] [VARCHAR("performance_schema")]`, fmt.Sprintf("%v", qr.Rows)) } - _, err := executor.Execute(ctx, nil, "TestExecute", session, "show variables", nil) + _, err := executorExecSession(ctx, executor, session, "show variables", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "show collation", nil) + _, err = executorExecSession(ctx, executor, session, "show collation", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "show collation where `Charset` = 'utf8' and `Collation` = 'utf8_bin'", nil) + _, err = executorExecSession(ctx, executor, session, "show collation where `Charset` = 'utf8' and `Collation` = 'utf8_bin'", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "use @primary", nil) + _, err = executorExecSession(ctx, executor, session, "use @primary", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "show tables", nil) + _, err = executorExecSession(ctx, executor, session, "show tables", nil) assert.EqualError(t, err, econtext.ErrNoKeyspace.Error(), "'show tables' should fail without a keyspace") assert.Empty(t, sbclookup.Queries, "sbclookup unexpectedly has queries already") @@ -627,7 +627,7 @@ func TestExecutorShow(t *testing.T) { sbclookup.SetResults([]*sqltypes.Result{showResults}) query := fmt.Sprintf("show tables from %v", KsTestUnsharded) - qr, err := executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err := executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) assert.Equal(t, 1, len(sbclookup.Queries), "Tablet should have received one 'show' query. Instead received: %v", sbclookup.Queries) @@ -639,88 +639,88 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, fmt.Sprintf("unexpected results running query: %s", query)) wantErrNoTable := "table unknown_table not found" - _, err = executor.Execute(ctx, nil, "TestExecute", session, "show create table unknown_table", nil) + _, err = executorExecSession(ctx, executor, session, "show create table unknown_table", nil) assert.EqualErrorf(t, err, wantErrNoTable, "Got: %v. Want: %v", wantErrNoTable) // SHOW CREATE table using vschema to find keyspace. - _, err = executor.Execute(ctx, nil, "TestExecute", session, "show create table user_seq", nil) + _, err = executorExecSession(ctx, executor, session, "show create table user_seq", nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql wantQuery := "show create table user_seq" assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) // SHOW CREATE table with query-provided keyspace - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show create table %v.unknown", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show create table %v.unknown", KsTestUnsharded), nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql wantQuery = "show create table `unknown`" assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) // SHOW KEYS with two different syntax - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show keys from %v.unknown", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show keys from %v.unknown", KsTestUnsharded), nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql wantQuery = "show indexes from `unknown`" assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show keys from unknown from %v", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show keys from unknown from %v", KsTestUnsharded), nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) // SHOW INDEX with two different syntax - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show index from %v.unknown", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show index from %v.unknown", KsTestUnsharded), nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show index from unknown from %v", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show index from unknown from %v", KsTestUnsharded), nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) // SHOW INDEXES with two different syntax - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show indexes from %v.unknown", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show indexes from %v.unknown", KsTestUnsharded), nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show indexes from unknown from %v", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show indexes from unknown from %v", KsTestUnsharded), nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) // SHOW EXTENDED {INDEX | INDEXES | KEYS} - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show extended index from unknown from %v", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show extended index from unknown from %v", KsTestUnsharded), nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show extended indexes from unknown from %v", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show extended indexes from unknown from %v", KsTestUnsharded), nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show extended keys from unknown from %v", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show extended keys from unknown from %v", KsTestUnsharded), nil) require.NoError(t, err) lastQuery = sbclookup.Queries[len(sbclookup.Queries)-1].Sql assert.Equal(t, wantQuery, lastQuery, "Got: %v. Want: %v", lastQuery, wantQuery) // Set destination keyspace in session session.TargetString = KsTestUnsharded - _, err = executor.Execute(ctx, nil, "TestExecute", session, "show create table unknown", nil) + _, err = executorExecSession(ctx, executor, session, "show create table unknown", nil) require.NoError(t, err) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "show full columns from table1", nil) + _, err = executorExecSession(ctx, executor, session, "show full columns from table1", nil) require.NoError(t, err) // Reset target string so other tests dont fail. session.TargetString = "@primary" - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show full columns from unknown from %v", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show full columns from unknown from %v", KsTestUnsharded), nil) require.NoError(t, err) for _, query := range []string{"show charset like 'utf8%'", "show character set like 'utf8%'"} { - qr, err := executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err := executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr := &sqltypes.Result{ Fields: append(buildVarCharFields("Charset", "Description", "Default collation"), &querypb.Field{Name: "Maxlen", Type: sqltypes.Uint32, Charset: collations.CollationBinaryID, Flags: uint32(querypb.MySqlFlag_NUM_FLAG | querypb.MySqlFlag_NOT_NULL_FLAG | querypb.MySqlFlag_UNSIGNED_FLAG | querypb.MySqlFlag_NO_DEFAULT_VALUE_FLAG)}), @@ -742,7 +742,7 @@ func TestExecutorShow(t *testing.T) { } for _, query := range []string{"show charset like '%foo'", "show character set like 'foo%'", "show charset like 'foo%'", "show character set where charset like '%foo'", "show charset where charset = '%foo'"} { - qr, err := executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err := executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr := &sqltypes.Result{ Fields: append(buildVarCharFields("Charset", "Description", "Default collation"), &querypb.Field{Name: "Maxlen", Type: sqltypes.Uint32, Charset: collations.CollationBinaryID, Flags: uint32(querypb.MySqlFlag_NUM_FLAG | querypb.MySqlFlag_NOT_NULL_FLAG | querypb.MySqlFlag_UNSIGNED_FLAG | querypb.MySqlFlag_NO_DEFAULT_VALUE_FLAG)}), @@ -753,7 +753,7 @@ func TestExecutorShow(t *testing.T) { } for _, query := range []string{"show charset like 'utf8mb3'", "show character set like 'utf8mb3'", "show charset where charset = 'utf8mb3'", "show character set where charset = 'utf8mb3'"} { - qr, err := executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err := executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr := &sqltypes.Result{ Fields: append(buildVarCharFields("Charset", "Description", "Default collation"), &querypb.Field{Name: "Maxlen", Type: sqltypes.Uint32, Charset: collations.CollationBinaryID, Flags: uint32(querypb.MySqlFlag_NUM_FLAG | querypb.MySqlFlag_NOT_NULL_FLAG | querypb.MySqlFlag_UNSIGNED_FLAG | querypb.MySqlFlag_NO_DEFAULT_VALUE_FLAG)}), @@ -770,7 +770,7 @@ func TestExecutorShow(t *testing.T) { } for _, query := range []string{"show charset like 'utf8mb4'", "show character set like 'utf8mb4'", "show charset where charset = 'utf8mb4'", "show character set where charset = 'utf8mb4'"} { - qr, err := executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err := executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr := &sqltypes.Result{ Fields: append(buildVarCharFields("Charset", "Description", "Default collation"), &querypb.Field{Name: "Maxlen", Type: sqltypes.Uint32, Charset: collations.CollationBinaryID, Flags: uint32(querypb.MySqlFlag_NUM_FLAG | querypb.MySqlFlag_NOT_NULL_FLAG | querypb.MySqlFlag_UNSIGNED_FLAG | querypb.MySqlFlag_NO_DEFAULT_VALUE_FLAG)}), @@ -786,12 +786,12 @@ func TestExecutorShow(t *testing.T) { } for _, query := range []string{"show character set where foo like '%foo'"} { - _, err := executor.Execute(ctx, nil, "TestExecute", session, query, nil) + _, err := executorExecSession(ctx, executor, session, query, nil) require.Error(t, err) } query = "show engines" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Engine", "Support", "Comment", "Transactions", "XA", "Savepoints"), @@ -808,7 +808,7 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) query = "show plugins" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Name", "Status", "Type", "Library", "License"), @@ -824,7 +824,7 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) for _, sql := range []string{"show session status", "show session status like 'Ssl_cipher'"} { - qr, err = executor.Execute(ctx, nil, "TestExecute", session, sql, nil) + qr, err = executorExecSession(ctx, executor, session, sql, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: []*querypb.Field{ @@ -840,11 +840,11 @@ func TestExecutorShow(t *testing.T) { } // Test SHOW FULL COLUMNS FROM where query has a qualifier - _, err = executor.Execute(ctx, nil, "TestExecute", session, fmt.Sprintf("show full columns from %v.table1", KsTestUnsharded), nil) + _, err = executorExecSession(ctx, executor, session, fmt.Sprintf("show full columns from %v.table1", KsTestUnsharded), nil) require.NoError(t, err) query = "show vitess_shards" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) // Just test for first & last. @@ -859,7 +859,7 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) query = "show vitess_shards like 'TestExecutor/%'" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) // Just test for first & last. @@ -874,7 +874,7 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) query = "show vitess_shards like 'TestExec%/%'" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) // Just test for first & last. @@ -889,7 +889,7 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) query = "show vitess_replication_status" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) qr.Rows = [][]sqltypes.Value{} wantqr = &sqltypes.Result{ @@ -898,7 +898,7 @@ func TestExecutorShow(t *testing.T) { } utils.MustMatch(t, wantqr, qr, query) query = "show vitess_replication_status like 'x'" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) qr.Rows = [][]sqltypes.Value{} wantqr = &sqltypes.Result{ @@ -908,7 +908,7 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) query = "show vitess_tablets" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) // Just test for first & last. qr.Rows = [][]sqltypes.Value{qr.Rows[0], qr.Rows[len(qr.Rows)-1]} @@ -922,7 +922,7 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) query = "show vitess_tablets like 'x'" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Cell", "Keyspace", "Shard", "TabletType", "State", "Alias", "Hostname", "PrimaryTermStartTime"), @@ -931,7 +931,7 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, fmt.Sprintf("%q should be empty", query)) query = "show vitess_tablets like '-20%'" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Cell", "Keyspace", "Shard", "TabletType", "State", "Alias", "Hostname", "PrimaryTermStartTime"), @@ -942,7 +942,7 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) query = "show vschema vindexes" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Keyspace", "Name", "Type", "Params", "Owner"), @@ -973,7 +973,7 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) query = "show vschema vindexes on TestExecutor.user" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Columns", "Name", "Type", "Params", "Owner"), @@ -985,18 +985,18 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) query = "show vschema vindexes on user" - _, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + _, err = executorExecSession(ctx, executor, session, query, nil) wantErr := econtext.ErrNoKeyspace.Error() assert.EqualError(t, err, wantErr, query) query = "show vschema vindexes on TestExecutor.garbage" - _, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + _, err = executorExecSession(ctx, executor, session, query, nil) wantErr = "VT05005: table 'garbage' does not exist in keyspace 'TestExecutor'" assert.EqualError(t, err, wantErr, query) query = "show vschema vindexes on user" session.TargetString = "TestExecutor" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Columns", "Name", "Type", "Params", "Owner"), @@ -1009,7 +1009,7 @@ func TestExecutorShow(t *testing.T) { query = "show vschema vindexes on user2" session.TargetString = "TestExecutor" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Columns", "Name", "Type", "Params", "Owner"), @@ -1021,12 +1021,12 @@ func TestExecutorShow(t *testing.T) { utils.MustMatch(t, wantqr, qr, query) query = "show vschema vindexes on garbage" - _, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + _, err = executorExecSession(ctx, executor, session, query, nil) wantErr = "VT05005: table 'garbage' does not exist in keyspace 'TestExecutor'" assert.EqualError(t, err, wantErr, query) query = "show warnings" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: []*querypb.Field{ @@ -1040,7 +1040,7 @@ func TestExecutorShow(t *testing.T) { query = "show warnings" session.Warnings = []*querypb.QueryWarning{} - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: []*querypb.Field{ @@ -1057,7 +1057,7 @@ func TestExecutorShow(t *testing.T) { {Code: uint32(sqlerror.ERBadTable), Message: "bad table"}, {Code: uint32(sqlerror.EROutOfResources), Message: "ks/-40: query timed out"}, } - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: []*querypb.Field{ @@ -1076,7 +1076,7 @@ func TestExecutorShow(t *testing.T) { // Make sure it still works when one of the keyspaces is in a bad state getSandbox(KsTestSharded).SrvKeyspaceMustFail++ query = "show vitess_shards" - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) // Just test for first & last. qr.Rows = [][]sqltypes.Value{qr.Rows[0], qr.Rows[len(qr.Rows)-1]} @@ -1091,7 +1091,7 @@ func TestExecutorShow(t *testing.T) { query = "show vschema tables" session = econtext.NewSafeSession(&vtgatepb.Session{TargetString: KsTestUnsharded}) - qr, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + qr, err = executorExecSession(ctx, executor, session, query, nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Tables"), @@ -1117,28 +1117,28 @@ func TestExecutorShow(t *testing.T) { query = "show vschema tables" session = econtext.NewSafeSession(&vtgatepb.Session{}) - _, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + _, err = executorExecSession(ctx, executor, session, query, nil) want = econtext.ErrNoKeyspace.Error() assert.EqualError(t, err, want, query) query = "show 10" - _, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + _, err = executorExecSession(ctx, executor, session, query, nil) want = "syntax error at position 8 near '10'" assert.EqualError(t, err, want, query) query = "show vschema tables" session = econtext.NewSafeSession(&vtgatepb.Session{TargetString: "no_such_keyspace"}) - _, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + _, err = executorExecSession(ctx, executor, session, query, nil) want = "VT05003: unknown database 'no_such_keyspace' in vschema" assert.EqualError(t, err, want, query) query = "show vitess_migrations" - _, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + _, err = executorExecSession(ctx, executor, session, query, nil) want = "VT05003: unknown database 'no_such_keyspace' in vschema" assert.EqualError(t, err, want, query) query = "show vitess_migrations from ks like '9748c3b7_7fdb_11eb_ac2c_f875a4d24e90'" - _, err = executor.Execute(ctx, nil, "TestExecute", session, query, nil) + _, err = executorExecSession(ctx, executor, session, query, nil) want = "VT05003: unknown database 'ks' in vschema" assert.EqualError(t, err, want, query) } @@ -1162,7 +1162,7 @@ func TestExecutorShowTargeted(t *testing.T) { } for _, sql := range queries { - _, err := executor.Execute(ctx, nil, "TestExecutorShowTargeted", session, sql, nil) + _, err := executorExecSession(ctx, executor, session, sql, nil) require.NoError(t, err) assert.NotZero(t, len(sbc2.Queries), "Tablet should have received 'show' query") lastQuery := sbc2.Queries[len(sbc2.Queries)-1].Sql @@ -1175,7 +1175,7 @@ func TestExecutorShowFromSystemSchema(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "mysql"}) - _, err := executor.Execute(ctx, nil, "TestExecutorShowFromSystemSchema", session, "show tables", nil) + _, err := executorExecSession(ctx, executor, session, "show tables", nil) require.NoError(t, err) } @@ -1193,19 +1193,19 @@ func TestExecutorUse(t *testing.T) { "TestExecutor:-80@primary", } for i, stmt := range stmts { - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) wantSession := &vtgatepb.Session{Autocommit: true, TargetString: want[i], RowCount: -1} utils.MustMatch(t, wantSession, session.Session, "session does not match") } - _, err := executor.Execute(ctx, nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{}), "use 1", nil) + _, err := executorExec(ctx, executor, &vtgatepb.Session{}, "use 1", nil) wantErr := "syntax error at position 6 near '1'" if err == nil || err.Error() != wantErr { t.Errorf("got: %v, want %v", err, wantErr) } - _, err = executor.Execute(ctx, nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{}), "use UnexistentKeyspace", nil) + _, err = executorExec(ctx, executor, &vtgatepb.Session{}, "use UnexistentKeyspace", nil) require.EqualError(t, err, "VT05003: unknown database 'UnexistentKeyspace' in vschema") } @@ -1219,7 +1219,7 @@ func TestExecutorComment(t *testing.T) { wantResult := &sqltypes.Result{} for _, stmt := range stmts { - gotResult, err := executor.Execute(ctx, nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{TargetString: KsTestUnsharded}), stmt, nil) + gotResult, err := executorExec(ctx, executor, &vtgatepb.Session{TargetString: KsTestUnsharded}, stmt, nil) require.NoError(t, err) if !gotResult.Equal(wantResult) { t.Errorf("Exec %s: %v, want %v", stmt, gotResult, wantResult) @@ -1302,7 +1302,7 @@ func TestExecutorDDL(t *testing.T) { sbc2.ExecCount.Store(0) sbclookup.ExecCount.Store(0) stmtType := "DDL" - _, err := executor.Execute(ctx, nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{TargetString: tc.targetStr}), stmt, nil) + _, err := executorExec(ctx, executor, &vtgatepb.Session{TargetString: tc.targetStr}, stmt, nil) if tc.hasNoKeyspaceErr { require.EqualError(t, err, econtext.ErrNoKeyspace.Error(), "expect query to fail: %q", stmt) stmtType = "" // For error case, plan is not generated to query log will not contain any stmtType. @@ -1341,7 +1341,7 @@ func TestExecutorDDL(t *testing.T) { sbc1.ExecCount.Store(0) sbc2.ExecCount.Store(0) sbclookup.ExecCount.Store(0) - _, err := executor.Execute(ctx, nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{TargetString: ""}), stmt.input, nil) + _, err := executorExec(ctx, executor, &vtgatepb.Session{TargetString: ""}, stmt.input, nil) if stmt.hasErr { assert.EqualError(t, err, econtext.ErrNoKeyspace.Error(), "expect query to fail") testQueryLog(t, executor, logChan, "TestExecute", "", stmt.input, 0) @@ -1354,7 +1354,6 @@ func TestExecutorDDL(t *testing.T) { } func TestExecutorDDLFk(t *testing.T) { - mName := "TestExecutorDDLFk" stmts := []string{ "create table t1(id bigint primary key, foreign key (id) references t2(id))", "alter table t2 add foreign key (id) references t1(id) on delete cascade", @@ -1366,7 +1365,7 @@ func TestExecutorDDLFk(t *testing.T) { executor, _, _, sbc, ctx := createExecutorEnv(t) sbc.ExecCount.Store(0) executor.vConfig.ForeignKeyMode = fkMode(mode) - _, err := executor.Execute(ctx, nil, mName, econtext.NewSafeSession(&vtgatepb.Session{TargetString: KsTestUnsharded}), stmt, nil) + _, err := executorExec(ctx, executor, &vtgatepb.Session{TargetString: KsTestUnsharded}, stmt, nil) if mode == "allow" { require.NoError(t, err) require.EqualValues(t, 1, sbc.ExecCount.Load()) @@ -1401,7 +1400,7 @@ func TestExecutorAlterVSchemaKeyspace(t *testing.T) { } stmt := "alter vschema create vindex TestExecutor.test_vindex using hash" - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _, vindex := waitForVindex(t, "TestExecutor", "test_vindex", vschemaUpdates, executor) @@ -1430,7 +1429,7 @@ func TestExecutorCreateVindexDDL(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: ks}) stmt := "alter vschema create vindex test_vindex using hash" - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _, vindex := waitForVindex(t, ks, "test_vindex", vschemaUpdates, executor) @@ -1438,7 +1437,7 @@ func TestExecutorCreateVindexDDL(t *testing.T) { t.Errorf("updated vschema did not contain test_vindex") } - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) wantErr := "vindex test_vindex already exists in keyspace TestExecutor" if err == nil || err.Error() != wantErr { t.Errorf("create duplicate vindex: %v, want %s", err, wantErr) @@ -1454,7 +1453,7 @@ func TestExecutorCreateVindexDDL(t *testing.T) { // ksNew := "test_new_keyspace" session = econtext.NewSafeSession(&vtgatepb.Session{TargetString: ks}) stmt = "alter vschema create vindex test_vindex2 using hash" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) vschema, vindex = waitForVindex(t, ks, "test_vindex2", vschemaUpdates, executor) @@ -1503,19 +1502,19 @@ func TestExecutorAddDropVschemaTableDDL(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: ks}) stmt := "alter vschema add table test_table" - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _ = waitForVschemaTables(t, ks, append([]string{"test_table"}, vschemaTables...), executor) stmt = "alter vschema add table test_table2" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _ = waitForVschemaTables(t, ks, append([]string{"test_table", "test_table2"}, vschemaTables...), executor) // Should fail adding a table on a sharded keyspace session = econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) stmt = "alter vschema add table test_table" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.EqualError(t, err, "add vschema table: unsupported on sharded keyspace TestExecutor") // No queries should have gone to any tablets @@ -1539,27 +1538,27 @@ func TestExecutorVindexDDLACL(t *testing.T) { // test that by default no users can perform the operation stmt := "alter vschema create vindex test_hash using hash" - _, err := executor.Execute(ctxRedUser, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctxRedUser, executor, session, stmt, nil) require.EqualError(t, err, `User 'redUser' is not authorized to perform vschema operations`) - _, err = executor.Execute(ctxBlueUser, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctxBlueUser, executor, session, stmt, nil) require.EqualError(t, err, `User 'blueUser' is not authorized to perform vschema operations`) // test when all users are enabled vschemaacl.AuthorizedDDLUsers.Set(vschemaacl.NewAuthorizedDDLUsers("%")) - _, err = executor.Execute(ctxRedUser, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctxRedUser, executor, session, stmt, nil) require.NoError(t, err) stmt = "alter vschema create vindex test_hash2 using hash" - _, err = executor.Execute(ctxBlueUser, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctxBlueUser, executor, session, stmt, nil) require.NoError(t, err) // test when only one user is enabled vschemaacl.AuthorizedDDLUsers.Set(vschemaacl.NewAuthorizedDDLUsers("orangeUser, blueUser, greenUser")) - _, err = executor.Execute(ctxRedUser, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctxRedUser, executor, session, stmt, nil) require.EqualError(t, err, `User 'redUser' is not authorized to perform vschema operations`) stmt = "alter vschema create vindex test_hash3 using hash" - _, err = executor.Execute(ctxBlueUser, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctxBlueUser, executor, session, stmt, nil) require.NoError(t, err) // restore the disallowed state @@ -1569,7 +1568,7 @@ func TestExecutorVindexDDLACL(t *testing.T) { func TestExecutorUnrecognized(t *testing.T) { executor, _, _, _, ctx := createExecutorEnv(t) - _, err := executor.Execute(ctx, nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{}), "invalid statement", nil) + _, err := executorExec(ctx, executor, &vtgatepb.Session{}, "invalid statement", nil) require.Error(t, err, "unrecognized statement: invalid statement'") } @@ -1581,7 +1580,7 @@ func TestExecutorDeniedErrorNoBuffer(t *testing.T) { session := econtext.NewAutocommitSession(&vtgatepb.Session{TargetString: "@primary"}) startExec := time.Now() - _, err := executor.Execute(ctx, nil, "TestExecutorDeniedErrorNoBuffer", session, "select * from user", nil) + _, err := executorExecSession(ctx, executor, session, "select * from user", nil) require.NoError(t, err, "enforce denied tables not buffered") endExec := time.Now() require.GreaterOrEqual(t, endExec.Sub(startExec).Milliseconds(), int64(500)) @@ -2017,7 +2016,7 @@ func TestExecutorMaxPayloadSizeExceeded(t *testing.T) { "delete from main1 where id=1", } for _, query := range testMaxPayloadSizeExceeded { - _, err := executor.Execute(context.Background(), nil, "TestExecutorMaxPayloadSizeExceeded", session, query, nil) + _, err := executorExecSession(context.Background(), executor, session, query, nil) require.NotNil(t, err) assert.EqualError(t, err, "query payload size above threshold") } @@ -2030,14 +2029,14 @@ func TestExecutorMaxPayloadSizeExceeded(t *testing.T) { "delete /*vt+ IGNORE_MAX_PAYLOAD_SIZE=1 */ from main1 where id=1", } for _, query := range testMaxPayloadSizeOverride { - _, err := executor.Execute(context.Background(), nil, "TestExecutorMaxPayloadSizeWithOverride", session, query, nil) + _, err := executorExecSession(context.Background(), executor, session, query, nil) assert.Equal(t, nil, err, "err should be nil") } assert.Equal(t, warningCount, warnings.Counts()["WarnPayloadSizeExceeded"], "warnings count") maxPayloadSize = 1000 for _, query := range testMaxPayloadSizeExceeded { - _, err := executor.Execute(context.Background(), nil, "TestExecutorMaxPayloadSizeExceeded", session, query, nil) + _, err := executorExecSession(context.Background(), executor, session, query, nil) assert.Equal(t, nil, err, "err should be nil") } assert.Equal(t, warningCount+4, warnings.Counts()["WarnPayloadSizeExceeded"], "warnings count") @@ -2064,7 +2063,7 @@ func TestExecutorClearsWarnings(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{ Warnings: []*querypb.QueryWarning{{Code: 234, Message: "oh noes"}}, }) - _, err := executor.Execute(context.Background(), nil, "TestExecute", session, "select 42", nil) + _, err := executorExecSession(context.Background(), executor, session, "select 42", nil) require.NoError(t, err) require.Empty(t, session.Warnings) } @@ -2096,7 +2095,7 @@ func TestServingKeyspaces(t *testing.T) { }) require.ElementsMatch(t, []string{"TestExecutor", "TestUnsharded"}, gw.GetServingKeyspaces()) - result, err := executor.Execute(ctx, nil, "TestServingKeyspaces", econtext.NewSafeSession(&vtgatepb.Session{}), "select keyspace_name from dual", nil) + result, err := executorExec(ctx, executor, &vtgatepb.Session{}, "select keyspace_name from dual", nil) require.NoError(t, err) require.Equal(t, `[[VARCHAR("TestExecutor")]]`, fmt.Sprintf("%v", result.Rows)) @@ -2112,7 +2111,7 @@ func TestServingKeyspaces(t *testing.T) { // Clear plan cache, to force re-planning of the query. executor.ClearPlans() require.ElementsMatch(t, []string{"TestUnsharded"}, gw.GetServingKeyspaces()) - result, err = executor.Execute(ctx, nil, "TestServingKeyspaces", econtext.NewSafeSession(&vtgatepb.Session{}), "select keyspace_name from dual", nil) + result, err = executorExec(ctx, executor, &vtgatepb.Session{}, "select keyspace_name from dual", nil) require.NoError(t, err) require.Equal(t, `[[VARCHAR("TestUnsharded")]]`, fmt.Sprintf("%v", result.Rows)) } @@ -2188,7 +2187,7 @@ func TestExecutorOther(t *testing.T) { sbc2.ExecCount.Store(0) sbclookup.ExecCount.Store(0) - _, err := executor.Execute(ctx, nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{TargetString: tc.targetStr}), stmt, nil) + _, err := executorExec(ctx, executor, &vtgatepb.Session{TargetString: tc.targetStr}, stmt, nil) if tc.hasNoKeyspaceErr { assert.Error(t, err, econtext.ErrNoKeyspace.Error()) } else if tc.hasDestinationShardErr { @@ -2244,7 +2243,7 @@ func TestExecutorAnalyze(t *testing.T) { sbc2.ExecCount.Store(0) sbclookup.ExecCount.Store(0) - _, err := executor.Execute(context.Background(), nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{TargetString: tc.targetStr}), stmt, nil) + _, err := executorExec(context.Background(), executor, &vtgatepb.Session{TargetString: tc.targetStr}, stmt, nil) require.NoError(t, err) utils.MustMatch(t, tc.wantCnts, cnts{ @@ -2308,7 +2307,7 @@ func TestExecutorExplainStmt(t *testing.T) { sbc2.ExecCount.Store(0) sbclookup.ExecCount.Store(0) - _, err := executor.Execute(ctx, nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{TargetString: tc.targetStr}), stmt, nil) + _, err := executorExec(ctx, executor, &vtgatepb.Session{TargetString: tc.targetStr}, stmt, nil) assert.NoError(t, err) utils.MustMatch(t, tc.wantCnts, cnts{ @@ -2396,7 +2395,7 @@ func TestExecutorOtherAdmin(t *testing.T) { sbc2.ExecCount.Store(0) sbclookup.ExecCount.Store(0) - _, err := executor.Execute(context.Background(), nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{TargetString: tc.targetStr}), stmt, nil) + _, err := executorExec(context.Background(), executor, &vtgatepb.Session{TargetString: tc.targetStr}, stmt, nil) if tc.hasNoKeyspaceErr { assert.Error(t, err, econtext.ErrNoKeyspace.Error()) } else if tc.hasDestinationShardErr { @@ -2645,7 +2644,7 @@ func TestExecutorCallProc(t *testing.T) { sbc2.ExecCount.Store(0) sbcUnsharded.ExecCount.Store(0) - _, err := executor.Execute(context.Background(), nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{TargetString: tc.targetStr}), "CALL proc()", nil) + _, err := executorExec(context.Background(), executor, &vtgatepb.Session{TargetString: tc.targetStr}, "CALL proc()", nil) if tc.hasNoKeyspaceErr { assert.EqualError(t, err, econtext.ErrNoKeyspace.Error()) } else if tc.unshardedOnlyErr { @@ -2670,7 +2669,7 @@ func TestExecutorTempTable(t *testing.T) { executor.vConfig.WarnShardedOnly = true creatQuery := "create temporary table temp_t(id bigint primary key)" session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: KsTestUnsharded}) - _, err := executor.Execute(ctx, nil, "TestExecutorTempTable", session, creatQuery, nil) + _, err := executorExecSession(ctx, executor, session, creatQuery, nil) require.NoError(t, err) assert.EqualValues(t, 1, sbcUnsharded.ExecCount.Load()) assert.NotEmpty(t, session.Warnings) @@ -2678,7 +2677,7 @@ func TestExecutorTempTable(t *testing.T) { before := executor.plans.Len() - _, err = executor.Execute(ctx, nil, "TestExecutorTempTable", session, "select * from temp_t", nil) + _, err = executorExecSession(ctx, executor, session, "select * from temp_t", nil) require.NoError(t, err) assert.Equal(t, before, executor.plans.Len()) @@ -2689,7 +2688,7 @@ func TestExecutorShowVitessMigrations(t *testing.T) { showQuery := "show vitess_migrations" session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) - _, err := executor.Execute(ctx, nil, "", session, showQuery, nil) + _, err := executorExecSession(ctx, executor, session, showQuery, nil) require.NoError(t, err) assert.Contains(t, sbc1.StringQueries(), "show vitess_migrations") assert.Contains(t, sbc2.StringQueries(), "show vitess_migrations") @@ -2699,10 +2698,10 @@ func TestExecutorDescHash(t *testing.T) { executor, _, _, _, ctx := createExecutorEnv(t) session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) - _, err := executor.Execute(ctx, nil, "", session, "desc hash_index", nil) + _, err := executorExecSession(ctx, executor, session, "desc hash_index", nil) require.EqualError(t, err, "VT05004: table 'hash_index' does not exist") - _, err = executor.Execute(ctx, nil, "", session, "desc music", nil) + _, err = executorExecSession(ctx, executor, session, "desc music", nil) require.NoError(t, err) } @@ -2714,7 +2713,7 @@ func TestExecutorVExplainQueries(t *testing.T) { sbclookup.SetResults([]*sqltypes.Result{ sqltypes.MakeTestResult(sqltypes.MakeTestFields("name|user_id", "varchar|int64"), "apa|1", "apa|2"), }) - qr, err := executor.Execute(ctx, nil, "TestExecutorVExplainQueries", session, "vexplain queries select * from user where name = 'apa'", nil) + qr, err := executorExecSession(ctx, executor, session, "vexplain queries select * from user where name = 'apa'", nil) require.NoError(t, err) txt := fmt.Sprintf("%v\n", qr.Rows) lookupQuery := "select `name`, user_id from name_user_map where `name` in" @@ -2766,12 +2765,12 @@ func TestExecutorStartTxnStmt(t *testing.T) { for _, tcase := range tcases { t.Run(tcase.beginSQL, func(t *testing.T) { - _, err := executor.Execute(ctx, nil, "TestExecutorStartTxnStmt", session, tcase.beginSQL, nil) + _, err := executorExecSession(ctx, executor, session, tcase.beginSQL, nil) require.NoError(t, err) assert.Equal(t, tcase.expTxAccessMode, session.GetOrCreateOptions().TransactionAccessMode) - _, err = executor.Execute(ctx, nil, "TestExecutorStartTxnStmt", session, "rollback", nil) + _, err = executorExecSession(ctx, executor, session, "rollback", nil) require.NoError(t, err) }) @@ -2783,7 +2782,7 @@ func TestExecutorPrepareExecute(t *testing.T) { session := econtext.NewAutocommitSession(&vtgatepb.Session{}) t.Run("prepare statement", func(t *testing.T) { - _, err := executor.Execute(context.Background(), nil, "TestExecutorPrepareExecute", session, "prepare prep_user from 'select * from user where id = ?'", nil) + _, err := executorExecSession(context.Background(), executor, session, "prepare prep_user from 'select * from user where id = ?'", nil) require.NoError(t, err) prepData := session.PrepareStatement["prep_user"] @@ -2793,9 +2792,9 @@ func TestExecutorPrepareExecute(t *testing.T) { }) t.Run("prepare statement using user defined variable", func(t *testing.T) { - _, err := executor.Execute(context.Background(), nil, "TestExecutorPrepareExecute", session, "set @udv_query = 'select * from user where id in (?,?,?)'", nil) + _, err := executorExecSession(context.Background(), executor, session, "set @udv_query = 'select * from user where id in (?,?,?)'", nil) require.NoError(t, err) - _, err = executor.Execute(context.Background(), nil, "TestExecutorPrepareExecute", session, "prepare prep_user2 from @udv_query", nil) + _, err = executorExecSession(context.Background(), executor, session, "prepare prep_user2 from @udv_query", nil) require.NoError(t, err) prepData := session.PrepareStatement["prep_user2"] @@ -2805,7 +2804,7 @@ func TestExecutorPrepareExecute(t *testing.T) { }) t.Run("syntax error on prepared query", func(t *testing.T) { - _, err := executor.Execute(context.Background(), nil, "TestExecutorPrepareExecute", session, "prepare prep_user2 from 'select'", nil) + _, err := executorExecSession(context.Background(), executor, session, "prepare prep_user2 from 'select'", nil) require.Error(t, err) // prepared statement is cleared from the session. @@ -2813,7 +2812,7 @@ func TestExecutorPrepareExecute(t *testing.T) { }) t.Run("user defined variable does not exists on prepared query", func(t *testing.T) { - _, err := executor.Execute(context.Background(), nil, "TestExecutorPrepareExecute", session, "prepare prep_user from @foo", nil) + _, err := executorExecSession(context.Background(), executor, session, "prepare prep_user from @foo", nil) require.Error(t, err) // prepared statement is cleared from the session. @@ -2821,7 +2820,7 @@ func TestExecutorPrepareExecute(t *testing.T) { }) t.Run("empty prepared query", func(t *testing.T) { - _, err := executor.Execute(context.Background(), nil, "TestExecutorPrepareExecute", session, "prepare prep_user from ''", nil) + _, err := executorExecSession(context.Background(), executor, session, "prepare prep_user from ''", nil) require.Error(t, err) }) } @@ -2874,17 +2873,17 @@ func TestExecutorSettingsInTwoPC(t *testing.T) { }) // start transaction - _, err := executor.Execute(ctx, nil, "TestExecutorSettingsInTwoPC", session, "begin", nil) + _, err := executorExecSession(ctx, executor, session, "begin", nil) require.NoError(t, err) // execute queries for _, sql := range tcase.sqls { - _, err = executor.Execute(ctx, nil, "TestExecutorSettingsInTwoPC", session, sql, nil) + _, err = executorExecSession(ctx, executor, session, sql, nil) require.NoError(t, err) } // commit 2pc - _, err = executor.Execute(ctx, nil, "TestExecutorSettingsInTwoPC", session, "commit", nil) + _, err = executorExecSession(ctx, executor, session, "commit", nil) require.NoError(t, err) queriesRecvd, err := sbc1.GetFinalQueries() @@ -2909,7 +2908,7 @@ func TestExecutorTruncateErrors(t *testing.T) { return nil } - _, err := executor.Execute(ctx, nil, "TestExecute", session, "invalid statement", nil) + _, err := executorExecSession(ctx, executor, session, "invalid statement", nil) assert.EqualError(t, err, "syntax error at posi [TRUNCATED]") err = executor.StreamExecute(ctx, nil, "TestExecute", session, "invalid statement", nil, fn) @@ -2964,7 +2963,7 @@ func TestExecutorFlushStmt(t *testing.T) { for _, tc := range tcs { t.Run(tc.query+tc.targetStr, func(t *testing.T) { - _, err := executor.Execute(context.Background(), nil, "TestExecutorFlushStmt", econtext.NewSafeSession(&vtgatepb.Session{TargetString: tc.targetStr}), tc.query, nil) + _, err := executorExec(context.Background(), executor, &vtgatepb.Session{TargetString: tc.targetStr}, tc.query, nil) if tc.expectedErr == "" { require.NoError(t, err) } else { @@ -3011,7 +3010,7 @@ func TestExecutorKillStmt(t *testing.T) { allowKillStmt = !tc.disallow t.Run("execute:"+tc.query+tc.errStr, func(t *testing.T) { mysqlCtx := &fakeMysqlConnection{ErrMsg: tc.errStr} - _, err := executor.Execute(context.Background(), mysqlCtx, "TestExecutorKillStmt", econtext.NewAutocommitSession(&vtgatepb.Session{}), tc.query, nil) + _, err := executor.Execute(context.Background(), mysqlCtx, "TestExecutorKillStmt", econtext.NewAutocommitSession(&vtgatepb.Session{}), tc.query, nil, false) if tc.errStr != "" { require.ErrorContains(t, err, tc.errStr) } else { @@ -3058,7 +3057,7 @@ func (f *fakeMysqlConnection) KillConnection(ctx context.Context, connID uint32) var _ vtgateservice.MySQLConnection = (*fakeMysqlConnection)(nil) func exec(executor *Executor, session *econtext.SafeSession, sql string) (*sqltypes.Result, error) { - return executor.Execute(context.Background(), nil, "TestExecute", session, sql, nil) + return executorExecSession(context.Background(), executor, session, sql, nil) } func makeComments(text string) sqlparser.MarginComments { diff --git a/go/vt/vtgate/executor_vexplain_test.go b/go/vt/vtgate/executor_vexplain_test.go index a9516492f1b..0e929a76291 100644 --- a/go/vt/vtgate/executor_vexplain_test.go +++ b/go/vt/vtgate/executor_vexplain_test.go @@ -138,7 +138,7 @@ func TestVExplainKeys(t *testing.T) { t.Run(tt.Query, func(t *testing.T) { executor, _, _, _, _ := createExecutorEnv(t) session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: "@primary"}) - gotResult, err := executor.Execute(context.Background(), nil, "Execute", session, "vexplain keys "+tt.Query, nil) + gotResult, err := executorExecSession(context.Background(), executor, session, "vexplain keys "+tt.Query, nil) require.NoError(t, err) gotRowString := gotResult.Rows[0][0].ToString() diff --git a/go/vt/vtgate/executor_vschema_ddl_test.go b/go/vt/vtgate/executor_vschema_ddl_test.go index 1acc1ba2362..b8eca5654c8 100644 --- a/go/vt/vtgate/executor_vschema_ddl_test.go +++ b/go/vt/vtgate/executor_vschema_ddl_test.go @@ -155,7 +155,7 @@ func TestPlanExecutorAlterVSchemaKeyspace(t *testing.T) { } stmt := "alter vschema create vindex TestExecutor.test_vindex using hash" - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _, vindex := waitForVindex(t, "TestExecutor", "test_vindex", vschemaUpdates, executor) @@ -184,7 +184,7 @@ func TestPlanExecutorCreateVindexDDL(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: ks}) stmt := "alter vschema create vindex test_vindex using hash" - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _, vindex := waitForVindex(t, ks, "test_vindex", vschemaUpdates, executor) @@ -192,7 +192,7 @@ func TestPlanExecutorCreateVindexDDL(t *testing.T) { t.Errorf("updated vschema did not contain test_vindex") } - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) wantErr := "vindex test_vindex already exists in keyspace TestExecutor" if err == nil || err.Error() != wantErr { t.Errorf("create duplicate vindex: %v, want %s", err, wantErr) @@ -226,14 +226,14 @@ func TestPlanExecutorDropVindexDDL(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: ks}) stmt := "alter vschema drop vindex test_vindex" - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) wantErr := "vindex test_vindex does not exists in keyspace TestExecutor" if err == nil || err.Error() != wantErr { t.Errorf("want error %v got %v", wantErr, err) } stmt = "alter vschema drop vindex TestExecutor.test_vindex" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) wantErr = "vindex test_vindex does not exists in keyspace TestExecutor" if err == nil || err.Error() != wantErr { t.Errorf("want error %v got %v", wantErr, err) @@ -241,7 +241,7 @@ func TestPlanExecutorDropVindexDDL(t *testing.T) { // add one vindex that has never been used by the tables stmt = "alter vschema create vindex test_vindex using hash" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _, vindex := waitForVindex(t, ks, "test_vindex", vschemaUpdates, executor) @@ -251,7 +251,7 @@ func TestPlanExecutorDropVindexDDL(t *testing.T) { // drop an existing vindex that has never been used by the tables stmt = "alter vschema drop vindex TestExecutor.test_vindex" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) vschema = <-vschemaUpdates _, ok = vschema.Keyspaces[ks].Vindexes["test_vindex"] @@ -261,7 +261,7 @@ func TestPlanExecutorDropVindexDDL(t *testing.T) { // drop an existing vindex that is used by at least one table stmt = "alter vschema drop vindex TestExecutor.keyspace_id" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) wantErr = "can not drop vindex cause keyspace_id still defined on table ksid_table" if err == nil || err.Error() != wantErr { t.Errorf("drop vindex still defined: %v, want %s", err, wantErr) @@ -300,19 +300,19 @@ func TestPlanExecutorAddDropVschemaTableDDL(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: ks}) stmt := "alter vschema add table test_table" - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _ = waitForVschemaTables(t, ks, append([]string{"test_table"}, vschemaTables...), executor) stmt = "alter vschema add table test_table2" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _ = waitForVschemaTables(t, ks, append([]string{"test_table", "test_table2"}, vschemaTables...), executor) // Should fail adding a table on a sharded keyspace session = econtext.NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) stmt = "alter vschema add table test_table" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) wantErr := "add vschema table: unsupported on sharded keyspace TestExecutor" if err == nil || err.Error() != wantErr { t.Errorf("want error %v got %v", wantErr, err) @@ -347,7 +347,7 @@ func TestExecutorAddSequenceDDL(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: ks}) stmt := "alter vschema add sequence test_seq" - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _ = waitForVschemaTables(t, ks, append(vschemaTables, []string{"test_seq"}...), executor) vschema = executor.vm.GetCurrentSrvVschema() @@ -362,7 +362,7 @@ func TestExecutorAddSequenceDDL(t *testing.T) { session = econtext.NewSafeSession(&vtgatepb.Session{TargetString: ksSharded}) stmt = "alter vschema add sequence sequence_table" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) wantErr := "add sequence table: unsupported on sharded keyspace TestExecutor" if err == nil || err.Error() != wantErr { @@ -371,13 +371,13 @@ func TestExecutorAddSequenceDDL(t *testing.T) { // Should be able to add autoincrement to table in sharded keyspace stmt = "alter vschema on test_table add vindex hash_index (id)" - if _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil); err != nil { + if _, err = executorExecSession(ctx, executor, session, stmt, nil); err != nil { t.Error(err) } time.Sleep(10 * time.Millisecond) stmt = "alter vschema on test_table add auto_increment id using `db-name`.`test_seq`" - if _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil); err != nil { + if _, err = executorExecSession(ctx, executor, session, stmt, nil); err != nil { t.Error(err) } time.Sleep(10 * time.Millisecond) @@ -409,7 +409,7 @@ func TestExecutorDropSequenceDDL(t *testing.T) { // add test sequence stmt := "alter vschema add sequence test_seq" - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _ = waitForVschemaTables(t, ks, []string{"test_seq"}, executor) vschema = executor.vm.GetCurrentSrvVschema() @@ -422,7 +422,7 @@ func TestExecutorDropSequenceDDL(t *testing.T) { // drop existing test sequence stmt = "alter vschema drop sequence test_seq" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) if !waitForNewerVSchema(ctx, executor, ts, 5*time.Second) { @@ -433,7 +433,7 @@ func TestExecutorDropSequenceDDL(t *testing.T) { session = econtext.NewSafeSession(&vtgatepb.Session{TargetString: ks}) stmt = "alter vschema drop sequence test_seq" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) wantErr := "vschema does not contain sequence test_seq in keyspace TestUnsharded" if err == nil || err.Error() != wantErr { @@ -452,14 +452,14 @@ func TestExecutorDropAutoIncDDL(t *testing.T) { session := econtext.NewSafeSession(&vtgatepb.Session{TargetString: ks}) stmt := "alter vschema add table test_table" - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _ = waitForVschemaTables(t, ks, []string{"test_table"}, executor) ts := executor.VSchema().GetCreated() stmt = "alter vschema on test_table add auto_increment id using `db-name`.`test_seq`" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) if !waitForNewerVSchema(ctx, executor, ts, 5*time.Second) { t.Fatalf("vschema did not update with auto_increment for 'test_table'") @@ -472,7 +472,7 @@ func TestExecutorDropAutoIncDDL(t *testing.T) { utils.MustMatch(t, wantAutoInc, gotAutoInc) stmt = "alter vschema on test_table drop auto_increment" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) if !waitForNewerVSchema(ctx, executor, ts, 5*time.Second) { @@ -503,14 +503,14 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { // Create a new vindex implicitly with the statement stmt := "alter vschema on test add vindex test_hash (id) using hash " - _, err := executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _, vindex := waitForVindex(t, ks, "test_hash", vschemaUpdates, executor) require.Equal(t, "hash", vindex.Type) _ = waitForColVindexes(t, ks, "test", []string{"test_hash"}, executor) - qr, err := executor.Execute(ctx, nil, "TestExecute", session, "show vschema vindexes on TestExecutor.test", nil) + qr, err := executorExecSession(ctx, executor, session, "show vschema vindexes on TestExecutor.test", nil) require.NoError(t, err) wantqr := &sqltypes.Result{ Fields: buildVarCharFields("Columns", "Name", "Type", "Params", "Owner"), @@ -522,17 +522,17 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { // Drop it stmt = "alter vschema on test drop vindex test_hash" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _, _ = waitForVindex(t, ks, "test_hash", vschemaUpdates, executor) _ = waitForColVindexes(t, ks, "test", []string{}, executor) - _, err = executor.Execute(ctx, nil, "TestExecute", session, "show vschema vindexes on TestExecutor.test", nil) + _, err = executorExecSession(ctx, executor, session, "show vschema vindexes on TestExecutor.test", nil) require.EqualError(t, err, "VT05005: table 'test' does not exist in keyspace 'TestExecutor'") // add it again using the same syntax stmt = "alter vschema on test add vindex test_hash (id) using hash " - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _, vindex = waitForVindex(t, ks, "test_hash", vschemaUpdates, executor) @@ -540,7 +540,7 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { _ = waitForColVindexes(t, ks, "test", []string{"test_hash"}, executor) - qr, err = executor.Execute(ctx, nil, "TestExecute", session, "show vschema vindexes on TestExecutor.test", nil) + qr, err = executorExecSession(ctx, executor, session, "show vschema vindexes on TestExecutor.test", nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Columns", "Name", "Type", "Params", "Owner"), @@ -553,7 +553,7 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { // add another stmt = "alter vschema on test add vindex test_lookup (c1,c2) using lookup with owner=`test`, from=`c1,c2`, table=test_lookup, to=keyspace_id" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) vschema, vindex = waitForVindex(t, ks, "test_lookup", vschemaUpdates, executor) @@ -570,7 +570,7 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { t.Fatalf("table test not defined in vschema") } - qr, err = executor.Execute(ctx, nil, "TestExecute", session, "show vschema vindexes on TestExecutor.test", nil) + qr, err = executorExecSession(ctx, executor, session, "show vschema vindexes on TestExecutor.test", nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Columns", "Name", "Type", "Params", "Owner"), @@ -582,7 +582,7 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { utils.MustMatch(t, wantqr, qr) stmt = "alter vschema on test add vindex test_hash_id2 (id2) using hash" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) vschema, vindex = waitForVindex(t, ks, "test_hash_id2", vschemaUpdates, executor) @@ -599,7 +599,7 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { t.Fatalf("table test not defined in vschema") } - qr, err = executor.Execute(ctx, nil, "TestExecute", session, "show vschema vindexes on TestExecutor.test", nil) + qr, err = executorExecSession(ctx, executor, session, "show vschema vindexes on TestExecutor.test", nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Columns", "Name", "Type", "Params", "Owner"), @@ -613,13 +613,13 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { // drop one stmt = "alter vschema on test drop vindex test_lookup" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) // wait for up to 50ms for it to disappear deadline := time.Now().Add(50 * time.Millisecond) for { - qr, err = executor.Execute(ctx, nil, "TestExecute", session, "show vschema vindexes on TestExecutor.test", nil) + qr, err = executorExecSession(ctx, executor, session, "show vschema vindexes on TestExecutor.test", nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Columns", "Name", "Type", "Params", "Owner"), @@ -640,7 +640,7 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { // use the newly created vindex on a new table stmt = "alter vschema on test2 add vindex test_hash (id)" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) vschema, vindex = waitForVindex(t, ks, "test_hash", vschemaUpdates, executor) @@ -653,7 +653,7 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { // create an identical vindex definition on a different table stmt = "alter vschema on test2 add vindex test_lookup (c1,c2) using lookup with owner=`test`, from=`c1,c2`, table=test_lookup, to=keyspace_id" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) vschema, vindex = waitForVindex(t, ks, "test_lookup", vschemaUpdates, executor) @@ -664,7 +664,7 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { require.Len(t, table.ColumnVindexes, 2) require.Equal(t, "test_lookup", table.ColumnVindexes[1].Name) - qr, err = executor.Execute(ctx, nil, "TestExecute", session, "show vschema vindexes on TestExecutor.test2", nil) + qr, err = executorExecSession(ctx, executor, session, "show vschema vindexes on TestExecutor.test2", nil) require.NoError(t, err) wantqr = &sqltypes.Result{ Fields: buildVarCharFields("Columns", "Name", "Type", "Params", "Owner"), @@ -677,7 +677,7 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { // now make sure we can create another vindex that references a table with dashes (i.e. escaping is necessary) stmt = "alter vschema on test2 add vindex test_lookup_fqn(c1,c2) using consistent_lookup_unique with owner=`test`, from=`c1,c2`, table=`test-keyspace`.`lookup-fqn`, to=`keyspace_id`" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.NoError(t, err) _, vindex = waitForVindex(t, ks, "test_lookup_fqn", vschemaUpdates, executor) @@ -688,35 +688,35 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { require.Equal(t, "keyspace_id", vindex.Params["to"]) stmt = "alter vschema on test2 add vindex nonexistent (c1,c2)" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.EqualError(t, err, "vindex nonexistent does not exist in keyspace TestExecutor") stmt = "alter vschema on test2 add vindex test_hash (c1,c2) using lookup" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.EqualError(t, err, "vindex test_hash defined with type hash not lookup") stmt = "alter vschema on test2 add vindex test_lookup (c1,c2) using lookup with owner=xyz" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.EqualError(t, err, "vindex test_lookup defined with owner test not xyz") stmt = "alter vschema on test2 add vindex test_lookup (c1,c2) using lookup with owner=`test`, foo=bar" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.EqualError(t, err, "vindex test_lookup defined with different parameters") stmt = "alter vschema on nonexistent drop vindex test_lookup" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.EqualError(t, err, "table TestExecutor.nonexistent not defined in vschema") stmt = "alter vschema on nonexistent drop vindex test_lookup" - _, err = executor.Execute(ctx, nil, "TestExecute", econtext.NewSafeSession(&vtgatepb.Session{TargetString: "InvalidKeyspace"}), stmt, nil) + _, err = executorExec(ctx, executor, &vtgatepb.Session{TargetString: "InvalidKeyspace"}, stmt, nil) require.EqualError(t, err, "VT05003: unknown database 'InvalidKeyspace' in vschema") stmt = "alter vschema on nowhere.nohow drop vindex test_lookup" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.EqualError(t, err, "VT05003: unknown database 'nowhere' in vschema") stmt = "alter vschema on test drop vindex test_lookup" - _, err = executor.Execute(ctx, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctx, executor, session, stmt, nil) require.EqualError(t, err, "vindex test_lookup not defined in table TestExecutor.test") // no queries should have gone to any tablets @@ -740,31 +740,31 @@ func TestPlanExecutorVindexDDLACL(t *testing.T) { // test that by default no users can perform the operation stmt := "alter vschema create vindex test_hash using hash" - _, err := executor.Execute(ctxRedUser, nil, "TestExecute", session, stmt, nil) + _, err := executorExecSession(ctxRedUser, executor, session, stmt, nil) require.EqualError(t, err, `User 'redUser' is not authorized to perform vschema operations`) - _, err = executor.Execute(ctxBlueUser, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctxBlueUser, executor, session, stmt, nil) require.EqualError(t, err, `User 'blueUser' is not authorized to perform vschema operations`) // test when all users are enabled vschemaacl.AuthorizedDDLUsers.Set(vschemaacl.NewAuthorizedDDLUsers("%")) - _, err = executor.Execute(ctxRedUser, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctxRedUser, executor, session, stmt, nil) if err != nil { t.Errorf("unexpected error '%v'", err) } stmt = "alter vschema create vindex test_hash2 using hash" - _, err = executor.Execute(ctxBlueUser, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctxBlueUser, executor, session, stmt, nil) if err != nil { t.Errorf("unexpected error '%v'", err) } // test when only one user is enabled vschemaacl.AuthorizedDDLUsers.Set(vschemaacl.NewAuthorizedDDLUsers("orangeUser, blueUser, greenUser")) - _, err = executor.Execute(ctxRedUser, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctxRedUser, executor, session, stmt, nil) require.EqualError(t, err, `User 'redUser' is not authorized to perform vschema operations`) stmt = "alter vschema create vindex test_hash3 using hash" - _, err = executor.Execute(ctxBlueUser, nil, "TestExecute", session, stmt, nil) + _, err = executorExecSession(ctxBlueUser, executor, session, stmt, nil) if err != nil { t.Errorf("unexpected error '%v'", err) } diff --git a/go/vt/vtgate/executorcontext/vcursor_impl.go b/go/vt/vtgate/executorcontext/vcursor_impl.go index fbb4d07b82f..a4c800e5053 100644 --- a/go/vt/vtgate/executorcontext/vcursor_impl.go +++ b/go/vt/vtgate/executorcontext/vcursor_impl.go @@ -96,7 +96,7 @@ type ( // vcursor_impl needs these facilities to be able to be able to execute queries for vindexes iExecute interface { - Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, method string, session *SafeSession, s string, vars map[string]*querypb.BindVariable) (*sqltypes.Result, error) + Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, method string, session *SafeSession, s string, vars map[string]*querypb.BindVariable, prepared bool) (*sqltypes.Result, error) ExecuteMultiShard(ctx context.Context, primitive engine.Primitive, rss []*srvtopo.ResolvedShard, queries []*querypb.BoundQuery, session *SafeSession, autocommit bool, ignoreMaxMemoryRows bool, resultsObserver ResultsObserver, fetchLastInsertID bool) (qr *sqltypes.Result, errs []error) StreamExecuteMulti(ctx context.Context, primitive engine.Primitive, query string, rss []*srvtopo.ResolvedShard, vars []map[string]*querypb.BindVariable, session *SafeSession, autocommit bool, callback func(reply *sqltypes.Result) error, observer ResultsObserver, fetchLastInsertID bool) []error ExecuteLock(ctx context.Context, rs *srvtopo.ResolvedShard, query *querypb.BoundQuery, session *SafeSession, lockFuncType sqlparser.LockingFuncType) (*sqltypes.Result, error) @@ -804,7 +804,7 @@ func (vc *VCursorImpl) Execute(ctx context.Context, method string, query string, return nil, err } - qr, err := vc.executor.Execute(ctx, nil, method, session, vc.marginComments.Leading+query+vc.marginComments.Trailing, bindVars) + qr, err := vc.executor.Execute(ctx, nil, method, session, vc.marginComments.Leading+query+vc.marginComments.Trailing, bindVars, false) vc.setRollbackOnPartialExecIfRequired(err != nil, rollbackOnError) return qr, err @@ -819,7 +819,7 @@ func (vc *VCursorImpl) markSavepoint(ctx context.Context, needsRollbackOnParialE } uID := fmt.Sprintf("_vt%s", strings.ReplaceAll(uuid.NewString(), "-", "_")) spQuery := fmt.Sprintf("%ssavepoint %s%s", vc.marginComments.Leading, uID, vc.marginComments.Trailing) - _, err := vc.executor.Execute(ctx, nil, "MarkSavepoint", vc.SafeSession, spQuery, bindVars) + _, err := vc.executor.Execute(ctx, nil, "MarkSavepoint", vc.SafeSession, spQuery, bindVars, false) if err != nil { return err } diff --git a/go/vt/vtgate/executorcontext/vcursor_impl_test.go b/go/vt/vtgate/executorcontext/vcursor_impl_test.go index 1f7368bedec..cb6a9b69986 100644 --- a/go/vt/vtgate/executorcontext/vcursor_impl_test.go +++ b/go/vt/vtgate/executorcontext/vcursor_impl_test.go @@ -329,7 +329,7 @@ func TestRecordMirrorStats(t *testing.T) { type fakeExecutor struct{} -func (f fakeExecutor) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, method string, session *SafeSession, s string, vars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { +func (f fakeExecutor) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, method string, session *SafeSession, s string, vars map[string]*querypb.BindVariable, prepared bool) (*sqltypes.Result, error) { // TODO implement me panic("implement me") } diff --git a/go/vt/vtgate/fakerpcvtgateconn/conn.go b/go/vt/vtgate/fakerpcvtgateconn/conn.go index 56c4e021127..894ac5e2193 100644 --- a/go/vt/vtgate/fakerpcvtgateconn/conn.go +++ b/go/vt/vtgate/fakerpcvtgateconn/conn.go @@ -85,7 +85,13 @@ func (conn *FakeVTGateConn) AddQuery( } // Execute please see vtgateconn.Impl.Execute -func (conn *FakeVTGateConn) Execute(ctx context.Context, session *vtgatepb.Session, sql string, bindVars map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) { +func (conn *FakeVTGateConn) Execute( + ctx context.Context, + session *vtgatepb.Session, + sql string, + bindVars map[string]*querypb.BindVariable, + prepared bool, +) (*vtgatepb.Session, *sqltypes.Result, error) { response, ok := conn.execMap[sql] if !ok { return nil, nil, fmt.Errorf("no match for: %s", sql) diff --git a/go/vt/vtgate/grpcvtgateconn/conn.go b/go/vt/vtgate/grpcvtgateconn/conn.go index f77c2aa05cb..f37f61fd9cc 100644 --- a/go/vt/vtgate/grpcvtgateconn/conn.go +++ b/go/vt/vtgate/grpcvtgateconn/conn.go @@ -107,7 +107,13 @@ func DialWithOpts(_ context.Context, opts ...grpc.DialOption) vtgateconn.DialerF return Dial(opts...) } -func (conn *vtgateConn) Execute(ctx context.Context, session *vtgatepb.Session, query string, bindVars map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) { +func (conn *vtgateConn) Execute( + ctx context.Context, + session *vtgatepb.Session, + query string, + bindVars map[string]*querypb.BindVariable, + prepared bool, +) (*vtgatepb.Session, *sqltypes.Result, error) { request := &vtgatepb.ExecuteRequest{ CallerId: callerid.EffectiveCallerIDFromContext(ctx), Session: session, @@ -115,6 +121,7 @@ func (conn *vtgateConn) Execute(ctx context.Context, session *vtgatepb.Session, Sql: query, BindVariables: bindVars, }, + Prepared: prepared, } response, err := conn.c.Execute(ctx, request) if err != nil { diff --git a/go/vt/vtgate/grpcvtgateconn/conn_rpc_test.go b/go/vt/vtgate/grpcvtgateconn/conn_rpc_test.go index 7f9cd436cab..4cd52d0f5a0 100644 --- a/go/vt/vtgate/grpcvtgateconn/conn_rpc_test.go +++ b/go/vt/vtgate/grpcvtgateconn/conn_rpc_test.go @@ -147,7 +147,7 @@ func TestGRPCVTGateConnAuth(t *testing.T) { RegisterTestDialProtocol(client) conn, _ := vtgateconn.DialProtocol(context.Background(), "test", "") // run the test suite - _, err = conn.Session("", nil).Execute(context.Background(), "select * from t", nil) + _, err = conn.Session("", nil).Execute(context.Background(), "select * from t", nil, false) want := "rpc error: code = Unauthenticated desc = username and password must be provided" if err == nil || err.Error() != want { t.Errorf("expected auth failure:\n%v, want\n%s", err, want) diff --git a/go/vt/vtgate/grpcvtgateconn/suite_test.go b/go/vt/vtgate/grpcvtgateconn/suite_test.go index 357998ad5eb..f1a6d6ba7e3 100644 --- a/go/vt/vtgate/grpcvtgateconn/suite_test.go +++ b/go/vt/vtgate/grpcvtgateconn/suite_test.go @@ -91,7 +91,14 @@ func (q *queryExecute) equal(q2 *queryExecute) bool { } // Execute is part of the VTGateService interface -func (f *fakeVTGateService) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) { +func (f *fakeVTGateService) Execute( + ctx context.Context, + mysqlCtx vtgateservice.MySQLConnection, + session *vtgatepb.Session, + sql string, + bindVariables map[string]*querypb.BindVariable, + prepared bool, +) (*vtgatepb.Session, *sqltypes.Result, error) { if f.hasError { return session, nil, errTestVtGateError } @@ -340,13 +347,13 @@ func verifyErrorString(t *testing.T, err error, method string) { func testExecute(t *testing.T, session *vtgateconn.VTGateSession) { ctx := newContext() execCase := execMap["request1"] - qr, err := session.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables) + qr, err := session.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables, false) require.NoError(t, err) if !qr.Equal(execCase.result) { t.Errorf("Unexpected result from Execute: got\n%#v want\n%#v", qr, execCase.result) } - _, err = session.Execute(ctx, "none", nil) + _, err = session.Execute(ctx, "none", nil, false) want := "no match for: none" if err == nil || !strings.Contains(err.Error(), want) { t.Errorf("none request: %v, want %v", err, want) @@ -357,14 +364,14 @@ func testExecuteError(t *testing.T, session *vtgateconn.VTGateSession, fake *fak ctx := newContext() execCase := execMap["errorRequst"] - _, err := session.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables) + _, err := session.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables, false) verifyError(t, err, "Execute") } func testExecutePanic(t *testing.T, session *vtgateconn.VTGateSession) { ctx := newContext() execCase := execMap["request1"] - _, err := session.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables) + _, err := session.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables, false) expectPanic(t, err) } diff --git a/go/vt/vtgate/grpcvtgateservice/server.go b/go/vt/vtgate/grpcvtgateservice/server.go index df32c8ee9c5..d4b759ed75d 100644 --- a/go/vt/vtgate/grpcvtgateservice/server.go +++ b/go/vt/vtgate/grpcvtgateservice/server.go @@ -145,7 +145,7 @@ func (vtg *VTGate) Execute(ctx context.Context, request *vtgatepb.ExecuteRequest if session == nil { session = &vtgatepb.Session{Autocommit: true} } - session, result, err := vtg.server.Execute(ctx, nil, session, request.Query.Sql, request.Query.BindVariables) + session, result, err := vtg.server.Execute(ctx, nil, session, request.Query.Sql, request.Query.BindVariables, request.Prepared) return &vtgatepb.ExecuteResponse{ Result: sqltypes.ResultToProto3(result), Session: session, diff --git a/go/vt/vtgate/plan_execute.go b/go/vt/vtgate/plan_execute.go index 91c403eca7c..65579d5608a 100644 --- a/go/vt/vtgate/plan_execute.go +++ b/go/vt/vtgate/plan_execute.go @@ -65,6 +65,7 @@ func (e *Executor) newExecute( safeSession *econtext.SafeSession, sql string, bindVars map[string]*querypb.BindVariable, + prepared bool, logStats *logstats.LogStats, execPlan planExec, // used when there is a plan to execute recResult txResult, // used when it's something simple like begin/commit/rollback/savepoint @@ -118,7 +119,7 @@ func (e *Executor) newExecute( // the vtgate to clear the cached plans when processing the new serving vschema. // When buffering ends, many queries might be getting planned at the same time and we then // take full advatange of the cached plan. - plan, vcursor, stmt, err = e.fetchOrCreatePlan(ctx, safeSession, sql, bindVars, e.config.Normalize, false, logStats) + plan, vcursor, stmt, err = e.fetchOrCreatePlan(ctx, safeSession, sql, bindVars, e.config.Normalize, prepared, logStats) execStart := e.logPlanningFinished(logStats, plan) if err != nil { @@ -358,7 +359,7 @@ func (e *Executor) rollbackPartialExec(ctx context.Context, safeSession *econtex rQuery := safeSession.GetRollbackOnPartialExec() if rQuery != econtext.TxRollback { safeSession.SavepointRollback() - _, _, err = e.execute(ctx, nil, safeSession, rQuery, bindVars, logStats) + _, _, err = e.execute(ctx, nil, safeSession, rQuery, bindVars, false, logStats) // If no error, the revert is successful with the savepoint. Notify the reason as error to the client. if err == nil { errMsg.WriteString("reverted partial DML execution failure") diff --git a/go/vt/vtgate/plugin_mysql_server.go b/go/vt/vtgate/plugin_mysql_server.go index 8fbb2274f1f..512a278e0ff 100644 --- a/go/vt/vtgate/plugin_mysql_server.go +++ b/go/vt/vtgate/plugin_mysql_server.go @@ -258,7 +258,7 @@ func (vh *vtgateHandler) ComQuery(c *mysql.Conn, query string, callback func(*sq fillInTxStatusFlags(c, session) return nil } - session, result, err := vh.vtg.Execute(ctx, vh, session, query, make(map[string]*querypb.BindVariable)) + session, result, err := vh.vtg.Execute(ctx, vh, session, query, make(map[string]*querypb.BindVariable), false) if err := sqlerror.NewSQLErrorFromError(err); err != nil { return err @@ -364,7 +364,7 @@ func (vh *vtgateHandler) ComStmtExecute(c *mysql.Conn, prepare *mysql.PrepareDat fillInTxStatusFlags(c, session) return nil } - _, qr, err := vh.vtg.Execute(ctx, vh, session, prepare.PrepareStmt, prepare.BindVars) + _, qr, err := vh.vtg.Execute(ctx, vh, session, prepare.PrepareStmt, prepare.BindVars, true) if err != nil { return sqlerror.NewSQLErrorFromError(err) } diff --git a/go/vt/vtgate/vtgate.go b/go/vt/vtgate/vtgate.go index 2cdf3822f23..568ae22f840 100644 --- a/go/vt/vtgate/vtgate.go +++ b/go/vt/vtgate/vtgate.go @@ -488,7 +488,14 @@ func (vtg *VTGate) Gateway() *TabletGateway { } // Execute executes a non-streaming query. -func (vtg *VTGate) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (newSession *vtgatepb.Session, qr *sqltypes.Result, err error) { +func (vtg *VTGate) Execute( + ctx context.Context, + mysqlCtx vtgateservice.MySQLConnection, + session *vtgatepb.Session, + sql string, + bindVariables map[string]*querypb.BindVariable, + prepared bool, +) (newSession *vtgatepb.Session, qr *sqltypes.Result, err error) { // In this context, we don't care if we can't fully parse destination destKeyspace, destTabletType, _, _ := vtg.executor.ParseDestinationTarget(session.TargetString) statsKey := []string{"Execute", destKeyspace, topoproto.TabletTypeLString(destTabletType)} @@ -498,7 +505,7 @@ func (vtg *VTGate) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConn err = vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "%v", bvErr) } else { safeSession := econtext.NewSafeSession(session) - qr, err = vtg.executor.Execute(ctx, mysqlCtx, "Execute", safeSession, sql, bindVariables) + qr, err = vtg.executor.Execute(ctx, mysqlCtx, "Execute", safeSession, sql, bindVariables, prepared) safeSession.RemoveInternalSavepoint() } if err == nil { @@ -536,7 +543,7 @@ func (vtg *VTGate) ExecuteBatch(ctx context.Context, session *vtgatepb.Session, if len(bindVariablesList) != 0 { bv = bindVariablesList[i] } - session, qrl[i].QueryResult, qrl[i].QueryError = vtg.Execute(ctx, nil, session, sql, bv) + session, qrl[i].QueryResult, qrl[i].QueryError = vtg.Execute(ctx, nil, session, sql, bv, false) if qr := qrl[i].QueryResult; qr != nil { vtg.rowsReturned.Add(statsKey, int64(len(qr.Rows))) vtg.rowsAffected.Add(statsKey, int64(qr.RowsAffected)) diff --git a/go/vt/vtgate/vtgate_test.go b/go/vt/vtgate/vtgate_test.go index 2919c6911c2..1b056cc378d 100644 --- a/go/vt/vtgate/vtgate_test.go +++ b/go/vt/vtgate/vtgate_test.go @@ -58,6 +58,7 @@ func TestVTGateExecute(t *testing.T) { }, "select id from t1", nil, + false, ) if err != nil { t.Errorf("want nil, got %v", err) @@ -98,6 +99,7 @@ func TestVTGateExecuteError(t *testing.T) { }, "bad select id from t1", nil, + false, ) require.Error(t, err) require.Nil(t, qr) @@ -188,6 +190,7 @@ func TestVTGateExecuteWithKeyspaceShard(t *testing.T) { }, "select id from none", nil, + false, ) if err != nil { t.Errorf("want nil, got %v", err) @@ -205,6 +208,7 @@ func TestVTGateExecuteWithKeyspaceShard(t *testing.T) { }, "select id from none", nil, + false, ) want := "VT05003: unknown database 'invalid_keyspace' in vschema" assert.EqualError(t, err, want) @@ -218,6 +222,7 @@ func TestVTGateExecuteWithKeyspaceShard(t *testing.T) { }, "select id from none", nil, + false, ) if err != nil { t.Errorf("want nil, got %v", err) @@ -233,6 +238,7 @@ func TestVTGateExecuteWithKeyspaceShard(t *testing.T) { }, "select id from none", nil, + false, ) require.Error(t, err) require.Contains(t, err.Error(), `no healthy tablet available for 'keyspace:"TestExecutor" shard:"noshard" tablet_type:PRIMARY`) @@ -286,7 +292,7 @@ func TestVTGateBindVarError(t *testing.T) { }{{ name: "Execute", f: func() error { - _, _, err := vtg.Execute(ctx, nil, session, "", bindVars) + _, _, err := vtg.Execute(ctx, nil, session, "", bindVars, false) return err }, }, { @@ -325,6 +331,7 @@ func testErrorPropagation(t *testing.T, ctx context.Context, vtg *VTGate, sbcs [ session, "select id from t1", nil, + false, ) if err == nil { t.Errorf("error %v not propagated for Execute", expected) @@ -457,11 +464,11 @@ func TestErrorIssuesRollback(t *testing.T) { // Start a transaction, send one statement. // Simulate an error that should trigger a rollback: // vtrpcpb.Code_ABORTED case. - session, _, err := vtg.Execute(ctx, nil, &vtgatepb.Session{TargetString: KsTestUnsharded + "@primary"}, "begin", nil) + session, _, err := vtg.Execute(ctx, nil, &vtgatepb.Session{TargetString: KsTestUnsharded + "@primary"}, "begin", nil, false) if err != nil { t.Fatalf("cannot start a transaction: %v", err) } - session, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil) + session, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil, false) if err != nil { t.Fatalf("want nil, got %v", err) } @@ -469,7 +476,7 @@ func TestErrorIssuesRollback(t *testing.T) { t.Errorf("want 0, got %d", sbc.RollbackCount.Load()) } sbc.MustFailCodes[vtrpcpb.Code_ABORTED] = 20 - _, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil) + _, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil, false) if err == nil { t.Fatalf("want error but got nil") } @@ -482,11 +489,11 @@ func TestErrorIssuesRollback(t *testing.T) { // Start a transaction, send one statement. // Simulate an error that should trigger a rollback: // vtrpcpb.ErrorCode_RESOURCE_EXHAUSTED case. - session, _, err = vtg.Execute(ctx, nil, &vtgatepb.Session{TargetString: KsTestUnsharded + "@primary"}, "begin", nil) + session, _, err = vtg.Execute(ctx, nil, &vtgatepb.Session{TargetString: KsTestUnsharded + "@primary"}, "begin", nil, false) if err != nil { t.Fatalf("cannot start a transaction: %v", err) } - session, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil) + session, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil, false) if err != nil { t.Fatalf("want nil, got %v", err) } @@ -494,7 +501,7 @@ func TestErrorIssuesRollback(t *testing.T) { t.Errorf("want 0, got %d", sbc.RollbackCount.Load()) } sbc.MustFailCodes[vtrpcpb.Code_RESOURCE_EXHAUSTED] = 20 - _, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil) + _, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil, false) if err == nil { t.Fatalf("want error but got nil") } @@ -507,11 +514,11 @@ func TestErrorIssuesRollback(t *testing.T) { // Start a transaction, send one statement. // Simulate an error that should *not* trigger a rollback: // vtrpcpb.Code_ALREADY_EXISTS case. - session, _, err = vtg.Execute(ctx, nil, &vtgatepb.Session{TargetString: KsTestUnsharded + "@primary"}, "begin", nil) + session, _, err = vtg.Execute(ctx, nil, &vtgatepb.Session{TargetString: KsTestUnsharded + "@primary"}, "begin", nil, false) if err != nil { t.Fatalf("cannot start a transaction: %v", err) } - session, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil) + session, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil, false) if err != nil { t.Fatalf("want nil, got %v", err) } @@ -519,7 +526,7 @@ func TestErrorIssuesRollback(t *testing.T) { t.Errorf("want 0, got %d", sbc.RollbackCount.Load()) } sbc.MustFailCodes[vtrpcpb.Code_ALREADY_EXISTS] = 20 - _, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil) + _, _, err = vtg.Execute(ctx, nil, session, "select id from t1", nil, false) if err == nil { t.Fatalf("want error but got nil") } @@ -605,13 +612,13 @@ func TestMultiInternalSavepointVtGate(t *testing.T) { require.False(t, session.InTransaction) var err error - session, _, err = vtg.Execute(ctx, nil, session, "begin", nil) + session, _, err = vtg.Execute(ctx, nil, session, "begin", nil, false) require.NoError(t, err) require.True(t, session.GetAutocommit()) require.True(t, session.InTransaction) // this query goes to multiple shards so internal savepoint will be created. - session, _, err = vtg.Execute(ctx, nil, session, "insert into sp_tbl(user_id) values (1), (3)", nil) + session, _, err = vtg.Execute(ctx, nil, session, "insert into sp_tbl(user_id) values (1), (3)", nil, false) require.NoError(t, err) require.True(t, session.GetAutocommit()) require.True(t, session.InTransaction) @@ -639,7 +646,7 @@ func TestMultiInternalSavepointVtGate(t *testing.T) { sbc2.Queries = nil // multi shard so new savepoint will be created. - session, _, err = vtg.Execute(ctx, nil, session, "insert into sp_tbl(user_id) values (2), (4)", nil) + session, _, err = vtg.Execute(ctx, nil, session, "insert into sp_tbl(user_id) values (2), (4)", nil, false) require.NoError(t, err) wantQ = []*querypb.BoundQuery{{ Sql: "savepoint x", @@ -657,7 +664,7 @@ func TestMultiInternalSavepointVtGate(t *testing.T) { sbc3.Queries = nil // single shard so no savepoint will be created and neither any old savepoint will be executed - _, _, err = vtg.Execute(ctx, nil, session, "insert into sp_tbl(user_id) values (5)", nil) + _, _, err = vtg.Execute(ctx, nil, session, "insert into sp_tbl(user_id) values (5)", nil, false) require.NoError(t, err) wantQ = []*querypb.BoundQuery{{ Sql: "insert into sp_tbl(user_id) values (:_user_id_0)", diff --git a/go/vt/vtgate/vtgateconn/vtgateconn.go b/go/vt/vtgate/vtgateconn/vtgateconn.go index 0445d02805f..7455bd6dd88 100644 --- a/go/vt/vtgate/vtgateconn/vtgateconn.go +++ b/go/vt/vtgate/vtgateconn/vtgateconn.go @@ -118,8 +118,8 @@ type VTGateSession struct { } // Execute performs a VTGate Execute. -func (sn *VTGateSession) Execute(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - session, res, err := sn.impl.Execute(ctx, sn.session, query, bindVars) +func (sn *VTGateSession) Execute(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable, prepared bool) (*sqltypes.Result, error) { + session, res, err := sn.impl.Execute(ctx, sn.session, query, bindVars, prepared) sn.session = session return res, err } @@ -159,7 +159,7 @@ func (sn *VTGateSession) Prepare(ctx context.Context, query string) ([]*querypb. // implementation. It can be used concurrently across goroutines. type Impl interface { // Execute executes a non-streaming query on vtgate. - Execute(ctx context.Context, session *vtgatepb.Session, query string, bindVars map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) + Execute(ctx context.Context, session *vtgatepb.Session, query string, bindVars map[string]*querypb.BindVariable, prepared bool) (*vtgatepb.Session, *sqltypes.Result, error) // ExecuteBatch executes a non-streaming queries on vtgate. ExecuteBatch(ctx context.Context, session *vtgatepb.Session, queryList []string, bindVarsList []map[string]*querypb.BindVariable) (*vtgatepb.Session, []sqltypes.QueryResponse, error) diff --git a/go/vt/vtgate/vtgateservice/interface.go b/go/vt/vtgate/vtgateservice/interface.go index d3ce48cbb61..e97020651d5 100644 --- a/go/vt/vtgate/vtgateservice/interface.go +++ b/go/vt/vtgate/vtgateservice/interface.go @@ -31,7 +31,7 @@ import ( // VTGateService is the interface implemented by the VTGate service, // that RPC server implementations will call. type VTGateService interface { - Execute(ctx context.Context, mysqlCtx MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) + Execute(ctx context.Context, mysqlCtx MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable, prepared bool) (*vtgatepb.Session, *sqltypes.Result, error) ExecuteBatch(ctx context.Context, session *vtgatepb.Session, sqlList []string, bindVariablesList []map[string]*querypb.BindVariable) (*vtgatepb.Session, []sqltypes.QueryResponse, error) StreamExecute(ctx context.Context, mysqlCtx MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable, callback func(*sqltypes.Result) error) (*vtgatepb.Session, error) // Prepare statement support diff --git a/go/vtbench/client.go b/go/vtbench/client.go index 585a66d356f..869b0c92917 100644 --- a/go/vtbench/client.go +++ b/go/vtbench/client.go @@ -106,7 +106,7 @@ func (c *grpcVtgateConn) connect(ctx context.Context, cp ConnParams) error { } func (c *grpcVtgateConn) execute(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - return c.session.Execute(ctx, query, bindVars) + return c.session.Execute(ctx, query, bindVars, false) } type grpcVttabletConn struct { diff --git a/proto/vtgate.proto b/proto/vtgate.proto index 3dd308d07ce..189428ec0c7 100644 --- a/proto/vtgate.proto +++ b/proto/vtgate.proto @@ -194,6 +194,8 @@ message ExecuteRequest { // Deprecated: use session.in_transaction instead // bool not_in_transaction = 5; reserved 4, 5, 6, 7; + + bool prepared = 8; } // ExecuteResponse is the returned value from Execute.