mariadb-cli 0.1.1

One-shot agent-native command line client for MariaDB servers
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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
//! The table itself: every published setting and the closed word lists behind
//! them.
//!
//! A key absent from this file does not exist in the product.

use super::types::{Domain, Fallback, KeySpec};

/// Truth values the product accepts on the way in.
///
/// Only `true` and `false` are ever written back, so a stored file never mixes
/// spellings, but a caller typing the obvious alternatives is not punished.
pub(super) const TRUE_WORDS: [&str; 3] = ["true", "yes", "1"];
pub(super) const FALSE_WORDS: [&str; 3] = ["false", "no", "0"];

const CHANNEL_COMPRESSION: [&str; 3] = ["auto", "always", "never"];
const OUTPUT_FORMAT: [&str; 4] = ["json", "ndjson", "tsv", "text"];
const BINARY_SHAPE: [&str; 2] = ["summary", "full"];
const ROW_COUNT_MODE: [&str; 2] = ["matched", "changed"];
const SECRET_STORAGE: [&str; 2] = ["file", "none"];
const LOG_LEVEL: [&str; 5] = ["error", "warn", "info", "debug", "trace"];
const LOG_ROTATION: [&str; 3] = ["daily", "hourly", "never"];

/// How far the destination's own policy reaches.
///
/// A destination declared read-only usually means "do not write here", not "do
/// not look here", so narrowing the policy to changes is the ordinary case and
/// extending it to everything is the deliberate one.
const POLICY_SCOPE: [&str; 2] = ["change", "all"];

/// How often the server is asked whether it accepts writes.
///
/// The answer almost never changes inside one invocation, so asking once is
/// enough; asking before every change buys correctness on a server whose mode
/// is being switched underneath, at the cost of a round trip each time.
const READONLY_PROBE: [&str; 2] = ["once", "always"];

/// Whether a copy is taken against a locked set of tables.
///
/// Locking gives one consistent instant across engines that cannot provide a
/// snapshot, and it blocks every writer while it holds, so it is never the
/// default.
const EXPORT_LOCK: [&str; 2] = ["none", "tables"];

/// When the notice that session state dies with the invocation is emitted.
const EPHEMERAL_NOTICE: [&str; 2] = ["on_create", "always"];

/// How thoroughly a server certificate is checked.
///
/// Trusting an unknown authority and accepting a certificate issued for another
/// address are separate risks, but a caller choosing a level wants one word for
/// it, so the two settings behind it move together and predictably.
const TLS_VERIFY: [&str; 3] = ["full", "ca", "none"];

/// Where the trusted authorities come from.
const TLS_ROOT_STORE: [&str; 3] = ["system", "bundled", "file"];

/// The lowest protocol version the channel will negotiate.
///
/// Nothing below 1.2 is offered at all: the versions before it are broken in
/// public and the product will not carry a way to ask for them.
const TLS_MIN_VERSION: [&str; 2] = ["1.2", "1.3"];

/// Builds one entry of the registry.
const fn key(
    name: &'static str,
    domain: Domain,
    fallback: Fallback,
    about: &'static str,
) -> KeySpec {
    KeySpec {
        name,
        domain,
        fallback,
        about,
    }
}

use Domain::{Boolean, Enumeration, IntegerInRange, NonNegativeInteger, PositiveInteger, Text};
use Fallback::{Absent, Builtin, Host, Server};

/// Every published setting, in the order the manual lists them.
pub(super) static REGISTRY: &[KeySpec] = &[
    // Destination.
    key(
        "conn.default",
        Text,
        Absent,
        "profile used when none is named",
    ),
    key(
        "conn.default_port",
        IntegerInRange(1, 65_535),
        Builtin("3306"),
        "port used when a destination names none",
    ),
    key(
        "conn.require_tls",
        Boolean,
        Builtin("true"),
        "demand an encrypted channel",
    ),
    key(
        "conn.prefer_socket",
        Boolean,
        Builtin("true"),
        "prefer the local channel when it exists",
    ),
    key(
        "conn.timezone",
        Text,
        Server,
        "time zone declared on the session",
    ),
    key("conn.charset", Text, Server, "character set of the session"),
    key(
        "conn.compression",
        Enumeration(&CHANNEL_COMPRESSION),
        Builtin("auto"),
        "channel compression",
    ),
    key(
        "conn.keepalive_secs",
        PositiveInteger,
        Builtin("60"),
        "liveness signal on the channel",
    ),
    key(
        "conn.max_packet_bytes",
        PositiveInteger,
        Server,
        "largest packet the channel accepts",
    ),
    key(
        "conn.idle_timeout_secs",
        PositiveInteger,
        Server,
        "time until the server drops an idle session",
    ),
    key(
        "conn.stmt_cache_size",
        NonNegativeInteger,
        Builtin("16"),
        "prepared statements kept on the session",
    ),
    key(
        "conn.session_setup",
        Text,
        Absent,
        "adjustments applied when the session opens",
    ),
    // Encryption. Demanding an encrypted channel says nothing about how well the
    // certificate on the other end is checked, so the level, the trust source and
    // the floor on the protocol are settings of their own rather than one switch.
    key(
        "tls.verify",
        Enumeration(&TLS_VERIFY),
        Builtin("full"),
        "how thoroughly the server certificate is checked",
    ),
    key(
        "tls.root_store",
        Enumeration(&TLS_ROOT_STORE),
        Builtin("system"),
        "where the trusted authorities come from",
    ),
    key(
        "tls.min_version",
        Enumeration(&TLS_MIN_VERSION),
        Builtin("1.2"),
        "lowest protocol version the channel negotiates",
    ),
    // Output.
    key(
        "output.format",
        Enumeration(&OUTPUT_FORMAT),
        Builtin("json"),
        "shape of the primary channel",
    ),
    key(
        "output.max_rows",
        PositiveInteger,
        Builtin("1000"),
        "ceiling on returned rows",
    ),
    key(
        "output.max_bytes",
        PositiveInteger,
        Builtin("1048576"),
        "ceiling on total volume",
    ),
    key(
        "output.truncate_cell",
        PositiveInteger,
        Builtin("4096"),
        "ceiling per cell",
    ),
    key(
        "output.redact",
        Boolean,
        Builtin("false"),
        "replace credential-shaped text inside cells",
    ),
    key(
        "output.binary",
        Enumeration(&BINARY_SHAPE),
        Builtin("summary"),
        "shape of a binary value",
    ),
    // How much of a thing the reader is shown. Each of these was a number in the
    // source deciding an interface question, which is precisely the sort of
    // question a reader is entitled to answer for themselves.
    //
    // The first multiplies `output.max_rows`, and that relationship is the
    // reason it is a setting rather than a constant: a caller who lowered the
    // row ceiling to keep answers small did not thereby mean to make counting
    // refuse a table a thousand times smaller than yesterday. Deriving from the
    // ceiling is right; deriving by a factor nobody can see is not.
    key(
        "output.count_headroom",
        PositiveInteger,
        Builtin("1000"),
        "how far past the row ceiling an exact count may still be attempted",
    ),
    key(
        "output.near_name_count",
        PositiveInteger,
        Builtin("5"),
        "how many near names a hint offers",
    ),
    key(
        "output.most_frequent_shown",
        PositiveInteger,
        Builtin("3"),
        "how many of the most frequent values a summary shows",
    ),
    // Budgets.
    key(
        "limits.query_timeout_secs",
        PositiveInteger,
        Builtin("30"),
        "ceiling for one operation",
    ),
    key(
        "limits.connect_timeout_secs",
        PositiveInteger,
        Builtin("10"),
        "ceiling for opening the connection",
    ),
    key(
        "limits.retries",
        NonNegativeInteger,
        Builtin("2"),
        "extra attempts on a repeatable failure",
    ),
    key(
        "limits.retry_base_ms",
        PositiveInteger,
        Builtin("200"),
        "first wait between attempts",
    ),
    key(
        "limits.retry_deadline_ms",
        PositiveInteger,
        Builtin("30000"),
        "longest the whole series of attempts may take",
    ),
    key(
        "limits.max_affected_rows",
        PositiveInteger,
        Builtin("1000"),
        "ceiling on rows one change may affect",
    ),
    key(
        "limits.max_concurrency",
        PositiveInteger,
        Host,
        "ceiling on simultaneous internal work",
    ),
    // The four below were numbers written into the source, and each of them
    // decided something a caller can reasonably want decided differently. Three
    // were merely invisible. The first was worse than invisible: it was applied
    // with `min` over `conn.max_packet_bytes`, so a caller who raised that
    // published key to 64 MiB went on reading 1 MiB, with exit 0 and no word
    // said. A literal that ANNULS a published key is the costliest form of
    // hardcoding, because the setting appears to work and does not.
    key(
        "limits.max_statement_bytes",
        PositiveInteger,
        Builtin("1048576"),
        "largest statement this product will read",
    ),
    // Distinct from the key above, and the distinction is the whole point. That
    // one bounds how large a single statement may BE; this one bounds how much
    // the product will READ before it has judged anything at all. Three entry
    // points took a whole file or the whole of the standard input into memory
    // and only then measured statements, so a two gigabyte file was resident
    // before any ceiling existed to refuse it.
    //
    // Reusing the statement ceiling here was considered and refused: a script of
    // many small statements is legitimate and its total is not a statement, so
    // one number cannot answer both questions without refusing correct input.
    key(
        "limits.max_input_bytes",
        PositiveInteger,
        Builtin("16777216"),
        "most this product will read from a file or the standard input",
    ),
    // Bounded rather than merely positive, and the bound is not decoration. A
    // thread cannot be given a workable stack of seven bytes, and this key hands
    // a number straight to one: published as any positive integer, a walk over
    // the registry set it to seven and the parser thread overflowed and aborted
    // the process. A domain that admits a value the product cannot survive is a
    // domain that has not been stated.
    key(
        "limits.parser_stack_bytes",
        IntegerInRange(1_048_576, 134_217_728),
        Builtin("67108864"),
        "stack given to the thread that parses",
    ),
    // The wait between attempts doubles, and it used to stop doubling after a
    // count written into the source, so the ceiling on a single wait existed and
    // could not be reached. Published as the ceiling itself rather than as the
    // number of doublings, because the ceiling is the thing anybody cares about.
    key(
        "limits.retry_wait_ceiling_ms",
        PositiveInteger,
        Builtin("6400"),
        "longest a single wait between attempts may grow to",
    ),
    key(
        "limits.max_concurrency_ceiling",
        PositiveInteger,
        Builtin("32"),
        "highest value the simultaneous work ceiling may be raised to",
    ),
    // Defence. The lock that refused every change was deliberately removed:
    // holding it on made the change surface unreachable, and the defence it was
    // standing in for is really the confirmation, the required restriction and
    // the ceiling on affected rows, each of which refuses on its own merits.
    key(
        "sql.read_only",
        Boolean,
        Builtin("false"),
        "refuse any change",
    ),
    key(
        "sql.policy_scope",
        Enumeration(&POLICY_SCOPE),
        Builtin("change"),
        "how far a destination's own policy reaches",
    ),
    key(
        "sql.ephemeral_notice",
        Enumeration(&EPHEMERAL_NOTICE),
        Builtin("on_create"),
        "when the notice of session state dying is emitted",
    ),
    key(
        "sql.require_where",
        Boolean,
        Builtin("true"),
        "refuse a change without a restriction",
    ),
    key(
        "sql.require_unique_key",
        Boolean,
        Builtin("false"),
        "refuse a change whose restriction is not on a unique key",
    ),
    key(
        "sql.local_file_read",
        Boolean,
        Builtin("false"),
        "let the server read a local file",
    ),
    key(
        "sql.delimiter",
        Text,
        Builtin(";"),
        "statement separator inside a file",
    ),
    key(
        "sql.row_count_mode",
        Enumeration(&ROW_COUNT_MODE),
        Builtin("changed"),
        "what a change count means",
    ),
    key(
        "secret.storage_mode",
        Enumeration(&SECRET_STORAGE),
        Builtin("file"),
        "how the secret is kept",
    ),
    // A change carries its target on the line that asked for it. Reading is
    // allowed to inherit the stored default, because a read that lands on the
    // wrong destination answers the wrong question and stops there; a change
    // that lands on the wrong destination has already happened by the time
    // anybody reads the answer.
    key(
        "conn.require_explicit_target",
        Boolean,
        Builtin("true"),
        "make a change name its destination on the call",
    ),
    // Structure.
    key(
        "schema.index_advice",
        Boolean,
        Builtin("false"),
        "point out a key with no index behind it",
    ),
    // The budget the compact map of a whole database is drawn under. These two
    // were written into the source with a comment admitting that sizing them
    // from `output.max_rows` would empty the map, which is a correct argument
    // for a budget of their own and not an argument for no setting at all.
    key(
        "schema.map_tables",
        PositiveInteger,
        Builtin("500"),
        "how many tables the compact map draws",
    ),
    key(
        "schema.map_rows",
        PositiveInteger,
        Builtin("20000"),
        "how many rows the compact map reads",
    ),
    // Server work.
    key(
        "server.status_interval_secs",
        PositiveInteger,
        Builtin("1"),
        "gap between two status samples",
    ),
    key(
        "server.readonly_probe",
        Enumeration(&READONLY_PROBE),
        Builtin("once"),
        "how often the server is asked whether it accepts writes",
    ),
    key(
        "server.observability_visible",
        Boolean,
        Builtin("true"),
        "offer the commands that observe other connections",
    ),
    key(
        "server.kill_foreign_requires_yes",
        Boolean,
        Builtin("true"),
        "demand confirmation before stopping another connection",
    ),
    // Data movement.
    key(
        "import.batch_size",
        PositiveInteger,
        Builtin("1000"),
        "rows sent to the server per batch",
    ),
    key(
        "data.rows_per_statement",
        PositiveInteger,
        Builtin("100"),
        "rows one statement of a copy carries",
    ),
    key(
        "data.stop_on_refusal",
        Boolean,
        Builtin("false"),
        "let one refused row stop the whole load",
    ),
    key(
        "data.export_lock",
        Enumeration(&EXPORT_LOCK),
        Builtin("none"),
        "hold the tables still while a copy is taken",
    ),
    // Diagnostics.
    key(
        "log.level",
        Enumeration(&LOG_LEVEL),
        Builtin("error"),
        "detail of the auxiliary channel",
    ),
    key(
        "log.to_file",
        Boolean,
        Builtin("false"),
        "write diagnostics to a file",
    ),
    key(
        "log.rotation",
        Enumeration(&LOG_ROTATION),
        Builtin("daily"),
        "how the diagnostic file turns over",
    ),
    key(
        "log.retention",
        PositiveInteger,
        Builtin("7"),
        "how many diagnostic files are kept",
    ),
    key("i18n.lang", Text, Host, "language of messages"),
];