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
//! `SqlCatalog` trait + descriptor-resolution error type.
//!
//! The SQL planner resolves collection metadata through the
//! `SqlCatalog` trait. Both Origin (via the host-side
//! `CredentialStore` + `SystemCatalog`) and Lite (via the embedded
//! redb catalog) implement it. The trait lives in its own file so
//! `types.rs` stays under the 500-line limit and so the error
//! surface has headroom for additional variants.
use Error;
use crateCollectionInfo;
/// Errors surfaced by `SqlCatalog` implementations.
///
/// Only one variant today — callers pattern-match directly and
/// map the retryable case to `SqlError::RetryableSchemaChanged`
/// via the `From` impl in `error.rs`. The enum shape is kept
/// despite having a single variant so future variants can be
/// added without a breaking change.
/// Trait for looking up collection metadata during planning.
///
/// Both Origin (via CredentialStore) and Lite (via the embedded
/// redb catalog) implement this trait.
///
/// The return type is `Result<Option<CollectionInfo>, _>` with
/// a three-way semantics:
///
/// - `Ok(Some(info))` — the collection exists and is usable.
/// An Origin implementation will have acquired a descriptor
/// lease at the current version before returning; subsequent
/// planning against the same collection within the lease
/// window is drain-safe.
/// - `Ok(None)` — the collection does not exist. Callers should
/// surface this as `SqlError::UnknownTable`.
/// - `Err(SqlCatalogError::RetryableSchemaChanged { .. })` —
/// the collection exists but a DDL drain is in progress.
/// Callers propagate this up so the pgwire layer can retry
/// the whole statement.