-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexpressions.go
264 lines (198 loc) · 4.29 KB
/
expressions.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
package sql
import "strconv"
type TableExpression struct {
From Table
GroupBy *GroupBy
OrderBy *OrderBy
Limit *Limit
LockTp SelectLockType
}
type Expr interface {
Expression()
}
type Exprs []Expr
func (Exprs) Expression() {}
func (Exprs) ValueExpression() {}
type BoolExpr interface {
Expression()
BoolExpression()
}
type ValueExpr interface {
Expression()
ValueExpression()
}
type OrExpr struct {
Left, Right Expr
}
func (*OrExpr) Expression() {}
type XorExpr struct {
Left, Right Expr
}
func (*XorExpr) Expression() {}
type AndExpr struct {
Left, Right Expr
}
func (*AndExpr) Expression() {}
type NotExpr struct {
Expr Expr
}
func (*NotExpr) Expression() {}
type TrueExpr struct {
Expr Expr
Not bool
}
func (*TrueExpr) Expression() {}
type FalseExpr struct {
Expr Expr
Not bool
}
func (*FalseExpr) Expression() {}
type UnknownExpr struct {
Expr Expr
Not bool
}
func (*UnknownExpr) Expression() {}
type IsNullPri struct {
Expr BoolExpr
Not bool
}
func (*IsNullPri) BoolExpression() {}
func (*IsNullPri) Expression() {}
type CompOp struct {
Left BoolExpr
Right ValueExpr
}
func (*CompOp) BoolExpression() {}
func (*CompOp) Expression() {}
type CompOpAll struct {
Left BoolExpr
Right ValueExpr
}
func (*CompOpAll) BoolExpression() {}
func (*CompOpAll) Expression() {}
type Predicate struct {
Expr ValueExpr
}
func (*Predicate) Expression() {}
func (*Predicate) BoolExpression() {}
type InCondition struct {
Expr ValueExpr
Not bool
List Exprs
}
func (*InCondition) Expression() {}
func (*InCondition) ValueExpression() {}
type BetweenCondition struct {
Not bool
Right ValueExpr
Left ValueExpr
}
func (*BetweenCondition) Expression() {}
func (*BetweenCondition) ValueExpression() {}
type LikeCondition struct {
Expr ValueExpr
Not bool
Pattern ValueExpr
}
func (*LikeCondition) Expression() {}
func (*LikeCondition) ValueExpression() {}
type RgexpCondition struct {
Expr ValueExpr
Not bool
Pattern ValueExpr
}
func (*RgexpCondition) Expression() {}
func (*RgexpCondition) ValueExpression() {}
const (
BITAND = "&"
BITOR = "|"
BITXOR = "^"
PLUS = "+"
MINUS = "-"
MULT = "*"
DIV = "/"
MOD = "%"
SHIFTLEFT = "<<"
SHIFTRIGHT = ">>"
OPEQ = "="
OPEQUAL = "=="
OPLT = "<"
OPGT = ">"
OPLE = "<="
OPGE = ">="
OPNE = "!="
OPNSE = "<=>"
OROR = "||"
UPLUS = "+"
UMINUS = "-"
TILDA = "~"
NOT2 = "!"
UBINARY = "binary"
)
type BinaryOperationExpr struct {
Operator string
Left, Right ValueExpr
}
func (*BinaryOperationExpr) Expression() {}
func (*BinaryOperationExpr) ValueExpression() {}
type IntervalExpr struct {
Expr Expr
Interval []byte
}
func (*IntervalExpr) Expression() {}
func (*IntervalExpr) ValueExpression() {}
type FuncExpr struct{}
func (*FuncExpr) Expression() {}
func (*FuncExpr) ValueExpression() {}
type CollateExpr struct {
Expr ValueExpr
Collate []byte
}
func (*CollateExpr) Expression() {}
func (*CollateExpr) ValueExpression() {}
type ExistsExpr struct {
SubQuery *SubQueryStmt
}
func (*ExistsExpr) Expression() {}
func (*ExistsExpr) ValueExpression() {}
type IdentExpr struct {
Ident []byte
Expr Expr
}
func (*IdentExpr) Expression() {}
func (*IdentExpr) ValueExpression() {}
type MatchExpr struct{}
func (*MatchExpr) Expression() {}
func (*MatchExpr) ValueExpression() {}
type StringVal []byte
func (StringVal) Expression() {}
func (StringVal) ValueExpression() {}
type BoolVal bool
func (BoolVal) Expression() {}
func (BoolVal) ValueExpression() {}
type BinVal []byte
func (BinVal) Expression() {}
func (BinVal) ValueExpression() {}
type NullVal struct{}
func (NullVal) Expression() {}
func (NullVal) ValueExpression() {}
type HexVal []byte
func (HexVal) Expression() {}
func (HexVal) ValueExpression() {}
type NumVal []byte
func (NumVal) Expression() {}
func (NumVal) ValueExpression() {}
func (n NumVal) ParseInt() (int, error) {
i, err := strconv.Atoi(string([]byte(n)))
if err != nil {
return 0, err
}
return i, nil
}
type SchemaObject struct {
Schema []byte
Table []byte
Column []byte
}
func (*SchemaObject) Expression() {}
func (*SchemaObject) ValueExpression() {}