本文整理汇总了Golang中github.com/youtube/vitess/go/sqltypes.MakeString函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeString函数的具体用法?Golang MakeString怎么用?Golang MakeString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: checkBlpPositionList
// checkBlpPositionList will ask the BinlogPlayerMap for its BlpPositionList,
// and check it contains one entry with the right data.
func checkBlpPositionList(t *testing.T, bpm *BinlogPlayerMap, vtClientSyncChannel chan *binlogplayer.VtClientMock) {
// ask for BlpPositionList, make sure we got what we expect
go func() {
vtcm := binlogplayer.NewVtClientMock()
vtcm.Result = &sqltypes.Result{
Fields: nil,
RowsAffected: 1,
InsertID: 0,
Rows: [][]sqltypes.Value{
{
sqltypes.MakeString([]byte("MariaDB/0-1-1235")),
sqltypes.MakeString([]byte("")),
},
},
}
vtClientSyncChannel <- vtcm
}()
bpl, err := bpm.BlpPositionList()
if err != nil {
t.Errorf("BlpPositionList failed: %v", err)
return
}
if len(bpl) != 1 ||
bpl[0].Uid != 1 ||
bpl[0].Position != "MariaDB/0-1-1235" {
t.Errorf("unexpected BlpPositionList: %v", bpl)
}
}
开发者ID:littleyang,项目名称:vitess,代码行数:30,代码来源:binlog_test.go
示例2: addGeneratedRows
// addGeneratedRows will add from-to generated rows. The rows (their primary
// key) will be in the range [from, to).
func (sq *testQueryService) addGeneratedRows(from, to int) {
var rows [][]sqltypes.Value
// ksids has keyspace ids which are covered by the shard key ranges -40 and 40-80.
ksids := []uint64{0x2000000000000000, 0x6000000000000000}
for id := from; id < to; id++ {
// Only return the rows which are covered by this shard.
shardIndex := id % 2
if sq.shardCount == 1 || shardIndex == sq.shardIndex {
idValue, _ := sqltypes.BuildValue(int64(id))
row := []sqltypes.Value{
idValue,
sqltypes.MakeString([]byte(fmt.Sprintf("Text for %v", id))),
}
if !sq.omitKeyspaceID {
row = append(row, sqltypes.MakeString([]byte(fmt.Sprintf("%v", ksids[shardIndex]))))
}
rows = append(rows, row)
}
}
if sq.rows == nil {
sq.rows = rows
} else {
sq.rows = append(sq.rows, rows...)
}
}
开发者ID:dumbunny,项目名称:vitess,代码行数:30,代码来源:split_clone_test.go
示例3: echoQueryResult
func echoQueryResult(vals map[string]interface{}) *sqltypes.Result {
qr := &sqltypes.Result{}
var row []sqltypes.Value
// The first two returned fields are always a field with a MySQL NULL value,
// and another field with a zero-length string.
// Client tests can use this to check that they correctly distinguish the two.
qr.Fields = append(qr.Fields, &querypb.Field{Name: "null", Type: sqltypes.VarBinary})
row = append(row, sqltypes.NULL)
qr.Fields = append(qr.Fields, &querypb.Field{Name: "emptyString", Type: sqltypes.VarBinary})
row = append(row, sqltypes.MakeString([]byte("")))
for k, v := range vals {
qr.Fields = append(qr.Fields, &querypb.Field{Name: k, Type: sqltypes.VarBinary})
val := reflect.ValueOf(v)
if val.Kind() == reflect.Map {
row = append(row, sqltypes.MakeString(printSortedMap(val)))
continue
}
row = append(row, sqltypes.MakeString([]byte(fmt.Sprintf("%v", v))))
}
qr.Rows = [][]sqltypes.Value{row}
return qr
}
开发者ID:littleyang,项目名称:vitess,代码行数:27,代码来源:echo.go
示例4: StreamExecute
func (sq *sqlDifferTabletServer) StreamExecute(ctx context.Context, target *pb.Target, query *proto.Query, sendReply func(reply *mproto.QueryResult) error) error {
sq.t.Logf("SqlDifferTabletServer: got query: %v", *query)
// Send the headers
if err := sendReply(&mproto.QueryResult{
Fields: []mproto.Field{
mproto.Field{
Name: "id",
Type: mproto.VT_LONGLONG,
},
mproto.Field{
Name: "msg",
Type: mproto.VT_VARCHAR,
},
},
}); err != nil {
return err
}
// Send the values
for i := 0; i < 1000; i++ {
if err := sendReply(&mproto.QueryResult{
Rows: [][]sqltypes.Value{
[]sqltypes.Value{
sqltypes.MakeString([]byte(fmt.Sprintf("%v", i))),
sqltypes.MakeString([]byte(fmt.Sprintf("Text for %v", i))),
},
},
}); err != nil {
return err
}
}
return nil
}
开发者ID:richarwu,项目名称:vitess,代码行数:34,代码来源:sqldiffer_test.go
示例5: TestRowsToProto3
func TestRowsToProto3(t *testing.T) {
rows := [][]sqltypes.Value{{
sqltypes.MakeString([]byte("aa")),
sqltypes.NULL,
sqltypes.MakeString([]byte("12")),
}, {
sqltypes.MakeString([]byte("bb")),
sqltypes.NULL,
sqltypes.NULL,
}}
p3 := RowsToProto3(rows)
want := []*query.Row{
&query.Row{
Lengths: []int64{2, -1, 2},
Values: []byte("aa12"),
},
&query.Row{
Lengths: []int64{2, -1, -1},
Values: []byte("bb"),
},
}
if !reflect.DeepEqual(p3, want) {
t.Errorf("P3: %v, want %v", p3, want)
}
reverse := Proto3ToRows(p3)
if !reflect.DeepEqual(reverse, rows) {
t.Errorf("reverse: \n%#v, want \n%#v", reverse, rows)
}
}
开发者ID:c3p0hz,项目名称:vitess,代码行数:30,代码来源:proto3_test.go
示例6: sourceRdonlyFactory
// sourceRdonlyFactory fakes out the MIN, MAX query on the primary key.
// (This query is used to calculate the split points for reading a table
// using multiple threads.)
func sourceRdonlyFactory(t *testing.T, dbAndTableName string, min, max int) func() (dbconnpool.PoolConnection, error) {
f := NewFakePoolConnectionQuery(t, "sourceRdonly")
f.addExpectedExecuteFetch(ExpectedExecuteFetch{
Query: fmt.Sprintf("SELECT MIN(id), MAX(id) FROM %s", dbAndTableName),
QueryResult: &sqltypes.Result{
Fields: []*querypb.Field{
{
Name: "min",
Type: sqltypes.Int64,
},
{
Name: "max",
Type: sqltypes.Int64,
},
},
Rows: [][]sqltypes.Value{
{
sqltypes.MakeString([]byte(strconv.Itoa(min))),
sqltypes.MakeString([]byte(strconv.Itoa(max))),
},
},
},
})
f.enableInfinite()
return f.getFactory()
}
开发者ID:jmptrader,项目名称:vitess,代码行数:29,代码来源:utils_test.go
示例7: checkBlpPositionList
// checkBlpPositionList will ask the BinlogPlayerMap for its BlpPositionList,
// and check it contains one entry with the right data.
func checkBlpPositionList(t *testing.T, bpm *BinlogPlayerMap, vtClientSyncChannel chan *binlogplayer.VtClientMock) {
// ask for BlpPositionList, make sure we got what we expect
go func() {
vtcm := binlogplayer.NewVtClientMock()
vtcm.Result = &mproto.QueryResult{
Fields: nil,
RowsAffected: 1,
InsertId: 0,
Rows: [][]sqltypes.Value{
[]sqltypes.Value{
sqltypes.MakeString([]byte("MariaDB/0-1-1235")),
sqltypes.MakeString([]byte("")),
},
},
}
vtClientSyncChannel <- vtcm
}()
bpl, err := bpm.BlpPositionList()
if err != nil {
t.Errorf("BlpPositionList failed: %v", err)
return
}
if len(bpl.Entries) != 1 ||
bpl.Entries[0].Uid != 1 ||
bpl.Entries[0].Position.GTIDSet.(myproto.MariadbGTID).Domain != 0 ||
bpl.Entries[0].Position.GTIDSet.(myproto.MariadbGTID).Server != 1 ||
bpl.Entries[0].Position.GTIDSet.(myproto.MariadbGTID).Sequence != 1235 {
t.Errorf("unexpected BlpPositionList: %v", bpl)
}
}
开发者ID:khanchan,项目名称:vitess,代码行数:32,代码来源:binlog_test.go
示例8: SourceRdonlyFactory
// on the source rdonly guy, should only have one query to find min & max
func SourceRdonlyFactory(t *testing.T) func() (dbconnpool.PoolConnection, error) {
return func() (dbconnpool.PoolConnection, error) {
return &FakePoolConnection{
t: t,
ExpectedExecuteFetch: []ExpectedExecuteFetch{
ExpectedExecuteFetch{
Query: "SELECT MIN(id), MAX(id) FROM vt_ks.table1",
QueryResult: &mproto.QueryResult{
Fields: []mproto.Field{
mproto.Field{
Name: "min",
Type: mproto.VT_LONGLONG,
},
mproto.Field{
Name: "max",
Type: mproto.VT_LONGLONG,
},
},
Rows: [][]sqltypes.Value{
[]sqltypes.Value{
sqltypes.MakeString([]byte("100")),
sqltypes.MakeString([]byte("200")),
},
},
},
},
},
}, nil
}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:31,代码来源:split_clone_test.go
示例9: VerticalSourceRdonlyFactory
// on the source rdonly guy, should only have one query to find min & max
func VerticalSourceRdonlyFactory(t *testing.T) func() (dbconnpool.PoolConnection, error) {
return func() (dbconnpool.PoolConnection, error) {
return &VerticalFakePoolConnection{
t: t,
ExpectedExecuteFetch: []ExpectedExecuteFetch{
ExpectedExecuteFetch{
Query: "SELECT MIN(id), MAX(id) FROM vt_source_ks.moving1",
QueryResult: &sqltypes.Result{
Fields: []*querypb.Field{
&querypb.Field{
Name: "min",
Type: sqltypes.Int64,
},
&querypb.Field{
Name: "max",
Type: sqltypes.Int64,
},
},
Rows: [][]sqltypes.Value{
[]sqltypes.Value{
sqltypes.MakeString([]byte("100")),
sqltypes.MakeString([]byte("200")),
},
},
},
},
},
}, nil
}
}
开发者ID:BobbWu,项目名称:vitess,代码行数:31,代码来源:vertical_split_clone_test.go
示例10: TestInvalidRowsProto
func TestInvalidRowsProto(t *testing.T) {
p3 := []*query.Row{
&query.Row{
Lengths: []int64{3, 5, -1, 6},
Values: []byte("aa12"),
},
}
rows := Proto3ToRows(p3)
want := [][]sqltypes.Value{{
sqltypes.MakeString([]byte("aa1")),
sqltypes.NULL,
sqltypes.NULL,
sqltypes.NULL,
}}
if !reflect.DeepEqual(rows, want) {
t.Errorf("reverse: \n%#v, want \n%#v", rows, want)
}
p3 = []*query.Row{
&query.Row{
Lengths: []int64{2, -2, 2},
Values: []byte("aa12"),
},
}
rows = Proto3ToRows(p3)
want = [][]sqltypes.Value{{
sqltypes.MakeString([]byte("aa")),
sqltypes.NULL,
sqltypes.MakeString([]byte("12")),
}}
if !reflect.DeepEqual(rows, want) {
t.Errorf("reverse: \n%#v, want \n%#v", rows, want)
}
}
开发者ID:khanchan,项目名称:vitess,代码行数:34,代码来源:proto3_test.go
示例11: createTestTableBaseShowTable
func createTestTableBaseShowTable(tableName string) []sqltypes.Value {
return []sqltypes.Value{
sqltypes.MakeString([]byte(tableName)),
sqltypes.MakeString([]byte("USER TABLE")),
sqltypes.MakeString([]byte("1427325875")),
sqltypes.MakeString([]byte("")),
}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:8,代码来源:schema_info_test.go
示例12: TestMiscTypes
func TestMiscTypes(t *testing.T) {
client := framework.NewClient()
defer client.Execute("delete from vitess_misc", nil)
_, err := client.Execute(
"insert into vitess_misc values(:id, :b, :d, :dt, :t)",
map[string]interface{}{
"id": 1,
"b": "\x01",
"d": "2012-01-01",
"dt": "2012-01-01 15:45:45",
"t": "15:45:45",
},
)
if err != nil {
t.Error(err)
return
}
qr, err := client.Execute("select * from vitess_misc where id = 1", nil)
if err != nil {
t.Error(err)
return
}
want := sqltypes.Result{
Fields: []*querypb.Field{
{
Name: "id",
Type: sqltypes.Int32,
}, {
Name: "b",
Type: sqltypes.Bit,
}, {
Name: "d",
Type: sqltypes.Date,
}, {
Name: "dt",
Type: sqltypes.Datetime,
}, {
Name: "t",
Type: sqltypes.Time,
},
},
RowsAffected: 1,
Rows: [][]sqltypes.Value{
[]sqltypes.Value{
sqltypes.MakeNumeric([]byte("1")),
sqltypes.MakeString([]byte("\x01")),
sqltypes.MakeString([]byte("2012-01-01")),
sqltypes.MakeString([]byte("2012-01-01 15:45:45")),
sqltypes.MakeString([]byte("15:45:45")),
},
},
}
if !reflect.DeepEqual(*qr, want) {
t.Errorf("Execute: \n%#v, want \n%#v", *qr, want)
}
}
开发者ID:tjyang,项目名称:vitess,代码行数:57,代码来源:compatibility_test.go
示例13: StreamExecute
func (sq *testQueryService) StreamExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, sessionID int64, sendReply func(reply *sqltypes.Result) error) error {
// Custom parsing of the query we expect
min := 100
max := 200
var err error
parts := strings.Split(sql, " ")
for _, part := range parts {
if strings.HasPrefix(part, "id>=") {
min, err = strconv.Atoi(part[4:])
if err != nil {
return err
}
} else if strings.HasPrefix(part, "id<") {
max, err = strconv.Atoi(part[3:])
}
}
sq.t.Logf("testQueryService: got query: %v with min %v max %v", sql, min, max)
// Send the headers
if err := sendReply(&sqltypes.Result{
Fields: []*querypb.Field{
{
Name: "id",
Type: sqltypes.Int64,
},
{
Name: "msg",
Type: sqltypes.VarChar,
},
{
Name: "keyspace_id",
Type: sqltypes.Int64,
},
},
}); err != nil {
return err
}
// Send the values
ksids := []uint64{0x2000000000000000, 0x6000000000000000}
for i := min; i < max; i++ {
if err := sendReply(&sqltypes.Result{
Rows: [][]sqltypes.Value{
{
sqltypes.MakeString([]byte(fmt.Sprintf("%v", i))),
sqltypes.MakeString([]byte(fmt.Sprintf("Text for %v", i))),
sqltypes.MakeString([]byte(fmt.Sprintf("%v", ksids[i%2]))),
},
},
}); err != nil {
return err
}
}
// SELECT id, msg, keyspace_id FROM table1 WHERE id>=180 AND id<190 ORDER BY id
return nil
}
开发者ID:littleyang,项目名称:vitess,代码行数:56,代码来源:split_clone_test.go
示例14: StreamExecute
func (sq *testQueryService) StreamExecute(ctx context.Context, query *proto.Query, sendReply func(reply *mproto.QueryResult) error) error {
// Custom parsing of the query we expect
min := 100
max := 200
var err error
parts := strings.Split(query.Sql, " ")
for _, part := range parts {
if strings.HasPrefix(part, "id>=") {
min, err = strconv.Atoi(part[4:])
if err != nil {
return err
}
} else if strings.HasPrefix(part, "id<") {
max, err = strconv.Atoi(part[3:])
}
}
sq.t.Logf("testQueryService: got query: %v with min %v max %v", *query, min, max)
// Send the headers
if err := sendReply(&mproto.QueryResult{
Fields: []mproto.Field{
mproto.Field{
Name: "id",
Type: mproto.VT_LONGLONG,
},
mproto.Field{
Name: "msg",
Type: mproto.VT_VARCHAR,
},
mproto.Field{
Name: "keyspace_id",
Type: mproto.VT_LONGLONG,
},
},
}); err != nil {
return err
}
// Send the values
ksids := []uint64{0x2000000000000000, 0x6000000000000000}
for i := min; i < max; i++ {
if err := sendReply(&mproto.QueryResult{
Rows: [][]sqltypes.Value{
[]sqltypes.Value{
sqltypes.MakeString([]byte(fmt.Sprintf("%v", i))),
sqltypes.MakeString([]byte(fmt.Sprintf("Text for %v", i))),
sqltypes.MakeString([]byte(fmt.Sprintf("%v", ksids[i%2]))),
},
},
}); err != nil {
return err
}
}
// SELECT id, msg, keyspace_id FROM table1 WHERE id>=180 AND id<190 ORDER BY id
return nil
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:56,代码来源:split_clone_test.go
示例15: StreamExecute
func (sq *sourceTabletServer) StreamExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, options *querypb.ExecuteOptions, sendReply func(reply *sqltypes.Result) error) error {
if strings.Contains(sql, sq.excludedTable) {
sq.t.Errorf("Split Diff operation on source should skip the excluded table: %v query: %v", sq.excludedTable, sql)
}
// we test for a keyspace_id where clause, except for v3
if !sq.v3 {
if hasKeyspace := strings.Contains(sql, "WHERE `keyspace_id` < 0x4000000000000000"); hasKeyspace != true {
sq.t.Errorf("Sql query on source should contain a keyspace_id WHERE clause; query received: %v", sql)
}
}
sq.t.Logf("sourceTabletServer: got query: %v", sql)
// Send the headers
if err := sendReply(&sqltypes.Result{
Fields: []*querypb.Field{
{
Name: "id",
Type: sqltypes.Int64,
},
{
Name: "msg",
Type: sqltypes.VarChar,
},
{
Name: "keyspace_id",
Type: sqltypes.Int64,
},
},
}); err != nil {
return err
}
// Send the values
ksids := []uint64{0x2000000000000000, 0x6000000000000000}
for i := 0; i < 100; i++ {
if !sq.v3 && i%2 == 1 {
// for v2, filtering is done at SQL layer
continue
}
if err := sendReply(&sqltypes.Result{
Rows: [][]sqltypes.Value{
{
sqltypes.MakeString([]byte(fmt.Sprintf("%v", i))),
sqltypes.MakeString([]byte(fmt.Sprintf("Text for %v", i))),
sqltypes.MakeString([]byte(fmt.Sprintf("%v", ksids[i%2]))),
},
},
}); err != nil {
return err
}
}
return nil
}
开发者ID:dumbunny,项目名称:vitess,代码行数:55,代码来源:split_diff_test.go
示例16: createTestTableUpdatedStats
func createTestTableUpdatedStats(tableName string) []sqltypes.Value {
return []sqltypes.Value{
sqltypes.MakeString([]byte(tableName)),
sqltypes.MakeString([]byte("USER TABLE")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("0")),
sqltypes.MakeString([]byte("")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("4")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("5")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("6")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("7")),
}
}
开发者ID:CowLeo,项目名称:vitess,代码行数:12,代码来源:schema_info_test.go
示例17: TestSqlQuerySplitQueryInvalidMinMax
func TestSqlQuerySplitQueryInvalidMinMax(t *testing.T) {
db := setUpSqlQueryTest()
testUtils := newTestUtils()
pkMinMaxQuery := "SELECT MIN(pk), MAX(pk) FROM test_table"
pkMinMaxQueryResp := &mproto.QueryResult{
Fields: []mproto.Field{
mproto.Field{Name: "pk", Type: mproto.VT_LONG},
},
RowsAffected: 1,
Rows: [][]sqltypes.Value{
// this make SplitQueryFail
[]sqltypes.Value{
sqltypes.MakeString([]byte("invalid")),
sqltypes.MakeString([]byte("invalid")),
},
},
}
db.AddQuery(pkMinMaxQuery, pkMinMaxQueryResp)
config := testUtils.newQueryServiceConfig()
sqlQuery := NewSqlQuery(config)
dbconfigs := testUtils.newDBConfigs()
err := sqlQuery.allowQueries(nil, &dbconfigs, []SchemaOverride{}, testUtils.newMysqld(&dbconfigs))
if err != nil {
t.Fatalf("allowQueries failed: %v", err)
}
defer sqlQuery.disallowQueries()
ctx := context.Background()
query := proto.SplitQueryRequest{
Query: proto.BoundQuery{
Sql: "select * from test_table where count > :count",
BindVariables: nil,
},
SplitCount: 10,
SessionID: sqlQuery.sessionID,
}
reply := proto.SplitQueryResult{
Queries: []proto.QuerySplit{
proto.QuerySplit{
Query: proto.BoundQuery{
Sql: "",
BindVariables: nil,
},
RowCount: 10,
},
},
}
if err := sqlQuery.SplitQuery(ctx, nil, &query, &reply); err == nil {
t.Fatalf("SqlQuery.SplitQuery should fail")
}
}
开发者ID:haoqoo,项目名称:vitess,代码行数:52,代码来源:sqlquery_test.go
示例18: createTestTableBaseShowTable
func createTestTableBaseShowTable(tableName string) []sqltypes.Value {
return []sqltypes.Value{
sqltypes.MakeString([]byte(tableName)),
sqltypes.MakeString([]byte("USER TABLE")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("1427325875")),
sqltypes.MakeString([]byte("")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("1")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("2")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("3")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("4")),
sqltypes.MakeTrusted(sqltypes.Int32, []byte("5")),
}
}
开发者ID:erzel,项目名称:vitess,代码行数:13,代码来源:schema_info_test.go
示例19: StreamExecute
func (sq *sourceSqlQuery) StreamExecute(ctx context.Context, target *pb.Target, query *proto.Query, sendReply func(reply *mproto.QueryResult) error) error {
if strings.Contains(query.Sql, sq.excludedTable) {
sq.t.Errorf("Split Diff operation on source should skip the excluded table: %v query: %v", sq.excludedTable, query.Sql)
}
// we test for a keyspace_id where clause, except for on views.
if !strings.Contains(query.Sql, "view") {
if hasKeyspace := strings.Contains(query.Sql, "WHERE keyspace_id < 0x4000000000000000"); hasKeyspace != true {
sq.t.Errorf("Sql query on source should contain a keyspace_id WHERE clause; query received: %v", query.Sql)
}
}
sq.t.Logf("sourceSqlQuery: got query: %v", *query)
// Send the headers
if err := sendReply(&mproto.QueryResult{
Fields: []mproto.Field{
mproto.Field{
Name: "id",
Type: mproto.VT_LONGLONG,
},
mproto.Field{
Name: "msg",
Type: mproto.VT_VARCHAR,
},
mproto.Field{
Name: "keyspace_id",
Type: mproto.VT_LONGLONG,
},
},
}); err != nil {
return err
}
// Send the values
ksids := []uint64{0x2000000000000000, 0x6000000000000000}
for i := 0; i < 100; i++ {
if err := sendReply(&mproto.QueryResult{
Rows: [][]sqltypes.Value{
[]sqltypes.Value{
sqltypes.MakeString([]byte(fmt.Sprintf("%v", i))),
sqltypes.MakeString([]byte(fmt.Sprintf("Text for %v", i))),
sqltypes.MakeString([]byte(fmt.Sprintf("%v", ksids[i%2]))),
},
},
}); err != nil {
return err
}
}
return nil
}
开发者ID:haoqoo,项目名称:vitess,代码行数:51,代码来源:split_diff_test.go
示例20: BuildValue
func BuildValue(bytes []byte, fieldType uint32) sqltypes.Value {
switch fieldType {
case C.MYSQL_TYPE_DECIMAL, C.MYSQL_TYPE_FLOAT, C.MYSQL_TYPE_DOUBLE, C.MYSQL_TYPE_NEWDECIMAL:
return sqltypes.MakeFractional(bytes)
case C.MYSQL_TYPE_TIMESTAMP:
return sqltypes.MakeString(bytes)
}
// The below condition represents the following list of values:
// C.MYSQL_TYPE_TINY, C.MYSQL_TYPE_SHORT, C.MYSQL_TYPE_LONG, C.MYSQL_TYPE_LONGLONG, C.MYSQL_TYPE_INT24, C.MYSQL_TYPE_YEAR:
if fieldType <= C.MYSQL_TYPE_INT24 || fieldType == C.MYSQL_TYPE_YEAR {
return sqltypes.MakeNumeric(bytes)
}
return sqltypes.MakeString(bytes)
}
开发者ID:Eric-Chen,项目名称:vitess,代码行数:14,代码来源:mysql.go
注:本文中的github.com/youtube/vitess/go/sqltypes.MakeString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论