/
queryinfo.go
150 lines (116 loc) · 3.52 KB
/
queryinfo.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package function
import "github.com/Ciyfly/FakerMysql/sql"
// RowCount implements the ROW_COUNT() function
type RowCount struct{}
func NewRowCount() sql.Expression {
return RowCount{}
}
var _ sql.FunctionExpression = RowCount{}
// Resolved implements sql.Expression
func (r RowCount) Resolved() bool {
return true
}
// String implements sql.Expression
func (r RowCount) String() string {
return "ROW_COUNT()"
}
// Type implements sql.Expression
func (r RowCount) Type() sql.Type {
return sql.Uint64
}
// IsNullable implements sql.Expression
func (r RowCount) IsNullable() bool {
return false
}
// Eval implements sql.Expression
func (r RowCount) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
return ctx.GetLastQueryInfo(sql.RowCount), nil
}
// Children implements sql.Expression
func (r RowCount) Children() []sql.Expression {
return nil
}
// WithChildren implements sql.Expression
func (r RowCount) WithChildren(children ...sql.Expression) (sql.Expression, error) {
return sql.NillaryWithChildren(r, children...)
}
// FunctionName implements sql.FunctionExpression
func (r RowCount) FunctionName() string {
return "row_count"
}
// LastInsertId implements the LAST_INSERT_ID() function
type LastInsertId struct{}
func NewLastInsertId() sql.Expression {
return LastInsertId{}
}
var _ sql.FunctionExpression = LastInsertId{}
// Resolved implements sql.Expression
func (r LastInsertId) Resolved() bool {
return true
}
// String implements sql.Expression
func (r LastInsertId) String() string {
return "LAST_INSERT_ID()"
}
// Type implements sql.Expression
func (r LastInsertId) Type() sql.Type {
return sql.Uint64
}
// IsNullable implements sql.Expression
func (r LastInsertId) IsNullable() bool {
return false
}
// Eval implements sql.Expression
func (r LastInsertId) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
return ctx.GetLastQueryInfo(sql.LastInsertId), nil
}
// Children implements sql.Expression
func (r LastInsertId) Children() []sql.Expression {
return nil
}
// WithChildren implements sql.Expression
func (r LastInsertId) WithChildren(children ...sql.Expression) (sql.Expression, error) {
return sql.NillaryWithChildren(r, children...)
}
// FunctionName implements sql.FunctionExpression
func (r LastInsertId) FunctionName() string {
return "last_insert_id"
}
// FoundRows implements the FOUND_ROWS() function
type FoundRows struct{}
func NewFoundRows() sql.Expression {
return FoundRows{}
}
var _ sql.FunctionExpression = FoundRows{}
// Resolved implements sql.Expression
func (r FoundRows) Resolved() bool {
return true
}
// String implements sql.Expression
func (r FoundRows) String() string {
return "FOUND_ROWS()"
}
// Type implements sql.Expression
func (r FoundRows) Type() sql.Type {
return sql.Uint64
}
// IsNullable implements sql.Expression
func (r FoundRows) IsNullable() bool {
return false
}
// Eval implements sql.Expression
func (r FoundRows) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
return ctx.GetLastQueryInfo(sql.FoundRows), nil
}
// Children implements sql.Expression
func (r FoundRows) Children() []sql.Expression {
return nil
}
// WithChildren implements sql.Expression
func (r FoundRows) WithChildren(children ...sql.Expression) (sql.Expression, error) {
return sql.NillaryWithChildren(r, children...)
}
// FunctionName implements sql.FunctionExpression
func (r FoundRows) FunctionName() string {
return "found_rows"
}