зеркало из https://github.com/github/vitess-gh.git
vtgate: Remove notInTransaction parameter from transaction object Execute* methods.
The flag is not used in open-source, so we don't want to expose it here.
This commit is contained in:
Родитель
e0e43ba4b2
Коммит
126730a663
|
@ -251,17 +251,17 @@ func testEchoTransactionExecute(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
t.Fatalf("Begin error: %v", err)
|
||||
}
|
||||
|
||||
qr, err = tx.Execute(ctx, echoPrefix+query, bindVars, tabletType, true)
|
||||
qr, err = tx.Execute(ctx, echoPrefix+query, bindVars, tabletType)
|
||||
checkEcho(t, "Execute", qr, err, map[string]string{
|
||||
"callerId": callerIDEcho,
|
||||
"query": echoPrefix + query,
|
||||
"bindVars": bindVarsEcho,
|
||||
"tabletType": tabletTypeEcho,
|
||||
"session": sessionEcho,
|
||||
"notInTransaction": "true",
|
||||
"notInTransaction": "false",
|
||||
})
|
||||
|
||||
qr, err = tx.ExecuteShards(ctx, echoPrefix+query, keyspace, shards, bindVars, tabletType, true)
|
||||
qr, err = tx.ExecuteShards(ctx, echoPrefix+query, keyspace, shards, bindVars, tabletType)
|
||||
checkEcho(t, "ExecuteShards", qr, err, map[string]string{
|
||||
"callerId": callerIDEcho,
|
||||
"query": echoPrefix + query,
|
||||
|
@ -270,10 +270,10 @@ func testEchoTransactionExecute(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
"bindVars": bindVarsEcho,
|
||||
"tabletType": tabletTypeEcho,
|
||||
"session": sessionEcho,
|
||||
"notInTransaction": "true",
|
||||
"notInTransaction": "false",
|
||||
})
|
||||
|
||||
qr, err = tx.ExecuteKeyspaceIds(ctx, echoPrefix+query, keyspace, keyspaceIDs, bindVars, tabletType, true)
|
||||
qr, err = tx.ExecuteKeyspaceIds(ctx, echoPrefix+query, keyspace, keyspaceIDs, bindVars, tabletType)
|
||||
checkEcho(t, "ExecuteKeyspaceIds", qr, err, map[string]string{
|
||||
"callerId": callerIDEcho,
|
||||
"query": echoPrefix + query,
|
||||
|
@ -282,10 +282,10 @@ func testEchoTransactionExecute(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
"bindVars": bindVarsEcho,
|
||||
"tabletType": tabletTypeEcho,
|
||||
"session": sessionEcho,
|
||||
"notInTransaction": "true",
|
||||
"notInTransaction": "false",
|
||||
})
|
||||
|
||||
qr, err = tx.ExecuteKeyRanges(ctx, echoPrefix+query, keyspace, keyRanges, bindVars, tabletType, true)
|
||||
qr, err = tx.ExecuteKeyRanges(ctx, echoPrefix+query, keyspace, keyRanges, bindVars, tabletType)
|
||||
checkEcho(t, "ExecuteKeyRanges", qr, err, map[string]string{
|
||||
"callerId": callerIDEcho,
|
||||
"query": echoPrefix + query,
|
||||
|
@ -294,10 +294,10 @@ func testEchoTransactionExecute(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
"bindVars": bindVarsEcho,
|
||||
"tabletType": tabletTypeEcho,
|
||||
"session": sessionEcho,
|
||||
"notInTransaction": "true",
|
||||
"notInTransaction": "false",
|
||||
})
|
||||
|
||||
qr, err = tx.ExecuteEntityIds(ctx, echoPrefix+query, keyspace, "column1", entityKeyspaceIDs, bindVars, tabletType, true)
|
||||
qr, err = tx.ExecuteEntityIds(ctx, echoPrefix+query, keyspace, "column1", entityKeyspaceIDs, bindVars, tabletType)
|
||||
checkEcho(t, "ExecuteEntityIds", qr, err, map[string]string{
|
||||
"callerId": callerIDEcho,
|
||||
"query": echoPrefix + query,
|
||||
|
@ -307,7 +307,7 @@ func testEchoTransactionExecute(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
"bindVars": bindVarsEcho,
|
||||
"tabletType": tabletTypeEcho,
|
||||
"session": sessionEcho,
|
||||
"notInTransaction": "true",
|
||||
"notInTransaction": "false",
|
||||
})
|
||||
|
||||
if err := tx.Rollback(ctx); err != nil {
|
||||
|
|
|
@ -114,23 +114,23 @@ func testTransactionExecuteErrors(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
ctx := context.Background()
|
||||
|
||||
checkTransactionExecuteErrors(t, conn, func(tx *vtgateconn.VTGateTx, query string) error {
|
||||
_, err := tx.Execute(ctx, query, bindVars, tabletType, true)
|
||||
_, err := tx.Execute(ctx, query, bindVars, tabletType)
|
||||
return err
|
||||
})
|
||||
checkTransactionExecuteErrors(t, conn, func(tx *vtgateconn.VTGateTx, query string) error {
|
||||
_, err := tx.ExecuteShards(ctx, query, keyspace, shards, bindVars, tabletType, true)
|
||||
_, err := tx.ExecuteShards(ctx, query, keyspace, shards, bindVars, tabletType)
|
||||
return err
|
||||
})
|
||||
checkTransactionExecuteErrors(t, conn, func(tx *vtgateconn.VTGateTx, query string) error {
|
||||
_, err := tx.ExecuteKeyspaceIds(ctx, query, keyspace, keyspaceIDs, bindVars, tabletType, true)
|
||||
_, err := tx.ExecuteKeyspaceIds(ctx, query, keyspace, keyspaceIDs, bindVars, tabletType)
|
||||
return err
|
||||
})
|
||||
checkTransactionExecuteErrors(t, conn, func(tx *vtgateconn.VTGateTx, query string) error {
|
||||
_, err := tx.ExecuteKeyRanges(ctx, query, keyspace, keyRanges, bindVars, tabletType, true)
|
||||
_, err := tx.ExecuteKeyRanges(ctx, query, keyspace, keyRanges, bindVars, tabletType)
|
||||
return err
|
||||
})
|
||||
checkTransactionExecuteErrors(t, conn, func(tx *vtgateconn.VTGateTx, query string) error {
|
||||
_, err := tx.ExecuteEntityIds(ctx, query, keyspace, "column1", entityKeyspaceIDs, bindVars, tabletType, true)
|
||||
_, err := tx.ExecuteEntityIds(ctx, query, keyspace, "column1", entityKeyspaceIDs, bindVars, tabletType)
|
||||
return err
|
||||
})
|
||||
checkTransactionExecuteErrors(t, conn, func(tx *vtgateconn.VTGateTx, query string) error {
|
||||
|
|
|
@ -327,9 +327,9 @@ func (s *stmt) Query(args []driver.Value) (driver.Rows, error) {
|
|||
func (s *stmt) executeVitess(ctx context.Context, args []driver.Value) (*sqltypes.Result, error) {
|
||||
if s.c.tx != nil {
|
||||
if s.c.useExecuteShards() {
|
||||
return s.c.tx.ExecuteShards(ctx, s.query, s.c.Keyspace, []string{s.c.Shard}, makeBindVars(args), s.c.tabletTypeProto, false /* notInTransaction */)
|
||||
return s.c.tx.ExecuteShards(ctx, s.query, s.c.Keyspace, []string{s.c.Shard}, makeBindVars(args), s.c.tabletTypeProto)
|
||||
}
|
||||
return s.c.tx.Execute(ctx, s.query, makeBindVars(args), s.c.tabletTypeProto, false /* notInTransaction */)
|
||||
return s.c.tx.Execute(ctx, s.query, makeBindVars(args), s.c.tabletTypeProto)
|
||||
}
|
||||
|
||||
// Non-transactional case.
|
||||
|
|
|
@ -157,7 +157,7 @@ func (conn *FakeVTGateConn) AddSplitQuery(
|
|||
}
|
||||
|
||||
// Execute please see vtgateconn.Impl.Execute
|
||||
func (conn *FakeVTGateConn) Execute(ctx context.Context, sql string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *FakeVTGateConn) Execute(ctx context.Context, sql string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
var s *vtgatepb.Session
|
||||
if session != nil {
|
||||
s = session.(*vtgatepb.Session)
|
||||
|
@ -167,11 +167,10 @@ func (conn *FakeVTGateConn) Execute(ctx context.Context, sql string, bindVars ma
|
|||
return nil, nil, fmt.Errorf("no match for: %s", sql)
|
||||
}
|
||||
query := &queryExecute{
|
||||
SQL: sql,
|
||||
BindVariables: bindVars,
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
NotInTransaction: notInTransaction,
|
||||
SQL: sql,
|
||||
BindVariables: bindVars,
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
}
|
||||
if !reflect.DeepEqual(query, response.execQuery) {
|
||||
return nil, nil, fmt.Errorf(
|
||||
|
@ -186,7 +185,7 @@ func (conn *FakeVTGateConn) Execute(ctx context.Context, sql string, bindVars ma
|
|||
}
|
||||
|
||||
// ExecuteShards please see vtgateconn.Impl.ExecuteShard
|
||||
func (conn *FakeVTGateConn) ExecuteShards(ctx context.Context, sql string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *FakeVTGateConn) ExecuteShards(ctx context.Context, sql string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
var s *vtgatepb.Session
|
||||
if session != nil {
|
||||
s = session.(*vtgatepb.Session)
|
||||
|
@ -196,13 +195,12 @@ func (conn *FakeVTGateConn) ExecuteShards(ctx context.Context, sql string, keysp
|
|||
return nil, nil, fmt.Errorf("no match for: %s", sql)
|
||||
}
|
||||
query := &queryExecuteShards{
|
||||
SQL: sql,
|
||||
BindVariables: bindVars,
|
||||
TabletType: tabletType,
|
||||
Keyspace: keyspace,
|
||||
Shards: shards,
|
||||
Session: s,
|
||||
NotInTransaction: notInTransaction,
|
||||
SQL: sql,
|
||||
BindVariables: bindVars,
|
||||
TabletType: tabletType,
|
||||
Keyspace: keyspace,
|
||||
Shards: shards,
|
||||
Session: s,
|
||||
}
|
||||
if !reflect.DeepEqual(query, response.shardQuery) {
|
||||
return nil, nil, fmt.Errorf(
|
||||
|
@ -217,17 +215,17 @@ func (conn *FakeVTGateConn) ExecuteShards(ctx context.Context, sql string, keysp
|
|||
}
|
||||
|
||||
// ExecuteKeyspaceIds please see vtgateconn.Impl.ExecuteKeyspaceIds
|
||||
func (conn *FakeVTGateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *FakeVTGateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
// ExecuteKeyRanges please see vtgateconn.Impl.ExecuteKeyRanges
|
||||
func (conn *FakeVTGateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *FakeVTGateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
// ExecuteEntityIds please see vtgateconn.Impl.ExecuteEntityIds
|
||||
func (conn *FakeVTGateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *FakeVTGateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
|
|
@ -84,15 +84,14 @@ func sessionFromRPC(session *vtgatepb.Session) interface{} {
|
|||
return session
|
||||
}
|
||||
|
||||
func (conn *vtgateConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *vtgateConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
s := sessionToRPC(session)
|
||||
request := gorpcvtgatecommon.Query{
|
||||
CallerID: getEffectiveCallerID(ctx),
|
||||
Sql: query,
|
||||
BindVariables: bindVars,
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
NotInTransaction: notInTransaction,
|
||||
CallerID: getEffectiveCallerID(ctx),
|
||||
Sql: query,
|
||||
BindVariables: bindVars,
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
}
|
||||
var result gorpcvtgatecommon.QueryResult
|
||||
if err := conn.rpcConn.Call(ctx, "VTGate.Execute", request, &result); err != nil {
|
||||
|
@ -107,17 +106,16 @@ func (conn *vtgateConn) Execute(ctx context.Context, query string, bindVars map[
|
|||
return result.Result, sessionFromRPC(result.Session), nil
|
||||
}
|
||||
|
||||
func (conn *vtgateConn) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *vtgateConn) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
s := sessionToRPC(session)
|
||||
request := gorpcvtgatecommon.QueryShard{
|
||||
CallerID: getEffectiveCallerID(ctx),
|
||||
Sql: query,
|
||||
BindVariables: bindVars,
|
||||
Keyspace: keyspace,
|
||||
Shards: shards,
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
NotInTransaction: notInTransaction,
|
||||
CallerID: getEffectiveCallerID(ctx),
|
||||
Sql: query,
|
||||
BindVariables: bindVars,
|
||||
Keyspace: keyspace,
|
||||
Shards: shards,
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
}
|
||||
var result gorpcvtgatecommon.QueryResult
|
||||
if err := conn.rpcConn.Call(ctx, "VTGate.ExecuteShard", request, &result); err != nil {
|
||||
|
@ -132,17 +130,16 @@ func (conn *vtgateConn) ExecuteShards(ctx context.Context, query string, keyspac
|
|||
return result.Result, sessionFromRPC(result.Session), nil
|
||||
}
|
||||
|
||||
func (conn *vtgateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *vtgateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
s := sessionToRPC(session)
|
||||
request := gorpcvtgatecommon.KeyspaceIdQuery{
|
||||
CallerID: getEffectiveCallerID(ctx),
|
||||
Sql: query,
|
||||
BindVariables: bindVars,
|
||||
Keyspace: keyspace,
|
||||
KeyspaceIds: keyspaceIds,
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
NotInTransaction: notInTransaction,
|
||||
CallerID: getEffectiveCallerID(ctx),
|
||||
Sql: query,
|
||||
BindVariables: bindVars,
|
||||
Keyspace: keyspace,
|
||||
KeyspaceIds: keyspaceIds,
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
}
|
||||
var result gorpcvtgatecommon.QueryResult
|
||||
if err := conn.rpcConn.Call(ctx, "VTGate.ExecuteKeyspaceIds", request, &result); err != nil {
|
||||
|
@ -157,17 +154,16 @@ func (conn *vtgateConn) ExecuteKeyspaceIds(ctx context.Context, query string, ke
|
|||
return result.Result, sessionFromRPC(result.Session), nil
|
||||
}
|
||||
|
||||
func (conn *vtgateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *vtgateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
s := sessionToRPC(session)
|
||||
request := gorpcvtgatecommon.KeyRangeQuery{
|
||||
CallerID: getEffectiveCallerID(ctx),
|
||||
Sql: query,
|
||||
BindVariables: bindVars,
|
||||
Keyspace: keyspace,
|
||||
KeyRanges: keyRanges,
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
NotInTransaction: notInTransaction,
|
||||
CallerID: getEffectiveCallerID(ctx),
|
||||
Sql: query,
|
||||
BindVariables: bindVars,
|
||||
Keyspace: keyspace,
|
||||
KeyRanges: keyRanges,
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
}
|
||||
var result gorpcvtgatecommon.QueryResult
|
||||
if err := conn.rpcConn.Call(ctx, "VTGate.ExecuteKeyRanges", request, &result); err != nil {
|
||||
|
@ -182,7 +178,7 @@ func (conn *vtgateConn) ExecuteKeyRanges(ctx context.Context, query string, keys
|
|||
return result.Result, sessionFromRPC(result.Session), nil
|
||||
}
|
||||
|
||||
func (conn *vtgateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *vtgateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
s := sessionToRPC(session)
|
||||
request := gorpcvtgatecommon.EntityIdsQuery{
|
||||
CallerID: getEffectiveCallerID(ctx),
|
||||
|
@ -193,7 +189,6 @@ func (conn *vtgateConn) ExecuteEntityIds(ctx context.Context, query string, keys
|
|||
EntityKeyspaceIDs: gorpcvtgatecommon.ProtoToEntityIds(entityKeyspaceIDs),
|
||||
TabletType: tabletType,
|
||||
Session: s,
|
||||
NotInTransaction: notInTransaction,
|
||||
}
|
||||
var result gorpcvtgatecommon.QueryResult
|
||||
if err := conn.rpcConn.Call(ctx, "VTGate.ExecuteEntityIds", request, &result); err != nil {
|
||||
|
|
|
@ -45,7 +45,7 @@ func dial(ctx context.Context, addr string, timeout time.Duration) (vtgateconn.I
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (conn *vtgateConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *vtgateConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
var s *vtgatepb.Session
|
||||
if session != nil {
|
||||
s = session.(*vtgatepb.Session)
|
||||
|
@ -55,11 +55,10 @@ func (conn *vtgateConn) Execute(ctx context.Context, query string, bindVars map[
|
|||
return nil, session, err
|
||||
}
|
||||
request := &vtgatepb.ExecuteRequest{
|
||||
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
|
||||
Session: s,
|
||||
Query: q,
|
||||
TabletType: tabletType,
|
||||
NotInTransaction: notInTransaction,
|
||||
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
|
||||
Session: s,
|
||||
Query: q,
|
||||
TabletType: tabletType,
|
||||
}
|
||||
response, err := conn.c.Execute(ctx, request)
|
||||
if err != nil {
|
||||
|
@ -71,7 +70,7 @@ func (conn *vtgateConn) Execute(ctx context.Context, query string, bindVars map[
|
|||
return sqltypes.Proto3ToResult(response.Result), response.Session, nil
|
||||
}
|
||||
|
||||
func (conn *vtgateConn) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *vtgateConn) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
var s *vtgatepb.Session
|
||||
if session != nil {
|
||||
s = session.(*vtgatepb.Session)
|
||||
|
@ -81,13 +80,12 @@ func (conn *vtgateConn) ExecuteShards(ctx context.Context, query string, keyspac
|
|||
return nil, session, err
|
||||
}
|
||||
request := &vtgatepb.ExecuteShardsRequest{
|
||||
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
|
||||
Session: s,
|
||||
Query: q,
|
||||
Keyspace: keyspace,
|
||||
Shards: shards,
|
||||
TabletType: tabletType,
|
||||
NotInTransaction: notInTransaction,
|
||||
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
|
||||
Session: s,
|
||||
Query: q,
|
||||
Keyspace: keyspace,
|
||||
Shards: shards,
|
||||
TabletType: tabletType,
|
||||
}
|
||||
response, err := conn.c.ExecuteShards(ctx, request)
|
||||
if err != nil {
|
||||
|
@ -99,7 +97,7 @@ func (conn *vtgateConn) ExecuteShards(ctx context.Context, query string, keyspac
|
|||
return sqltypes.Proto3ToResult(response.Result), response.Session, nil
|
||||
}
|
||||
|
||||
func (conn *vtgateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *vtgateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
var s *vtgatepb.Session
|
||||
if session != nil {
|
||||
s = session.(*vtgatepb.Session)
|
||||
|
@ -109,13 +107,12 @@ func (conn *vtgateConn) ExecuteKeyspaceIds(ctx context.Context, query string, ke
|
|||
return nil, session, err
|
||||
}
|
||||
request := &vtgatepb.ExecuteKeyspaceIdsRequest{
|
||||
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
|
||||
Session: s,
|
||||
Query: q,
|
||||
Keyspace: keyspace,
|
||||
KeyspaceIds: keyspaceIds,
|
||||
TabletType: tabletType,
|
||||
NotInTransaction: notInTransaction,
|
||||
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
|
||||
Session: s,
|
||||
Query: q,
|
||||
Keyspace: keyspace,
|
||||
KeyspaceIds: keyspaceIds,
|
||||
TabletType: tabletType,
|
||||
}
|
||||
response, err := conn.c.ExecuteKeyspaceIds(ctx, request)
|
||||
if err != nil {
|
||||
|
@ -127,7 +124,7 @@ func (conn *vtgateConn) ExecuteKeyspaceIds(ctx context.Context, query string, ke
|
|||
return sqltypes.Proto3ToResult(response.Result), response.Session, nil
|
||||
}
|
||||
|
||||
func (conn *vtgateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *vtgateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
var s *vtgatepb.Session
|
||||
if session != nil {
|
||||
s = session.(*vtgatepb.Session)
|
||||
|
@ -137,13 +134,12 @@ func (conn *vtgateConn) ExecuteKeyRanges(ctx context.Context, query string, keys
|
|||
return nil, session, err
|
||||
}
|
||||
request := &vtgatepb.ExecuteKeyRangesRequest{
|
||||
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
|
||||
Session: s,
|
||||
Query: q,
|
||||
Keyspace: keyspace,
|
||||
KeyRanges: keyRanges,
|
||||
TabletType: tabletType,
|
||||
NotInTransaction: notInTransaction,
|
||||
CallerId: callerid.EffectiveCallerIDFromContext(ctx),
|
||||
Session: s,
|
||||
Query: q,
|
||||
Keyspace: keyspace,
|
||||
KeyRanges: keyRanges,
|
||||
TabletType: tabletType,
|
||||
}
|
||||
response, err := conn.c.ExecuteKeyRanges(ctx, request)
|
||||
if err != nil {
|
||||
|
@ -155,7 +151,7 @@ func (conn *vtgateConn) ExecuteKeyRanges(ctx context.Context, query string, keys
|
|||
return sqltypes.Proto3ToResult(response.Result), response.Session, nil
|
||||
}
|
||||
|
||||
func (conn *vtgateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
func (conn *vtgateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error) {
|
||||
var s *vtgatepb.Session
|
||||
if session != nil {
|
||||
s = session.(*vtgatepb.Session)
|
||||
|
@ -172,7 +168,6 @@ func (conn *vtgateConn) ExecuteEntityIds(ctx context.Context, query string, keys
|
|||
EntityColumnName: entityColumnName,
|
||||
EntityKeyspaceIds: entityKeyspaceIDs,
|
||||
TabletType: tabletType,
|
||||
NotInTransaction: notInTransaction,
|
||||
}
|
||||
response, err := conn.c.ExecuteEntityIds(ctx, request)
|
||||
if err != nil {
|
||||
|
|
|
@ -37,31 +37,31 @@ type VTGateConn struct {
|
|||
// Execute executes a non-streaming query on vtgate.
|
||||
// This is using v3 API.
|
||||
func (conn *VTGateConn) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error) {
|
||||
res, _, err := conn.impl.Execute(ctx, query, bindVars, tabletType, false, nil)
|
||||
res, _, err := conn.impl.Execute(ctx, query, bindVars, tabletType, nil)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// ExecuteShards executes a non-streaming query for multiple shards on vtgate.
|
||||
func (conn *VTGateConn) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error) {
|
||||
res, _, err := conn.impl.ExecuteShards(ctx, query, keyspace, shards, bindVars, tabletType, false, nil)
|
||||
res, _, err := conn.impl.ExecuteShards(ctx, query, keyspace, shards, bindVars, tabletType, nil)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// ExecuteKeyspaceIds executes a non-streaming query for multiple keyspace_ids.
|
||||
func (conn *VTGateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error) {
|
||||
res, _, err := conn.impl.ExecuteKeyspaceIds(ctx, query, keyspace, keyspaceIds, bindVars, tabletType, false, nil)
|
||||
res, _, err := conn.impl.ExecuteKeyspaceIds(ctx, query, keyspace, keyspaceIds, bindVars, tabletType, nil)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// ExecuteKeyRanges executes a non-streaming query on a key range.
|
||||
func (conn *VTGateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error) {
|
||||
res, _, err := conn.impl.ExecuteKeyRanges(ctx, query, keyspace, keyRanges, bindVars, tabletType, false, nil)
|
||||
res, _, err := conn.impl.ExecuteKeyRanges(ctx, query, keyspace, keyRanges, bindVars, tabletType, nil)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// ExecuteEntityIds executes a non-streaming query for multiple entities.
|
||||
func (conn *VTGateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error) {
|
||||
res, _, err := conn.impl.ExecuteEntityIds(ctx, query, keyspace, entityColumnName, entityKeyspaceIDs, bindVars, tabletType, false, nil)
|
||||
res, _, err := conn.impl.ExecuteEntityIds(ctx, query, keyspace, entityColumnName, entityKeyspaceIDs, bindVars, tabletType, nil)
|
||||
return res, err
|
||||
}
|
||||
|
||||
|
@ -200,51 +200,51 @@ type VTGateTx struct {
|
|||
}
|
||||
|
||||
// Execute executes a query on vtgate within the current transaction.
|
||||
func (tx *VTGateTx) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool) (*sqltypes.Result, error) {
|
||||
func (tx *VTGateTx) Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error) {
|
||||
if tx.session == nil {
|
||||
return nil, fmt.Errorf("execute: not in transaction")
|
||||
}
|
||||
res, session, err := tx.impl.Execute(ctx, query, bindVars, tabletType, notInTransaction, tx.session)
|
||||
res, session, err := tx.impl.Execute(ctx, query, bindVars, tabletType, tx.session)
|
||||
tx.session = session
|
||||
return res, err
|
||||
}
|
||||
|
||||
// ExecuteShards executes a query for multiple shards on vtgate within the current transaction.
|
||||
func (tx *VTGateTx) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool) (*sqltypes.Result, error) {
|
||||
func (tx *VTGateTx) ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error) {
|
||||
if tx.session == nil {
|
||||
return nil, fmt.Errorf("executeShards: not in transaction")
|
||||
}
|
||||
res, session, err := tx.impl.ExecuteShards(ctx, query, keyspace, shards, bindVars, tabletType, notInTransaction, tx.session)
|
||||
res, session, err := tx.impl.ExecuteShards(ctx, query, keyspace, shards, bindVars, tabletType, tx.session)
|
||||
tx.session = session
|
||||
return res, err
|
||||
}
|
||||
|
||||
// ExecuteKeyspaceIds executes a non-streaming query for multiple keyspace_ids.
|
||||
func (tx *VTGateTx) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool) (*sqltypes.Result, error) {
|
||||
func (tx *VTGateTx) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error) {
|
||||
if tx.session == nil {
|
||||
return nil, fmt.Errorf("executeKeyspaceIds: not in transaction")
|
||||
}
|
||||
res, session, err := tx.impl.ExecuteKeyspaceIds(ctx, query, keyspace, keyspaceIds, bindVars, tabletType, notInTransaction, tx.session)
|
||||
res, session, err := tx.impl.ExecuteKeyspaceIds(ctx, query, keyspace, keyspaceIds, bindVars, tabletType, tx.session)
|
||||
tx.session = session
|
||||
return res, err
|
||||
}
|
||||
|
||||
// ExecuteKeyRanges executes a non-streaming query on a key range.
|
||||
func (tx *VTGateTx) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool) (*sqltypes.Result, error) {
|
||||
func (tx *VTGateTx) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error) {
|
||||
if tx.session == nil {
|
||||
return nil, fmt.Errorf("executeKeyRanges: not in transaction")
|
||||
}
|
||||
res, session, err := tx.impl.ExecuteKeyRanges(ctx, query, keyspace, keyRanges, bindVars, tabletType, notInTransaction, tx.session)
|
||||
res, session, err := tx.impl.ExecuteKeyRanges(ctx, query, keyspace, keyRanges, bindVars, tabletType, tx.session)
|
||||
tx.session = session
|
||||
return res, err
|
||||
}
|
||||
|
||||
// ExecuteEntityIds executes a non-streaming query for multiple entities.
|
||||
func (tx *VTGateTx) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool) (*sqltypes.Result, error) {
|
||||
func (tx *VTGateTx) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType) (*sqltypes.Result, error) {
|
||||
if tx.session == nil {
|
||||
return nil, fmt.Errorf("executeEntityIds: not in transaction")
|
||||
}
|
||||
res, session, err := tx.impl.ExecuteEntityIds(ctx, query, keyspace, entityColumnName, entityKeyspaceIDs, bindVars, tabletType, notInTransaction, tx.session)
|
||||
res, session, err := tx.impl.ExecuteEntityIds(ctx, query, keyspace, entityColumnName, entityKeyspaceIDs, bindVars, tabletType, tx.session)
|
||||
tx.session = session
|
||||
return res, err
|
||||
}
|
||||
|
@ -320,19 +320,19 @@ type ErrFunc func() error
|
|||
// implementation. It can be used concurrently across goroutines.
|
||||
type Impl interface {
|
||||
// Execute executes a non-streaming query on vtgate.
|
||||
Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error)
|
||||
Execute(ctx context.Context, query string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error)
|
||||
|
||||
// ExecuteShards executes a non-streaming query for multiple shards on vtgate.
|
||||
ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error)
|
||||
ExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error)
|
||||
|
||||
// ExecuteKeyspaceIds executes a non-streaming query for multiple keyspace_ids.
|
||||
ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error)
|
||||
ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error)
|
||||
|
||||
// ExecuteKeyRanges executes a non-streaming query on a key range.
|
||||
ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error)
|
||||
ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error)
|
||||
|
||||
// ExecuteEntityIds executes a non-streaming query for multiple entities.
|
||||
ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, notInTransaction bool, session interface{}) (*sqltypes.Result, interface{}, error)
|
||||
ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]interface{}, tabletType topodatapb.TabletType, session interface{}) (*sqltypes.Result, interface{}, error)
|
||||
|
||||
// ExecuteBatchShards executes a set of non-streaming queries for multiple shards.
|
||||
ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, tabletType topodatapb.TabletType, asTransaction bool, session interface{}) ([]sqltypes.Result, interface{}, error)
|
||||
|
|
|
@ -1482,7 +1482,7 @@ func testTxPass(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables, execCase.execQuery.TabletType, false)
|
||||
_, err = tx.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables, execCase.execQuery.TabletType)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -1496,7 +1496,7 @@ func testTxPass(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteShards(ctx, execCase.shardQuery.SQL, execCase.shardQuery.Keyspace, execCase.shardQuery.Shards, execCase.shardQuery.BindVariables, execCase.shardQuery.TabletType, false)
|
||||
_, err = tx.ExecuteShards(ctx, execCase.shardQuery.SQL, execCase.shardQuery.Keyspace, execCase.shardQuery.Shards, execCase.shardQuery.BindVariables, execCase.shardQuery.TabletType)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -1510,7 +1510,7 @@ func testTxPass(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteKeyspaceIds(ctx, execCase.keyspaceIDQuery.SQL, execCase.keyspaceIDQuery.Keyspace, execCase.keyspaceIDQuery.KeyspaceIds, execCase.keyspaceIDQuery.BindVariables, execCase.keyspaceIDQuery.TabletType, false)
|
||||
_, err = tx.ExecuteKeyspaceIds(ctx, execCase.keyspaceIDQuery.SQL, execCase.keyspaceIDQuery.Keyspace, execCase.keyspaceIDQuery.KeyspaceIds, execCase.keyspaceIDQuery.BindVariables, execCase.keyspaceIDQuery.TabletType)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -1524,7 +1524,7 @@ func testTxPass(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteKeyRanges(ctx, execCase.keyRangeQuery.SQL, execCase.keyRangeQuery.Keyspace, execCase.keyRangeQuery.KeyRanges, execCase.keyRangeQuery.BindVariables, execCase.keyRangeQuery.TabletType, false)
|
||||
_, err = tx.ExecuteKeyRanges(ctx, execCase.keyRangeQuery.SQL, execCase.keyRangeQuery.Keyspace, execCase.keyRangeQuery.KeyRanges, execCase.keyRangeQuery.BindVariables, execCase.keyRangeQuery.TabletType)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -1538,7 +1538,7 @@ func testTxPass(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteEntityIds(ctx, execCase.entityIdsQuery.SQL, execCase.entityIdsQuery.Keyspace, execCase.entityIdsQuery.EntityColumnName, execCase.entityIdsQuery.EntityKeyspaceIDs, execCase.entityIdsQuery.BindVariables, execCase.entityIdsQuery.TabletType, false)
|
||||
_, err = tx.ExecuteEntityIds(ctx, execCase.entityIdsQuery.SQL, execCase.entityIdsQuery.Keyspace, execCase.entityIdsQuery.EntityColumnName, execCase.entityIdsQuery.EntityKeyspaceIDs, execCase.entityIdsQuery.BindVariables, execCase.entityIdsQuery.TabletType)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -1584,26 +1584,6 @@ func testTxPassNotInTransaction(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables, execCase.execQuery.TabletType, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteShards(ctx, execCase.shardQuery.SQL, execCase.shardQuery.Keyspace, execCase.shardQuery.Shards, execCase.shardQuery.BindVariables, execCase.shardQuery.TabletType, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteKeyspaceIds(ctx, execCase.keyspaceIDQuery.SQL, execCase.keyspaceIDQuery.Keyspace, execCase.keyspaceIDQuery.KeyspaceIds, execCase.keyspaceIDQuery.BindVariables, execCase.keyspaceIDQuery.TabletType, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteKeyRanges(ctx, execCase.keyRangeQuery.SQL, execCase.keyRangeQuery.Keyspace, execCase.keyRangeQuery.KeyRanges, execCase.keyRangeQuery.BindVariables, execCase.keyRangeQuery.TabletType, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteEntityIds(ctx, execCase.entityIdsQuery.SQL, execCase.entityIdsQuery.Keyspace, execCase.entityIdsQuery.EntityColumnName, execCase.entityIdsQuery.EntityKeyspaceIDs, execCase.entityIdsQuery.BindVariables, execCase.entityIdsQuery.TabletType, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteBatchShards(ctx, execCase.batchQueryShard.Queries, execCase.batchQueryShard.TabletType, execCase.batchQueryShard.AsTransaction)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -1625,7 +1605,7 @@ func testTx2Pass(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables, execCase.execQuery.TabletType, false)
|
||||
_, err = tx.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables, execCase.execQuery.TabletType)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -1639,7 +1619,7 @@ func testTx2Pass(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteShards(ctx, execCase.shardQuery.SQL, execCase.shardQuery.Keyspace, execCase.shardQuery.Shards, execCase.shardQuery.BindVariables, execCase.shardQuery.TabletType, false)
|
||||
_, err = tx.ExecuteShards(ctx, execCase.shardQuery.SQL, execCase.shardQuery.Keyspace, execCase.shardQuery.Shards, execCase.shardQuery.BindVariables, execCase.shardQuery.TabletType)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -1653,7 +1633,7 @@ func testTx2Pass(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteKeyspaceIds(ctx, execCase.keyspaceIDQuery.SQL, execCase.keyspaceIDQuery.Keyspace, execCase.keyspaceIDQuery.KeyspaceIds, execCase.keyspaceIDQuery.BindVariables, execCase.keyspaceIDQuery.TabletType, false)
|
||||
_, err = tx.ExecuteKeyspaceIds(ctx, execCase.keyspaceIDQuery.SQL, execCase.keyspaceIDQuery.Keyspace, execCase.keyspaceIDQuery.KeyspaceIds, execCase.keyspaceIDQuery.BindVariables, execCase.keyspaceIDQuery.TabletType)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -1667,7 +1647,7 @@ func testTx2Pass(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteKeyRanges(ctx, execCase.keyRangeQuery.SQL, execCase.keyRangeQuery.Keyspace, execCase.keyRangeQuery.KeyRanges, execCase.keyRangeQuery.BindVariables, execCase.keyRangeQuery.TabletType, false)
|
||||
_, err = tx.ExecuteKeyRanges(ctx, execCase.keyRangeQuery.SQL, execCase.keyRangeQuery.Keyspace, execCase.keyRangeQuery.KeyRanges, execCase.keyRangeQuery.BindVariables, execCase.keyRangeQuery.TabletType)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -1681,7 +1661,7 @@ func testTx2Pass(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteEntityIds(ctx, execCase.entityIdsQuery.SQL, execCase.entityIdsQuery.Keyspace, execCase.entityIdsQuery.EntityColumnName, execCase.entityIdsQuery.EntityKeyspaceIDs, execCase.entityIdsQuery.BindVariables, execCase.entityIdsQuery.TabletType, false)
|
||||
_, err = tx.ExecuteEntityIds(ctx, execCase.entityIdsQuery.SQL, execCase.entityIdsQuery.Keyspace, execCase.entityIdsQuery.EntityColumnName, execCase.entityIdsQuery.EntityKeyspaceIDs, execCase.entityIdsQuery.BindVariables, execCase.entityIdsQuery.TabletType)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -1728,26 +1708,6 @@ func testTx2PassNotInTransaction(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.Execute(ctx, execCase.execQuery.SQL, execCase.execQuery.BindVariables, execCase.execQuery.TabletType, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteShards(ctx, execCase.shardQuery.SQL, execCase.shardQuery.Keyspace, execCase.shardQuery.Shards, execCase.shardQuery.BindVariables, execCase.shardQuery.TabletType, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteKeyspaceIds(ctx, execCase.keyspaceIDQuery.SQL, execCase.keyspaceIDQuery.Keyspace, execCase.keyspaceIDQuery.KeyspaceIds, execCase.keyspaceIDQuery.BindVariables, execCase.keyspaceIDQuery.TabletType, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteKeyRanges(ctx, execCase.keyRangeQuery.SQL, execCase.keyRangeQuery.Keyspace, execCase.keyRangeQuery.KeyRanges, execCase.keyRangeQuery.BindVariables, execCase.keyRangeQuery.TabletType, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteEntityIds(ctx, execCase.entityIdsQuery.SQL, execCase.entityIdsQuery.Keyspace, execCase.entityIdsQuery.EntityColumnName, execCase.entityIdsQuery.EntityKeyspaceIDs, execCase.entityIdsQuery.BindVariables, execCase.entityIdsQuery.TabletType, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = tx.ExecuteBatchShards(ctx, execCase.batchQueryShard.Queries, execCase.batchQueryShard.TabletType, execCase.batchQueryShard.AsTransaction)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -1907,31 +1867,31 @@ func testTxFail(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
t.Errorf("Commit: %v, want %v", err, want)
|
||||
}
|
||||
|
||||
_, err = tx.Execute(ctx, "", nil, topodatapb.TabletType_REPLICA, false)
|
||||
_, err = tx.Execute(ctx, "", nil, topodatapb.TabletType_REPLICA)
|
||||
want = "execute: not in transaction"
|
||||
if err == nil || err.Error() != want {
|
||||
t.Errorf("Execute: %v, want %v", err, want)
|
||||
}
|
||||
|
||||
_, err = tx.ExecuteShards(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA, false)
|
||||
_, err = tx.ExecuteShards(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA)
|
||||
want = "executeShards: not in transaction"
|
||||
if err == nil || err.Error() != want {
|
||||
t.Errorf("ExecuteShards: %v, want %v", err, want)
|
||||
}
|
||||
|
||||
_, err = tx.ExecuteKeyspaceIds(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA, false)
|
||||
_, err = tx.ExecuteKeyspaceIds(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA)
|
||||
want = "executeKeyspaceIds: not in transaction"
|
||||
if err == nil || err.Error() != want {
|
||||
t.Errorf("ExecuteShards: %v, want %v", err, want)
|
||||
}
|
||||
|
||||
_, err = tx.ExecuteKeyRanges(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA, false)
|
||||
_, err = tx.ExecuteKeyRanges(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA)
|
||||
want = "executeKeyRanges: not in transaction"
|
||||
if err == nil || err.Error() != want {
|
||||
t.Errorf("ExecuteShards: %v, want %v", err, want)
|
||||
}
|
||||
|
||||
_, err = tx.ExecuteEntityIds(ctx, "", "", "", nil, nil, topodatapb.TabletType_REPLICA, false)
|
||||
_, err = tx.ExecuteEntityIds(ctx, "", "", "", nil, nil, topodatapb.TabletType_REPLICA)
|
||||
want = "executeEntityIds: not in transaction"
|
||||
if err == nil || err.Error() != want {
|
||||
t.Errorf("ExecuteShards: %v, want %v", err, want)
|
||||
|
@ -1984,31 +1944,31 @@ func testTx2Fail(t *testing.T, conn *vtgateconn.VTGateConn) {
|
|||
t.Errorf("Commit2: %v, want %v", err, want)
|
||||
}
|
||||
|
||||
_, err = tx.Execute(ctx, "", nil, topodatapb.TabletType_REPLICA, false)
|
||||
_, err = tx.Execute(ctx, "", nil, topodatapb.TabletType_REPLICA)
|
||||
want = "execute: not in transaction"
|
||||
if err == nil || err.Error() != want {
|
||||
t.Errorf("Execute: %v, want %v", err, want)
|
||||
}
|
||||
|
||||
_, err = tx.ExecuteShards(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA, false)
|
||||
_, err = tx.ExecuteShards(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA)
|
||||
want = "executeShards: not in transaction"
|
||||
if err == nil || err.Error() != want {
|
||||
t.Errorf("ExecuteShards: %v, want %v", err, want)
|
||||
}
|
||||
|
||||
_, err = tx.ExecuteKeyspaceIds(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA, false)
|
||||
_, err = tx.ExecuteKeyspaceIds(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA)
|
||||
want = "executeKeyspaceIds: not in transaction"
|
||||
if err == nil || err.Error() != want {
|
||||
t.Errorf("ExecuteShards: %v, want %v", err, want)
|
||||
}
|
||||
|
||||
_, err = tx.ExecuteKeyRanges(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA, false)
|
||||
_, err = tx.ExecuteKeyRanges(ctx, "", "", nil, nil, topodatapb.TabletType_REPLICA)
|
||||
want = "executeKeyRanges: not in transaction"
|
||||
if err == nil || err.Error() != want {
|
||||
t.Errorf("ExecuteShards: %v, want %v", err, want)
|
||||
}
|
||||
|
||||
_, err = tx.ExecuteEntityIds(ctx, "", "", "", nil, nil, topodatapb.TabletType_REPLICA, false)
|
||||
_, err = tx.ExecuteEntityIds(ctx, "", "", "", nil, nil, topodatapb.TabletType_REPLICA)
|
||||
want = "executeEntityIds: not in transaction"
|
||||
if err == nil || err.Error() != want {
|
||||
t.Errorf("ExecuteShards: %v, want %v", err, want)
|
||||
|
@ -2443,73 +2403,6 @@ var execMap = map[string]struct {
|
|||
outSession: session2,
|
||||
},
|
||||
"txRequestNIT": {
|
||||
execQuery: &queryExecute{
|
||||
SQL: "txRequestNIT",
|
||||
BindVariables: map[string]interface{}{
|
||||
"bind1": int64(0),
|
||||
},
|
||||
TabletType: topodatapb.TabletType_MASTER,
|
||||
Session: session1,
|
||||
NotInTransaction: true,
|
||||
},
|
||||
shardQuery: &queryExecuteShards{
|
||||
SQL: "txRequestNIT",
|
||||
BindVariables: map[string]interface{}{
|
||||
"bind1": int64(0),
|
||||
},
|
||||
TabletType: topodatapb.TabletType_MASTER,
|
||||
Keyspace: "",
|
||||
Shards: []string{"s1", "s2"},
|
||||
Session: session1,
|
||||
NotInTransaction: true,
|
||||
},
|
||||
keyspaceIDQuery: &queryExecuteKeyspaceIds{
|
||||
SQL: "txRequestNIT",
|
||||
BindVariables: map[string]interface{}{
|
||||
"bind1": int64(0),
|
||||
},
|
||||
Keyspace: "ks",
|
||||
KeyspaceIds: [][]byte{
|
||||
{0x61},
|
||||
},
|
||||
TabletType: topodatapb.TabletType_RDONLY,
|
||||
Session: session1,
|
||||
NotInTransaction: true,
|
||||
},
|
||||
keyRangeQuery: &queryExecuteKeyRanges{
|
||||
SQL: "txRequestNIT",
|
||||
BindVariables: map[string]interface{}{
|
||||
"bind1": int64(0),
|
||||
},
|
||||
Keyspace: "ks",
|
||||
KeyRanges: []*topodatapb.KeyRange{
|
||||
{
|
||||
Start: []byte{0x34},
|
||||
End: []byte{0x77},
|
||||
},
|
||||
},
|
||||
TabletType: topodatapb.TabletType_RDONLY,
|
||||
Session: session1,
|
||||
NotInTransaction: true,
|
||||
},
|
||||
entityIdsQuery: &queryExecuteEntityIds{
|
||||
SQL: "txRequestNIT",
|
||||
BindVariables: map[string]interface{}{
|
||||
"bind1": int64(0),
|
||||
},
|
||||
Keyspace: "ks",
|
||||
EntityColumnName: "column",
|
||||
EntityKeyspaceIDs: []*vtgatepb.ExecuteEntityIdsRequest_EntityId{
|
||||
{
|
||||
Type: sqltypes.Int64,
|
||||
Value: []byte("123456"),
|
||||
KeyspaceId: []byte{0x6B},
|
||||
},
|
||||
},
|
||||
TabletType: topodatapb.TabletType_RDONLY,
|
||||
Session: session1,
|
||||
NotInTransaction: true,
|
||||
},
|
||||
batchQueryShard: &queryExecuteBatchShards{
|
||||
Queries: []*vtgatepb.BoundShardQuery{
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче