fraiseql_wire/protocol/constants.rs
1//! Postgres protocol constants
2
3/// Protocol version 3.0
4pub const PROTOCOL_VERSION: i32 = 0x0003_0000;
5
6/// Message type tags
7pub mod tags {
8 /// Authentication request
9 pub const AUTHENTICATION: u8 = b'R';
10
11 /// Backend key data
12 pub const BACKEND_KEY_DATA: u8 = b'K';
13
14 /// Command complete
15 pub const COMMAND_COMPLETE: u8 = b'C';
16
17 /// Data row
18 pub const DATA_ROW: u8 = b'D';
19
20 /// Error response
21 pub const ERROR_RESPONSE: u8 = b'E';
22
23 /// Notice response
24 pub const NOTICE_RESPONSE: u8 = b'N';
25
26 /// Parameter status
27 pub const PARAMETER_STATUS: u8 = b'S';
28
29 /// Ready for query
30 pub const READY_FOR_QUERY: u8 = b'Z';
31
32 /// Row description
33 pub const ROW_DESCRIPTION: u8 = b'T';
34
35 /// Empty query response (reply to an empty query string)
36 pub const EMPTY_QUERY_RESPONSE: u8 = b'I';
37
38 /// Asynchronous notification (`LISTEN`/`NOTIFY`)
39 pub const NOTIFICATION_RESPONSE: u8 = b'A';
40
41 /// `CopyInResponse` — server is ready to receive `COPY ... FROM STDIN` data
42 pub const COPY_IN_RESPONSE: u8 = b'G';
43
44 /// `CopyOutResponse` — server is about to send `COPY ... TO STDOUT` data
45 pub const COPY_OUT_RESPONSE: u8 = b'H';
46
47 /// `CopyBothResponse` — bidirectional COPY (streaming replication)
48 pub const COPY_BOTH_RESPONSE: u8 = b'W';
49}
50
51/// Authentication types
52pub mod auth {
53 /// Authentication successful
54 pub const OK: i32 = 0;
55
56 /// Cleartext password required
57 pub const CLEARTEXT_PASSWORD: i32 = 3;
58
59 /// MD5 password required
60 pub const MD5_PASSWORD: i32 = 5;
61
62 /// SASL mechanisms available (Postgres 10+)
63 pub const SASL: i32 = 10;
64
65 /// SASL server challenge
66 pub const SASL_CONTINUE: i32 = 11;
67
68 /// SASL server final message
69 pub const SASL_FINAL: i32 = 12;
70}
71
72/// Transaction status
73pub mod tx_status {
74 /// Idle (not in transaction)
75 pub const IDLE: u8 = b'I';
76
77 /// In transaction block
78 pub const IN_TRANSACTION: u8 = b'T';
79
80 /// Failed transaction (queries will be rejected until END)
81 pub const FAILED: u8 = b'E';
82}