forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
88 lines (73 loc) · 1.57 KB
/
structs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright 2012, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package proto
import (
"fmt"
"github.com/youtube/vitess/go/bytes2"
mproto "github.com/youtube/vitess/go/mysql/proto"
)
type SessionParams struct {
Keyspace string
Shard string
}
type SessionInfo struct {
SessionId int64
}
type Query struct {
Sql string
BindVariables map[string]interface{}
SessionId int64
TransactionId int64
}
// String prints a readable version of Query, and also truncates
// data if it's too long
func (query *Query) String() string {
buf := bytes2.NewChunkedWriter(1024)
fmt.Fprintf(buf, "Sql: %#v, BindVars: {", query.Sql)
for k, v := range query.BindVariables {
switch val := v.(type) {
case []byte:
fmt.Fprintf(buf, "%s: %#v, ", k, slimit(string(val)))
case string:
fmt.Fprintf(buf, "%s: %#v, ", k, slimit(val))
default:
fmt.Fprintf(buf, "%s: %v, ", k, v)
}
}
fmt.Fprintf(buf, "}")
return string(buf.Bytes())
}
func slimit(s string) string {
l := len(s)
if l > 256 {
l = 256
}
return s[:l]
}
type BoundQuery struct {
Sql string
BindVariables map[string]interface{}
}
type QueryList struct {
Queries []BoundQuery
SessionId int64
TransactionId int64
}
type QueryResultList struct {
List []mproto.QueryResult
}
type Session struct {
SessionId int64
TransactionId int64
}
type TransactionInfo struct {
TransactionId int64
}
type DmlType struct {
Table string
Keys []string
}
type DDLInvalidate struct {
DDL string
}