本文整理汇总了Golang中github.com/youtube/vitess/go/mysql/proto.QueryResult类的典型用法代码示例。如果您正苦于以下问题:Golang QueryResult类的具体用法?Golang QueryResult怎么用?Golang QueryResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QueryResult类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: UnmarshalBson
// UnmarshalBson bson-decodes into QueryResultList.
func (queryResultList *QueryResultList) UnmarshalBson(buf *bytes.Buffer, kind byte) {
switch kind {
case bson.EOO, bson.Object:
// valid
case bson.Null:
return
default:
panic(bson.NewBsonError("unexpected kind %v for QueryResultList", kind))
}
bson.Next(buf, 4)
for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
switch bson.ReadCString(buf) {
case "List":
// []mproto.QueryResult
if kind != bson.Null {
if kind != bson.Array {
panic(bson.NewBsonError("unexpected kind %v for queryResultList.List", kind))
}
bson.Next(buf, 4)
queryResultList.List = make([]mproto.QueryResult, 0, 8)
for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
bson.SkipIndex(buf)
var _v1 mproto.QueryResult
_v1.UnmarshalBson(buf, kind)
queryResultList.List = append(queryResultList.List, _v1)
}
}
default:
bson.Skip(buf, kind)
}
}
}
开发者ID:chinna1986,项目名称:vitess,代码行数:34,代码来源:query_result_list_bson.go
示例2: appendResult
func appendResult(qr, innerqr *mproto.QueryResult) {
if qr.Fields == nil {
qr.Fields = innerqr.Fields
}
qr.RowsAffected += innerqr.RowsAffected
if innerqr.InsertId != 0 {
qr.InsertId = innerqr.InsertId
}
qr.Rows = append(qr.Rows, innerqr.Rows...)
}
开发者ID:rjammala,项目名称:vitess,代码行数:10,代码来源:scatter_conn.go
示例3: testStreamExecuteKeyspaceIds
func testStreamExecuteKeyspaceIds(t *testing.T, conn *vtgateconn.VTGateConn) {
ctx := context.Background()
execCase := execMap["request1"]
packets, errFunc := conn.StreamExecuteKeyspaceIds(ctx, execCase.keyspaceIdQuery.Sql, execCase.keyspaceIdQuery.Keyspace, execCase.keyspaceIdQuery.KeyspaceIds, execCase.keyspaceIdQuery.BindVariables, execCase.keyspaceIdQuery.TabletType)
var qr mproto.QueryResult
for packet := range packets {
if len(packet.Fields) != 0 {
qr.Fields = packet.Fields
}
if len(packet.Rows) != 0 {
qr.Rows = append(qr.Rows, packet.Rows...)
}
}
wantResult := *execCase.reply.Result
wantResult.RowsAffected = 0
wantResult.InsertId = 0
if !reflect.DeepEqual(qr, wantResult) {
t.Errorf("Unexpected result from Execute: got %+v want %+v", qr, wantResult)
}
err := errFunc()
if err != nil {
t.Error(err)
}
packets, errFunc = conn.StreamExecuteKeyspaceIds(ctx, "none", "", []key.KeyspaceId{}, nil, "")
for packet := range packets {
t.Errorf("packet: %+v, want none", packet)
}
err = errFunc()
want := "no match for: none"
if err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("none request: %v, want %v", err, want)
}
execCase = execMap["errorRequst"]
packets, errFunc = conn.StreamExecuteKeyspaceIds(ctx, execCase.keyspaceIdQuery.Sql, execCase.keyspaceIdQuery.Keyspace, execCase.keyspaceIdQuery.KeyspaceIds, execCase.keyspaceIdQuery.BindVariables, execCase.keyspaceIdQuery.TabletType)
for packet := range packets {
t.Errorf("packet: %+v, want none", packet)
}
err = errFunc()
want = "app error"
if err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("errorRequst: %v, want %v", err, want)
}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:45,代码来源:client.go
示例4: DecodeResultsBson
func DecodeResultsBson(buf *bytes.Buffer, kind byte) (results []mproto.QueryResult) {
switch kind {
case bson.Array:
// valid
case bson.Null:
return nil
default:
panic(bson.NewBsonError("Unexpected data type %v for Queries", kind))
}
bson.Next(buf, 4)
results = make([]mproto.QueryResult, 0, 8)
kind = bson.NextByte(buf)
var result mproto.QueryResult
for i := 0; kind != bson.EOO; i++ {
bson.ExpectIndex(buf, i)
result.UnmarshalBson(buf)
results = append(results, result)
kind = bson.NextByte(buf)
}
return results
}
开发者ID:rjammala,项目名称:vitess,代码行数:22,代码来源:bson.go
示例5: AddTabletErrorToQueryResult
// AddTabletErrorToQueryResult will mutate a QueryResult struct to fill in the Err
// field with details from the TabletError.
func AddTabletErrorToQueryResult(err error, reply *mproto.QueryResult) {
if err == nil {
return
}
reply.Err = rpcErrFromTabletError(err)
}
开发者ID:fengshao0907,项目名称:vitess,代码行数:8,代码来源:tablet_error.go
注:本文中的github.com/youtube/vitess/go/mysql/proto.QueryResult类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论