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
// SPDX-License-Identifier: Apache-2.0
//! Standard PostgreSQL SQLSTATE code constants.
//!
//! A single source of truth for every five-character SQLSTATE string used
//! across the codebase. Grouping follows the PostgreSQL documentation
//! appendix (Class 00–XX). All constants are `&'static str` so they compose
//! directly with `pgwire::error::ErrorInfo` without any allocation.
//!
//! Add new codes here when a new error path needs one; never inline a literal
//! elsewhere — a typo in a SQLSTATE string is undetectable at compile time.
// ── Class 00 — Successful Completion ────────────────────────────────────────
/// `00000` — `successful_completion`
pub const SUCCESS: &str = "00000";
// ── Class 01 — Warning ───────────────────────────────────────────────────────
/// `01000` — `warning` (generic warning)
pub const WARNING: &str = "01000";
// ── Class 02 — No Data ───────────────────────────────────────────────────────
/// `02000` — `no_data` (document / row not found)
pub const NO_DATA: &str = "02000";
// ── Class 0A — Feature Not Supported ────────────────────────────────────────
/// `0A000` — `feature_not_supported`
pub const FEATURE_NOT_SUPPORTED: &str = "0A000";
// ── Class 22 — Data Exception ────────────────────────────────────────────────
/// `22003` — `numeric_value_out_of_range`
pub const NUMERIC_VALUE_OUT_OF_RANGE: &str = "22003";
// ── Class 23 — Integrity Constraint Violation ────────────────────────────────
/// `23000` — `integrity_constraint_violation` (generic)
pub const INTEGRITY_CONSTRAINT_VIOLATION: &str = "23000";
/// `23502` — `not_null_violation`
pub const NOT_NULL_VIOLATION: &str = "23502";
/// `23503` — `foreign_key_violation` (dangling-edge rejection)
pub const FOREIGN_KEY_VIOLATION: &str = "23503";
/// `23505` — `unique_violation`
pub const UNIQUE_VIOLATION: &str = "23505";
/// `23514` — `check_violation`
pub const CHECK_VIOLATION: &str = "23514";
/// `23601` — NodeDB extension: append-only write rejected.
pub const APPEND_ONLY_VIOLATION: &str = "23601";
/// `23602` — NodeDB extension: balance constraint violated.
pub const BALANCE_VIOLATION: &str = "23602";
/// `23603` — NodeDB extension: period lock; writes rejected.
pub const PERIOD_LOCKED: &str = "23603";
/// `23604` — NodeDB extension: state-transition constraint violated.
pub const STATE_TRANSITION_VIOLATION: &str = "23604";
/// `23605` — NodeDB extension: transition-check constraint violated.
pub const TRANSITION_CHECK_VIOLATION: &str = "23605";
/// `23606` — NodeDB extension: retention policy blocks deletion.
pub const RETENTION_VIOLATION: &str = "23606";
/// `23607` — NodeDB extension: legal hold blocks deletion.
pub const LEGAL_HOLD_ACTIVE: &str = "23607";
/// `23608` — NodeDB extension: type-guard constraint violated.
pub const TYPE_GUARD_VIOLATION: &str = "23608";
// ── Class 28 — Invalid Authorization Specification ───────────────────────────
/// `28000` — `invalid_authorization_specification` (no valid credentials)
pub const INVALID_AUTHORIZATION: &str = "28000";
// ── Class 40 — Transaction Rollback ──────────────────────────────────────────
/// `40001` — `serialization_failure` (write conflict; client should retry)
pub const SERIALIZATION_FAILURE: &str = "40001";
// ── Class 42 — Syntax Error or Access Rule Violation ─────────────────────────
/// `42501` — `insufficient_privilege`
pub const INSUFFICIENT_PRIVILEGE: &str = "42501";
/// `42601` — `syntax_error`
pub const SYNTAX_ERROR: &str = "42601";
/// `42846` — `cannot_coerce`
pub const CANNOT_COERCE: &str = "42846";
/// `42P01` — `undefined_table` (collection not found)
pub const UNDEFINED_TABLE: &str = "42P01";
// ── Class 53 — Insufficient Resources ────────────────────────────────────────
/// `53200` — `out_of_memory`
pub const OUT_OF_MEMORY: &str = "53200";
/// `53300` — `too_many_connections` (closest match for rate-limit denial)
pub const TOO_MANY_CONNECTIONS: &str = "53300";
/// `53400` — `configuration_limit_exceeded` (quota exceeded)
pub const CONFIGURATION_LIMIT_EXCEEDED: &str = "53400";
// ── Class 54 — Program Limit Exceeded ────────────────────────────────────────
/// `54000` — `program_limit_exceeded` (generic over-cap)
pub const PROGRAM_LIMIT_EXCEEDED: &str = "54000";
/// `54001` — `statement_too_complex` (fan-out / rate limit exceeded)
pub const STATEMENT_TOO_COMPLEX: &str = "54001";
// ── Class 55 — Object Not In Prerequisite State ──────────────────────────────
/// `55P03` — `lock_not_available` (no cluster leader)
pub const LOCK_NOT_AVAILABLE: &str = "55P03";
// ── Class 57 — Operator Intervention ─────────────────────────────────────────
/// `57014` — `query_canceled` (deadline exceeded)
pub const QUERY_CANCELED: &str = "57014";
/// `57P03` — `cannot_connect_now` (collection is draining)
pub const CANNOT_CONNECT_NOW: &str = "57P03";
/// `57P04` — `database_dropped` (not-leader redirect; client should retry elsewhere)
pub const DATABASE_DROPPED: &str = "57P04";
// ── Class XX — Internal Error ────────────────────────────────────────────────
/// `XX000` — `internal_error`
pub const INTERNAL_ERROR: &str = "XX000";