radixdb-catalog 1.1.0

Generational logical catalog owner for RadixDB
Documentation
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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
use std::fmt;

pub type CatalogResult<T> = Result<T, CatalogError>;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CatalogError {
    InvalidObjectIdHex,
    ZeroObjectId,
    ReservedObjectId {
        hex: String,
    },
    UnknownObjectKind {
        tag: u16,
    },
    ReservedObjectKind {
        tag: u16,
        name: &'static str,
    },
    UnsupportedCatalogMinor {
        major: u16,
        minor: u16,
    },
    ObjectKindRequiresCatalogMinor {
        tag: u16,
        name: &'static str,
        required_minor: u16,
        actual_minor: u16,
    },
    EmptyName,
    EmbeddedNameNul,
    DisplayNameTooLong {
        actual: usize,
        limit: usize,
    },
    NormalizedNameTooLong {
        actual: usize,
        limit: usize,
    },
    NonCanonicalNormalizedName,
    UnsupportedPayloadVersion {
        kind: &'static str,
        version: u16,
    },
    UnknownPayloadFlags {
        kind: &'static str,
        flags: u64,
    },
    EmptyCanonicalSql {
        field: &'static str,
    },
    EmbeddedSqlNul {
        field: &'static str,
    },
    CanonicalSqlTooLong {
        field: &'static str,
        actual: usize,
        limit: usize,
    },
    EmptyObjectIdList {
        field: &'static str,
    },
    TooManyObjectIds {
        field: &'static str,
        actual: usize,
        limit: usize,
    },
    DuplicateObjectId {
        field: &'static str,
        id: String,
    },
    InvalidDataTypeDescriptor {
        detail: &'static str,
    },
    InvalidColumnPayload {
        detail: &'static str,
    },
    InvalidTablePayload {
        detail: &'static str,
    },
    InvalidConstraintPayload {
        detail: &'static str,
    },
    InvalidIndexPayload {
        detail: &'static str,
    },
    InvalidExtensionPayload {
        detail: &'static str,
    },
    InvalidExternalTypePayload {
        detail: &'static str,
    },
    InvalidOperatorPayload {
        detail: &'static str,
    },
    InvalidOperatorClassPayload {
        detail: &'static str,
    },
    InvalidPlannerSupportPayload {
        detail: &'static str,
    },
    UnknownPayloadEnumTag {
        owner: &'static str,
        tag: u16,
    },
    UnknownEdgeKind {
        tag: u16,
    },
    ReservedEdgeKind {
        tag: u16,
        name: &'static str,
    },
    UnsupportedEdgeVersion {
        version: u16,
    },
    UnknownEdgeFlags {
        flags: u32,
    },
    DuplicateCatalogObject {
        id: String,
    },
    DuplicateCatalogName {
        name: String,
    },
    InvalidCatalogObject {
        id: String,
        detail: &'static str,
    },
    PayloadKindMismatch {
        id: String,
        header: &'static str,
        payload: &'static str,
    },
    MissingCatalogObject {
        role: &'static str,
        id: String,
    },
    DuplicateCatalogEdge {
        source: String,
        target: String,
        kind: &'static str,
        ordinal: u32,
    },
    IllegalCatalogEdge {
        source: String,
        target: String,
        kind: &'static str,
        detail: &'static str,
    },
    CatalogDependencyCycle {
        id: String,
    },
    CatalogDependencyDepthExceeded {
        id: String,
        depth: usize,
        limit: usize,
    },
    InvalidCatalogFormat {
        detail: &'static str,
    },
    CatalogLimitExceeded {
        field: &'static str,
        actual: u64,
        limit: u64,
    },
    CatalogChecksumMismatch {
        scope: &'static str,
    },
    InvalidCatalogUtf8 {
        field: &'static str,
    },
    NonCanonicalCatalogEncoding {
        detail: &'static str,
    },
    InvalidCatalogPublication {
        detail: &'static str,
    },
    CatalogPublicationUnavailable,
    InvalidCatalogMutation {
        detail: &'static str,
    },
    CatalogMutationLimitExceeded {
        field: &'static str,
        actual: usize,
        limit: usize,
    },
    StaleCatalogMutation {
        field: &'static str,
        expected: String,
        actual: String,
    },
    CatalogObjectPreconditionFailed {
        id: String,
        detail: &'static str,
    },
}

impl fmt::Display for CatalogError {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::InvalidObjectIdHex => {
                formatter.write_str("object ID must contain exactly 32 hexadecimal digits")
            }
            Self::ZeroObjectId => formatter.write_str("all-zero object ID is not an identity"),
            Self::ReservedObjectId { hex } => {
                write!(
                    formatter,
                    "object ID {hex} belongs to the reserved V6 range"
                )
            }
            Self::UnknownObjectKind { tag } => write!(formatter, "unknown object kind tag {tag}"),
            Self::ReservedObjectKind { tag, name } => write!(
                formatter,
                "object kind {name} ({tag}) is reserved and not admitted"
            ),
            Self::UnsupportedCatalogMinor { major, minor } => {
                write!(formatter, "unsupported catalog format {major}.{minor}")
            }
            Self::ObjectKindRequiresCatalogMinor {
                tag,
                name,
                required_minor,
                actual_minor,
            } => write!(
                formatter,
                "object kind {name} ({tag}) requires catalog 6.{required_minor}, got 6.{actual_minor}"
            ),
            Self::EmptyName => formatter.write_str("catalog name cannot be empty"),
            Self::EmbeddedNameNul => formatter.write_str("catalog name contains an embedded NUL"),
            Self::DisplayNameTooLong { actual, limit } => write!(
                formatter,
                "display name has {actual} UTF-8 bytes; V6 limit is {limit}"
            ),
            Self::NormalizedNameTooLong { actual, limit } => write!(
                formatter,
                "normalized name has {actual} UTF-8 bytes; V6 limit is {limit}"
            ),
            Self::NonCanonicalNormalizedName => {
                formatter.write_str("stored normalized name is not canonical for its display name")
            }
            Self::UnsupportedPayloadVersion { kind, version } => {
                write!(formatter, "unsupported {kind} payload version {version}")
            }
            Self::UnknownPayloadFlags { kind, flags } => {
                write!(formatter, "unknown {kind} payload flags 0x{flags:016x}")
            }
            Self::EmptyCanonicalSql { field } => {
                write!(formatter, "canonical SQL field {field} cannot be empty")
            }
            Self::EmbeddedSqlNul { field } => {
                write!(
                    formatter,
                    "canonical SQL field {field} contains an embedded NUL"
                )
            }
            Self::CanonicalSqlTooLong {
                field,
                actual,
                limit,
            } => write!(
                formatter,
                "canonical SQL field {field} has {actual} UTF-8 bytes; V6 limit is {limit}"
            ),
            Self::EmptyObjectIdList { field } => {
                write!(formatter, "object ID list {field} cannot be empty")
            }
            Self::TooManyObjectIds {
                field,
                actual,
                limit,
            } => write!(
                formatter,
                "object ID list {field} has {actual} entries; V6 limit is {limit}"
            ),
            Self::DuplicateObjectId { field, id } => {
                write!(formatter, "object ID list {field} contains duplicate {id}")
            }
            Self::InvalidDataTypeDescriptor { detail } => {
                write!(formatter, "invalid data type descriptor: {detail}")
            }
            Self::InvalidColumnPayload { detail } => {
                write!(formatter, "invalid column payload: {detail}")
            }
            Self::InvalidTablePayload { detail } => {
                write!(formatter, "invalid table payload: {detail}")
            }
            Self::InvalidConstraintPayload { detail } => {
                write!(formatter, "invalid constraint payload: {detail}")
            }
            Self::InvalidIndexPayload { detail } => {
                write!(formatter, "invalid index payload: {detail}")
            }
            Self::InvalidExtensionPayload { detail } => {
                write!(formatter, "invalid extension payload: {detail}")
            }
            Self::InvalidExternalTypePayload { detail } => {
                write!(formatter, "invalid external type payload: {detail}")
            }
            Self::InvalidOperatorPayload { detail } => {
                write!(formatter, "invalid operator payload: {detail}")
            }
            Self::InvalidOperatorClassPayload { detail } => {
                write!(formatter, "invalid operator class payload: {detail}")
            }
            Self::InvalidPlannerSupportPayload { detail } => {
                write!(formatter, "invalid planner support payload: {detail}")
            }
            Self::UnknownPayloadEnumTag { owner, tag } => {
                write!(formatter, "unknown {owner} tag {tag}")
            }
            Self::UnknownEdgeKind { tag } => write!(formatter, "unknown catalog edge kind {tag}"),
            Self::ReservedEdgeKind { tag, name } => write!(
                formatter,
                "catalog edge kind {name} ({tag}) is reserved and not admitted in V6.0"
            ),
            Self::UnsupportedEdgeVersion { version } => {
                write!(formatter, "unsupported catalog edge version {version}")
            }
            Self::UnknownEdgeFlags { flags } => {
                write!(formatter, "unknown catalog edge flags 0x{flags:08x}")
            }
            Self::DuplicateCatalogObject { id } => {
                write!(formatter, "duplicate catalog object ID {id}")
            }
            Self::DuplicateCatalogName { name } => {
                write!(formatter, "duplicate catalog name key {name}")
            }
            Self::InvalidCatalogObject { id, detail } => {
                write!(formatter, "invalid catalog object {id}: {detail}")
            }
            Self::PayloadKindMismatch {
                id,
                header,
                payload,
            } => write!(
                formatter,
                "catalog object {id} header kind {header} does not match payload kind {payload}"
            ),
            Self::MissingCatalogObject { role, id } => {
                write!(
                    formatter,
                    "missing catalog object {id} referenced as {role}"
                )
            }
            Self::DuplicateCatalogEdge {
                source,
                target,
                kind,
                ordinal,
            } => write!(
                formatter,
                "duplicate catalog edge {source} -{kind}[{ordinal}]-> {target}"
            ),
            Self::IllegalCatalogEdge {
                source,
                target,
                kind,
                detail,
            } => write!(
                formatter,
                "illegal catalog edge {source} -{kind}-> {target}: {detail}"
            ),
            Self::CatalogDependencyCycle { id } => {
                write!(formatter, "catalog dependency cycle reaches object {id}")
            }
            Self::CatalogDependencyDepthExceeded { id, depth, limit } => write!(
                formatter,
                "catalog dependency depth at {id} is {depth}; V6 limit is {limit}"
            ),
            Self::InvalidCatalogFormat { detail } => {
                write!(formatter, "invalid V6 catalog format: {detail}")
            }
            Self::CatalogLimitExceeded {
                field,
                actual,
                limit,
            } => write!(
                formatter,
                "V6 catalog field {field} is {actual}; hard limit is {limit}"
            ),
            Self::CatalogChecksumMismatch { scope } => {
                write!(formatter, "V6 catalog {scope} checksum mismatch")
            }
            Self::InvalidCatalogUtf8 { field } => {
                write!(formatter, "V6 catalog field {field} is not valid UTF-8")
            }
            Self::NonCanonicalCatalogEncoding { detail } => {
                write!(formatter, "non-canonical V6 catalog encoding: {detail}")
            }
            Self::InvalidCatalogPublication { detail } => {
                write!(formatter, "invalid catalog publication: {detail}")
            }
            Self::CatalogPublicationUnavailable => {
                formatter.write_str("catalog publication lock is unavailable")
            }
            Self::InvalidCatalogMutation { detail } => {
                write!(formatter, "invalid catalog mutation: {detail}")
            }
            Self::CatalogMutationLimitExceeded {
                field,
                actual,
                limit,
            } => write!(
                formatter,
                "catalog mutation {field} is {actual}; V6 limit is {limit}"
            ),
            Self::StaleCatalogMutation {
                field,
                expected,
                actual,
            } => write!(
                formatter,
                "stale catalog mutation: expected {field} {expected}, found {actual}"
            ),
            Self::CatalogObjectPreconditionFailed { id, detail } => {
                write!(
                    formatter,
                    "catalog object {id} precondition failed: {detail}"
                )
            }
        }
    }
}

impl std::error::Error for CatalogError {}