-
Notifications
You must be signed in to change notification settings - Fork 486
Expand file tree
/
Copy pathproxy.proto
More file actions
264 lines (224 loc) · 5.09 KB
/
proxy.proto
File metadata and controls
264 lines (224 loc) · 5.09 KB
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
syntax = "proto3";
package proxy;
message Queries {
repeated Query queries = 1;
// Uuid
string client_id = 2;
}
message Query {
string stmt = 1;
oneof Params {
Positional positional = 2;
Named named = 3;
}
bool skip_rows = 4;
}
message Positional {
repeated Value values = 1;
}
message Named {
repeated string names = 1;
repeated Value values = 2;
}
message QueryResult {
oneof row_result {
Error error = 1;
ResultRows row = 2;
}
}
message Error {
enum ErrorCode {
SQL_ERROR = 0;
TX_BUSY = 1;
TX_TIMEOUT = 2;
INTERNAL = 3;
}
ErrorCode code = 1;
string message = 2;
int32 extended_code = 3;
}
message ResultRows {
repeated Column column_descriptions = 1;
repeated Row rows = 2;
uint64 affected_row_count = 3;
optional int64 last_insert_rowid = 4;
}
message DescribeRequest {
string client_id = 1;
string stmt = 2;
}
message DescribeResult {
oneof describe_result {
Error error = 1;
Description description = 2;
}
}
message Description {
repeated Column column_descriptions = 1;
repeated string param_names = 2;
uint64 param_count = 3;
}
message Value {
/// wincode encoded Value (binary compatible with bincode)
bytes data = 1;
}
message Row {
repeated Value values = 1;
}
message Column {
string name = 1;
optional string decltype = 3;
}
message DisconnectMessage {
string client_id = 1;
}
message Ack { }
enum State {
INIT = 0;
INVALID = 1;
TXN = 2;
}
message ExecuteResults {
repeated QueryResult results = 1;
/// State after executing the queries
State state = 2;
/// Primary frame_no after executing the request.
optional uint64 current_frame_no = 3;
}
message Program {
repeated Step steps = 1;
}
message Step {
optional Cond cond = 1;
Query query = 2;
}
message Cond {
oneof cond {
OkCond ok = 1;
ErrCond err = 2;
NotCond not = 3;
AndCond and = 4;
OrCond or = 5;
IsAutocommitCond is_autocommit = 6;
}
}
message OkCond {
int64 step = 1;
}
message ErrCond {
int64 step = 1;
}
message NotCond {
Cond cond = 1;
}
message AndCond {
repeated Cond conds = 1;
}
message OrCond {
repeated Cond conds = 1;
}
message IsAutocommitCond {
}
message ProgramReq {
string client_id = 1;
Program pgm = 2;
}
/// Streaming exec request
message ExecReq {
/// id of the request. The response will contain this id.
uint32 request_id = 1;
oneof request {
StreamProgramReq execute = 2;
StreamDescribeReq describe = 3;
}
}
/// Describe request for the streaming protocol
message StreamProgramReq {
Program pgm = 1;
}
/// descibre request for the streaming protocol
message StreamDescribeReq {
string stmt = 1;
}
/// Response message for the streaming proto
/// Request response types
message Init { }
message BeginStep { }
message FinishStep {
uint64 affected_row_count = 1;
optional int64 last_insert_rowid = 2;
}
message StepError {
Error error = 1;
}
message ColsDescription {
repeated Column columns = 1;
}
message RowValue {
oneof value {
string text = 1;
int64 integer = 2;
double real = 3;
bytes blob = 4;
// null if present
bool null = 5;
}
}
message BeginRows { }
message BeginRow { }
message AddRowValue {
RowValue val = 1;
}
message FinishRow { }
message FinishRows { }
message Finish {
optional uint64 last_frame_no = 1;
bool is_autocommit = 2;
}
/// Stream execx dexcribe response messages
message DescribeParam {
optional string name = 1;
}
message DescribeCol {
string name = 1;
optional string decltype = 2;
}
message DescribeResp {
repeated DescribeParam params = 1;
repeated DescribeCol cols = 2;
bool is_explain = 3;
bool is_readonly = 4;
}
message RespStep {
oneof step {
Init init = 1;
BeginStep begin_step = 2;
FinishStep finish_step = 3;
StepError step_error = 4;
ColsDescription cols_description = 5;
BeginRows begin_rows = 6;
BeginRow begin_row = 7;
AddRowValue add_row_value = 8;
FinishRow finish_row = 9;
FinishRows finish_rows = 10;
Finish finish = 11;
}
}
message ProgramResp {
repeated RespStep steps = 1;
}
message ExecResp {
uint32 request_id = 1;
oneof response {
ProgramResp program_resp = 2;
DescribeResp describe_resp = 3;
Error error = 4;
}
}
service Proxy {
rpc StreamExec(stream ExecReq) returns (stream ExecResp) {}
// Deprecated:
rpc Execute(ProgramReq) returns (ExecuteResults) {}
rpc Describe(DescribeRequest) returns (DescribeResult) {}
rpc Disconnect(DisconnectMessage) returns (Ack) {}
}