aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/api/postgres_messages.zig
blob: 35fee49063eb60ed20f0038a1c9862a37ba0b976 (plain) (blame)
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
pub const String = extern struct {
    data: [*:0]u8 align(1) = undefined,
};

pub const Byten = extern struct {
    data: [*:0]u8 align(1) = undefined,
};

pub const AuthenticationOk = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        byte1: u8 align(1) = 'R',
        length: i32 align(1) = 8,
        tag: i32 align(1) = 0,
    };
    pub const bytes = Bytes{};
};

pub const AuthenticationKerberosV5 = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        byte1: u8 align(1) = 'R',
        length: i32 align(1) = 8,
        tag: i32 align(1) = 2,
    };
    pub const bytes = Bytes{};
};

pub const AuthenticationMD5Password = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        byte1: u8 align(1) = 'R',
        length: i32 align(1) = 12,
        tag: i32 align(1) = 5,
        salt: [4]u8 align(1) = undefined,
    };
    pub const bytes = Bytes{};
};

pub const AuthenticationSCMCredential = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        byte1: u8 align(1) = 'R',
        length: i32 align(1) = 8,
        tag: i32 align(1) = 6,
    };
    pub const bytes = Bytes{};
};

pub const AuthenticationCleartextPassword = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        byte1: u8 align(1) = 'R',
        length: i32 align(1) = 8,
        tag: i32 align(1) = 3,
    };
    pub const bytes = Bytes{};
};

pub const AuthenticationGSS = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as an authentication request.
        byte1: u8 align(1) = 'R',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = 8,
        /// Specifies that GSSAPI authentication is required.
        tag: i32 align(1) = 7,
    };
    pub const bytes = Bytes{};
};

pub const AuthenticationGSSContinue = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as an authentication request.
        byte1: u8 align(1) = 'R',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = 8,
        /// Specifies that this message contains GSSAPI or SSPI data.
        tag: i32 align(1) = 8,
        /// GSSAPI or SSPI authentication data.
        data: []u8 align(1),
    };
    pub const bytes = Bytes{};
};

pub const AuthenticationSSPI = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as an authentication request.
        byte1: u8 align(1) = 'R',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = 8,
        /// Specifies that SSPI authentication is required.
        tag: i32 align(1) = 9,
    };
    pub const bytes = Bytes{};
};

pub const AuthenticationSASL = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as an authentication request.
        byte1: u8 align(1) = 'R',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = 8,
        /// Specifies that SASL authentication is required.
        tag: i32 align(1) = 10,
        /// The message body is a list of SASL authentication mechanisms, in the server's order of preference. A zero byte is required as terminator after the last authentication mechanism name. For each mechanism, there is the following:
        mechanisms: [:0]const u8 align(1) = "",
    };
    pub const bytes = Bytes{};
};

pub const AuthenticationSASLContinue = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as an authentication request.
        byte1: u8 align(1) = 'R',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,
        /// Specifies that this message contains a SASL challenge.
        tag: i32 align(1) = 11,
        /// SASL data, specific to the SASL mechanism being used.
        data: []const u8 align(1) = "",
    };
    pub const bytes = Bytes{};
};

pub const AuthenticationSASLFinal = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as an authentication request.
        byte1: u8 align(1) = 'R',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,
        /// Specifies that SASL authentication has completed.
        tag: i32 align(1) = 12,
        /// SASL outcome "additional data", specific to the SASL mechanism being used.
        data: []const u8 align(1) = "",
    };
    pub const bytes = Bytes{};
};

pub const CancelRequest = extern struct {
    pub const direction = .frontend;
    pub const Bytes = extern struct {
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = 16,
        /// The cancel request code. The value is chosen to contain 1234 in the most significant 16 bits, and 5678 in the least significant 16 bits. (To avoid confusion, this code must not be the same as any protocol version number.)
        code: i32 align(1) = 80877102,
        /// The process ID of the target backend.
        process_id: i32 align(1),
        /// The secret key for the target backend.
        secret_key: i32 align(1),
    };
    pub const bytes = Bytes{};
};

pub const Close = extern struct {
    pub const direction = .frontend;
    pub const Bytes = extern struct {
        /// Identifies the message as a Close command.
        byte1: u8 align(1) = 'C',
        /// Length of message contents in bytes, including self.
        length: i32 align(1),
        /// 'S' to close a prepared statement; or 'P' to close a portal.
        type: u8 align(1),
        /// The name of the prepared statement or portal to close (an empty string selects the unnamed prepared statement or portal).
        name: []u8 align(1),
    };
    pub const bytes = Bytes{};
};

pub const CloseComplete = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as a Close-complete indicator.
        byte1: u8 align(1) = '3',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = 4,
    };
    pub const bytes = Bytes{};
};

pub const CommandComplete = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as a command-completed response.
        byte1: u8 align(1) = 'C',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,
        /// The command tag. This is usually a single word that identifies which SQL command was completed.
        /// For an INSERT command, the tag is INSERT oid rows, where rows is the number of rows inserted. oid used to be the object ID of the inserted row if rows was 1 and the target table had OIDs, but OIDs system columns are not supported anymore; therefore oid is always 0.
        /// For a DELETE command, the tag is DELETE rows where rows is the number of rows deleted.
        /// For an UPDATE command, the tag is UPDATE rows where rows is the number of rows updated.
        /// For a SELECT or CREATE TABLE AS command, the tag is SELECT rows where rows is the number of rows retrieved.
        /// For a MOVE command, the tag is MOVE rows where rows is the number of rows the cursor's position has been changed by.
        /// For a FETCH command, the tag is FETCH rows where rows is the number of rows that have been retrieved from the cursor.
        /// For a COPY command, the tag is COPY rows where rows is the number of rows copied. (Note: the row count appears only in PostgreSQL 8.2 and later.)
        tag: [8]u8 align(1) = .{ 0, 0, 0, 0, 0, 0, 0, 0 },
    };
    pub const bytes = Bytes{};
};

pub const CopyData = extern struct {
    pub const direction = .both;
    pub const Bytes = extern struct {
        /// Identifies the message as copy data.
        byte1: u8 align(1) = 'd',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,
        /// Data that forms part of a copy-in or copy-out operation.
        data: []const u8 align(1),
    };
    pub const bytes = Bytes{};
};

pub const CopyDone = extern struct {
    pub const direction = .frontend;
    pub const Bytes = extern struct {
        /// Identifies the message as copy-done.
        byte1: u8 align(1) = 'c',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = 4,
    };
    pub const bytes = Bytes{};
};

pub const CopyFail = extern struct {
    pub const direction = .frontend;
    pub const Bytes = extern struct {
        /// Identifies the message as copy-fail.
        byte1: u8 align(1) = 'f',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,
        /// The failure message.
        message: [:0]const u8 align(1) = "",
    };
    pub const bytes = Bytes{};
};

pub const CopyInResponse = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as a CopyInResponse.
        byte1: u8 align(1) = 'G',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,

        /// 0 indicates the overall COPY format is textual (rows separated by newlines, columns separated by separator characters, etc.). 1 indicates the overall copy format is binary (similar to DataRow format). See COPY for more information.
        copy_format: i8 align(1) = undefined,

        /// The format code being used for the data transfer.
        columns_count: i16 align(1) = 0,

        /// The format codes to be used for each column. Each must presently be zero (text) or one (binary). All must be zero if the overall copy format is textual.
        columns: []i16 align(1) = &[_]i16{},
    };
    pub const bytes = Bytes{};
};

pub const CopyOutResponse = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as a CopyOutResponse.
        byte1: u8 align(1) = 'H',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,

        /// 0 indicates the overall COPY format is textual (rows separated by newlines, columns separated by separator characters, etc.). 1 indicates the overall copy format is binary (similar to DataRow format). See COPY for more information.
        copy_format: i8 align(1) = undefined,

        /// The format code being used for the data transfer.
        columns_count: i16 align(1) = 0,

        /// The format codes to be used for each column. Each must presently be zero (text) or one (binary). All must be zero if the overall copy format is textual.
        columns: []i16 align(1) = &[_]i16{},
    };
    pub const bytes = Bytes{};
};

pub const CopyBothResponse = extern struct {
    pub const direction = .backend;
    pub const Bytes = struct {
        /// Identifies the message as a CopyBothResponse.
        byte1: u8 align(1) = 'W',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,

        /// 0 indicates the overall COPY format is textual (rows separated by newlines, columns separated by separator characters, etc.). 1 indicates the overall copy format is binary (similar to DataRow format). See COPY for more information.
        copy_format: i8 align(1) = undefined,

        /// The format code being used for the data transfer.
        columns_count: i16 align(1) = 0,

        /// The format codes to be used for each column. Each must presently be zero (text) or one (binary). All must be zero if the overall copy format is textual.
        columns: [*]i16 align(1) = &[_]i16{},
    };
    pub const bytes = Bytes{};
};

pub const DataRow = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as a DataRow.
        byte1: u8 align(1) = 'D',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,
        /// The number of column values that follow (possibly zero).
        columns_count: i16 align(1) = 0,
    };
    pub const bytes = Bytes{};
};

pub const Describe = extern struct {
    pub const direction = .frontend;
    pub const Bytes = extern struct {
        /// Identifies the message as a Describe command.
        byte1: u8 align(1) = 'D',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,
        /// The object to describe. 'S' to describe a prepared statement; or 'P' to describe a portal.
        object_type: u8 align(1) = 'S',
        /// The name of the prepared statement or portal to describe (an empty string selects the unnamed prepared statement or portal).
        object_name: [*:0]const u8 align(1) = "",
    };
    pub const bytes = Bytes{};
};

pub const EmptyQueryResponse = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as an EmptyQueryResponse.
        byte1: u8 align(1) = 'I',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = 4,
    };
    pub const bytes = Bytes{};
};

pub const ErrorResponse = extern struct {
    pub const direction = .backend;
    pub const Bytes = extern struct {
        /// Identifies the message as an ErrorResponse.
        byte1: u8 align(1) = 'E',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,
        /// The fields of the error response.
        fields: [*:0]const Field align(1) = &[_]Field{},
    };
    pub const bytes = Bytes{};

    pub const Field = extern struct {
        /// The error code.
        code: u8 align(1) = undefined,
        /// The error message.
        message: [:0]const u8 align(1) = "",
    };
};

pub const Execute = extern struct {
    pub const direction = .frontend;
    pub const Bytes = extern struct {
        /// Identifies the message as an Execute command.
        byte1: u8 align(1) = 'E',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,
        /// The name of the portal to execute (an empty string selects the unnamed portal).
        portal_name: [*:0]const u8 align(1) = "",
        /// The maximum number of rows to return, if portal contains a query that returns rows (ignored otherwise). Zero denotes "no limit".
        max_rows: i32 align(1) = 0,
    };
    pub const bytes = Bytes{};
};

pub const Flush = extern struct {
    pub const direction = .frontend;
    pub const Bytes = extern struct {
        /// Identifies the message as a Flush.
        byte1: u8 align(1) = 'H',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = 4,
    };
    pub const bytes = Bytes{};
};

pub const FunctionCall = extern struct {
    pub const direction = .frontend;
    pub const Bytes = extern struct {
        /// Identifies the message as a FunctionCall.
        byte1: u8 align(1) = 'F',
        /// Length of message contents in bytes, including self.
        length: i32 align(1) = undefined,
        /// The object ID of the function to be called.
        function_id: i32 align(1) = undefined,

        /// The number of argument format codes that follow (denoted C below). This can be zero to indicate that there are no arguments or that the arguments all use the default format (text); or one, in which case the specified format code is applied to all arguments; or it can equal the actual number of arguments.
        format_codes_len: i16 align(1) = 0,

        format_codes: [:0]i16 align(1) = &[_]i16{},
    };
    pub const bytes = Bytes{};

    pub const Argument = extern struct {
        /// The argument value, in the format indicated by the associated format code. n is the above length.
        value: [:0]const u8 align(1) = "",
    };
};