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
//! Supporting types for the `DatabaseAdapter` trait family.
//!
//! Extracted from the main `traits` module to keep the trait definition file
//! focused on method signatures.
use ;
use Result;
use Stream;
use DatabaseAdapter;
use crate::;
/// Result from a relay pagination query, containing rows and an optional total count.
/// A snapshot of an adapter's query-result cache, for the operator surface.
///
/// Exists because the admin API could see only the Arrow Flight query cache, and so
/// answered "Cache is not configured" for a server whose sibling endpoint reported the
/// query result cache active in the same breath (#941). An adapter that caches nothing
/// returns `None` from
/// [`DatabaseAdapter::result_cache_stats`](super::DatabaseAdapter::result_cache_stats)
/// — "no such cache" and "a cache holding zero entries" are different answers and the
/// endpoint must not conflate them.
/// A typed cursor value for keyset (relay) pagination.
///
/// The cursor type is determined at compile time by `QueryDefinition::relay_cursor_type`
/// and used at runtime to choose the correct SQL comparison and cursor
/// encoding/decoding path.
/// Parameters for an `execute_with_projection_arc` call (F043).
///
/// Consolidates the six positional parameters of the projection-execution path
/// into a single borrowed struct so adapters and callers cannot reorder them
/// by mistake. All fields borrow from the caller; the struct is constructed
/// per-request on the stack and discarded after the call.
///
/// # Field ordering
///
/// The field order mirrors a SQL `SELECT … FROM view WHERE … ORDER BY … LIMIT
/// … OFFSET …` clause, top-to-bottom, so that reading the struct mirrors the
/// query it produces.
///
/// Intentionally **not** `#[non_exhaustive]`: the struct is the *call shape*
/// of the trait method and any field addition is a breaking trait change
/// regardless. Callers construct it with a struct literal so that omitting a
/// field is a hard compile error.
/// JSONB rows delivered as the database produces them, rather than collected
/// into a `Vec` first (#958).
///
/// Returned by
/// [`DatabaseAdapter::stream_with_projection`](super::DatabaseAdapter::stream_with_projection).
/// Boxed because the trait is used through `dyn DatabaseAdapter`, and `Send`
/// because a response body is polled from whichever task the transport runs on.
///
/// # What the caller is holding
///
/// A stream is not a `Vec` that arrives late. On PostgreSQL it is an open portal
/// inside an open transaction, which means the read holds a pooled connection for
/// as long as the stream is alive. Consume it promptly, and drop it as soon as the
/// response is finished — dropping is what closes the transaction and returns the
/// connection.
pub type JsonbRowStream = ;
/// The column-shaped counterpart of [`JsonbRowStream`], for transports that
/// decode typed columns rather than a JSONB document (gRPC).
///
/// Returned by
/// [`DatabaseAdapter::stream_row_query`](super::DatabaseAdapter::stream_row_query).
/// The same connection-lifetime caveat applies.
pub type ColumnRowStream = ;
/// Type alias for boxed dynamic database adapters.
///
/// Used to store database adapters without generic type parameters in collections
/// or struct fields. The adapter type is determined at runtime.
///
/// # Example
///
/// ```ignore
/// let adapter: BoxDatabaseAdapter = Box::new(postgres_adapter);
/// ```
pub type BoxDatabaseAdapter = ;
/// Type alias for arc-wrapped dynamic database adapters.
///
/// Used for thread-safe, reference-counted storage of adapters in shared state.
///
/// # Example
///
/// ```ignore
/// let adapter: ArcDatabaseAdapter = Arc::new(postgres_adapter);
/// ```
pub type ArcDatabaseAdapter = ;
/// One operator-supplied statement, and every bound the database is asked to
/// enforce on it (#962).
///
/// This is the call shape of
/// [`DatabaseAdapter::execute_admin_sql`](super::DatabaseAdapter::execute_admin_sql),
/// the only path on which FraiseQL runs SQL it did not generate. Every field is a
/// containment control, and each is enforced *by PostgreSQL* rather than by
/// inspecting the statement text:
///
/// * `read_only` becomes the transaction's own mode, so a write is refused with SQLSTATE `25006` no
/// matter how it is spelled. A parser deciding whether a string "is a SELECT" is a guess about a
/// dialect it does not own; a read-only transaction is not.
/// * `commit` is the *only* thing that makes any effect outlast the request. The transaction is
/// rolled back otherwise, which is what makes the default a preview.
/// * `statement_timeout_ms` is `SET LOCAL statement_timeout`, so the server cancels the backend.
/// * `session_vars` are the same transaction-local settings the executor applies for a real query,
/// which is what lets an operator preview a row under a tenant's RLS rather than as the pool's
/// role.
///
/// Not `#[non_exhaustive]`: it is a trait method's parameter list, so adding a
/// field is a breaking change either way, and a struct literal makes an omitted
/// bound a compile error rather than a default someone did not choose.
/// What one [`AdminSqlRequest`] did.
///
/// `committed` is reported rather than assumed: it is the difference between a
/// preview and a change, and an operator reading the response should not have to
/// re-derive it from what they asked for.