@carllee1983/dbcli 1.53.0 → 1.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/dbcli.mdc +1 -1
- package/.cursor/skills/dbcli/reference.md +22 -6
- package/.github/skills/dbcli/SKILL.md +1 -1
- package/.github/skills/dbcli/reference.md +22 -6
- package/CHANGELOG.md +21 -0
- package/assets/SKILL.md +1 -1
- package/assets/SKILL.zh-TW.md +1 -1
- package/assets/reference.md +22 -6
- package/dist/cli-runtime.mjs +35103 -85552
- package/dist/cli.mjs +3 -2
- package/dist/core.d.ts +357 -274
- package/dist/core.mjs +9125 -21887
- package/package.json +3 -2
- package/plugins/dbcli-agent/skills/dbcli/SKILL.md +1 -1
- package/plugins/dbcli-agent/skills/dbcli/reference.md +22 -6
- package/skills/dbcli/SKILL.md +1 -1
- package/skills/dbcli/reference.md +22 -6
package/.cursor/rules/dbcli.mdc
CHANGED
|
@@ -605,4 +605,4 @@ schema. Raw `query` / `export` invocations render a sortable table only.
|
|
|
605
605
|
- Blacklisted tables and columns are redacted from query output.
|
|
606
606
|
- `schema` reports `estimatedRowCount` and `sizeCategory` (small / medium / large / huge). For large/huge tables add `WHERE` or `LIMIT` — bands in [reference.md](../skills/dbcli/reference.md#schema).
|
|
607
607
|
- `doctor` on `mongodb+srv://` reports whether SRV resolves natively or through the DoH fallback — useful when the runtime restricts DNS.
|
|
608
|
-
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `--timeout <ms>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
|
608
|
+
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `--timeout <ms>`, `--statement-timeout <ms>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
|
@@ -83,13 +83,16 @@ command-level option is only valid after the command that declares it.
|
|
|
83
83
|
| `--global` | Select the user-global registry at `~/.config/dbcli/config.json` instead of the current project's `.dbcli` config. Place it before the command path. |
|
|
84
84
|
| `--use <connection>` | Select a named connection for this invocation; place it before the command path unless that command explicitly lists a command-level `--use`. |
|
|
85
85
|
| `--timeout <ms>` | Connection timeout in milliseconds (integer, 100–600000), overriding the connection config's `timeout` field for this invocation. Applies to every engine adapter. Without either the flag or the config field, adapters fall back to their built-in 5000ms default. |
|
|
86
|
+
| `--statement-timeout <ms>` | How long a single statement may run, in milliseconds (integer, 0–3600000; `0` removes the limit), overriding the connection config's `statementTimeout` field. Independent of the connection timeout — raising it does not slow down detection of an unreachable host. Falls back to `--timeout` when unset, and to the server's own setting when neither is given. |
|
|
86
87
|
|
|
87
88
|
`--timeout` is applied only when the adapter is constructed for this invocation — it is
|
|
88
89
|
never written back to `config.json`. Set the connection's `timeout` field instead for a
|
|
89
|
-
value that persists across runs.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
value that persists across runs. `--timeout` caps statement time as well as connection time, so a
|
|
91
|
+
low value cuts off a long-running query with an error that reads like a connection
|
|
92
|
+
problem; the 100ms floor exists specifically to keep that failure mode from being too
|
|
93
|
+
easy to trigger. Use `--statement-timeout` when only the statement limit should change.
|
|
94
|
+
With neither flag, dbcli sets no statement limit at all — the server's setting decides,
|
|
95
|
+
so a query that runs longer than the connection timeout is no longer cut off.
|
|
93
96
|
Elasticsearch applies its timeout per request rather than once for the whole connection.
|
|
94
97
|
The `timeout` field itself always takes a literal number — unlike other connection
|
|
95
98
|
fields, it does not accept an `{"$env": "..."}` reference.
|
|
@@ -220,8 +223,8 @@ dbcli list --include-system # Elasticsearch: include `.system` indices
|
|
|
220
223
|
**Permission:** query-only+
|
|
221
224
|
|
|
222
225
|
> **MongoDB:** Lists collections with estimated document count.
|
|
223
|
-
> **Redis:**
|
|
224
|
-
> **Elasticsearch:** Returns indices with `documentCount` from `/
|
|
226
|
+
> **Redis:** Samples the first 1 000 keys scanned via `SCAN MATCH * COUNT 1000`, applying the blacklist during the scan. When the keyspace is larger, table output adds a `Sampled the first 1000 keys scanned` line and JSON output carries `sampled: true` with `sampleLimit`. The header reads `Keys in db <n> (redis):` where `<n>` is the logical DB index.
|
|
227
|
+
> **Elasticsearch:** Returns indices with `documentCount` from one `/_cat/indices?h=index,docs.count&expand_wildcards=all` request (open and closed indices alike). The count is primaries-only, so a replicated index no longer reports its replica copies as extra documents. Aliases are tagged separately. System indices (names starting with `.`) are hidden unless `--include-system` is passed.
|
|
225
228
|
|
|
226
229
|
### schema
|
|
227
230
|
|
|
@@ -243,6 +246,13 @@ dbcli schema --use prod # Scan prod DB; saves to .dbcli/schemas/prod
|
|
|
243
246
|
**Options:** `--format <table|json>`, `--refresh`, `--reset`, `--force`, `--use <connection>`, `--sample-size <n>` (mongo only), `--sample-method <random|natural>` (mongo only)
|
|
244
247
|
**Permission:** query-only+
|
|
245
248
|
|
|
249
|
+
> **Row counts on a full scan:** scanning every table records
|
|
250
|
+
> `rowCountIsEstimate: true` and reports the engine's row *estimate* (`information_schema.TABLES.TABLE_ROWS` on MySQL/MariaDB,
|
|
251
|
+
> `pg_class.reltuples` on PostgreSQL) rather than running `COUNT(*)` per table —
|
|
252
|
+
> a hundred full-table counts is what made scanning a large database unusable.
|
|
253
|
+
> `dbcli schema <table>` on a single table still reports the exact count. Tables
|
|
254
|
+
> are scanned with bounded parallelism (4 at a time).
|
|
255
|
+
|
|
246
256
|
**Schema storage (v1.4+):** Schema is persisted as layered files under `.dbcli/schemas/`. With v2 multi-connection config each connection gets its own subdirectory (`.dbcli/schemas/<connection>/`). Run `dbcli schema --use <connection>` once per connection before querying it — otherwise `schema <table>` may return data from the wrong connection's cache.
|
|
247
257
|
|
|
248
258
|
> **PostgreSQL:** Introspection uses the exact `public` catalog identity throughout. Full catalog/schema/table joins prevent a reused constraint name from contaminating another table; enum lookup includes its namespace; composite primary-key order comes from the exact table OID and index ordinality; and row estimates are scoped to the exact `public` relation. Row-count SQL qualifies and quotes both `"public"` and the exact table identifier, escaping embedded quotes so mixed-case or punctuation-bearing names remain distinct and safe.
|
|
@@ -286,6 +296,12 @@ dbcli query "SELECT * FROM orders" --format html > orders.html # pipe to stdou
|
|
|
286
296
|
**Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--fields <list>`, `--truncate <number>` / `--no-truncate`, `-f, --query-file <path>`, `--use <name[,name]>`, `--slow-ms <number>`, `--recovery`
|
|
287
297
|
**Permission:** query-only+ (Redis: per-command; Elasticsearch: per HTTP method/path)
|
|
288
298
|
|
|
299
|
+
> **Server-side scripts are rejected on every path.** MongoDB `$where`,
|
|
300
|
+
> `$function`, and `$accumulator`, and Elasticsearch `script` / `script_fields`,
|
|
301
|
+
> execute code on the database server. The adapters reject them anywhere in a
|
|
302
|
+
> filter, pipeline, or DSL body — before the request is sent — so `query`, `q`,
|
|
303
|
+
> saved snippets, and DML planning all behave the same way.
|
|
304
|
+
|
|
289
305
|
#### Passive slow-query hint (`--slow-ms`)
|
|
290
306
|
|
|
291
307
|
`query` and `q` read the execution time they already measured for a finished
|
|
@@ -605,4 +605,4 @@ schema. Raw `query` / `export` invocations render a sortable table only.
|
|
|
605
605
|
- Blacklisted tables and columns are redacted from query output.
|
|
606
606
|
- `schema` reports `estimatedRowCount` and `sizeCategory` (small / medium / large / huge). For large/huge tables add `WHERE` or `LIMIT` — bands in [reference.md](reference.md#schema).
|
|
607
607
|
- `doctor` on `mongodb+srv://` reports whether SRV resolves natively or through the DoH fallback — useful when the runtime restricts DNS.
|
|
608
|
-
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `--timeout <ms>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
|
608
|
+
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `--timeout <ms>`, `--statement-timeout <ms>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
|
@@ -83,13 +83,16 @@ command-level option is only valid after the command that declares it.
|
|
|
83
83
|
| `--global` | Select the user-global registry at `~/.config/dbcli/config.json` instead of the current project's `.dbcli` config. Place it before the command path. |
|
|
84
84
|
| `--use <connection>` | Select a named connection for this invocation; place it before the command path unless that command explicitly lists a command-level `--use`. |
|
|
85
85
|
| `--timeout <ms>` | Connection timeout in milliseconds (integer, 100–600000), overriding the connection config's `timeout` field for this invocation. Applies to every engine adapter. Without either the flag or the config field, adapters fall back to their built-in 5000ms default. |
|
|
86
|
+
| `--statement-timeout <ms>` | How long a single statement may run, in milliseconds (integer, 0–3600000; `0` removes the limit), overriding the connection config's `statementTimeout` field. Independent of the connection timeout — raising it does not slow down detection of an unreachable host. Falls back to `--timeout` when unset, and to the server's own setting when neither is given. |
|
|
86
87
|
|
|
87
88
|
`--timeout` is applied only when the adapter is constructed for this invocation — it is
|
|
88
89
|
never written back to `config.json`. Set the connection's `timeout` field instead for a
|
|
89
|
-
value that persists across runs.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
value that persists across runs. `--timeout` caps statement time as well as connection time, so a
|
|
91
|
+
low value cuts off a long-running query with an error that reads like a connection
|
|
92
|
+
problem; the 100ms floor exists specifically to keep that failure mode from being too
|
|
93
|
+
easy to trigger. Use `--statement-timeout` when only the statement limit should change.
|
|
94
|
+
With neither flag, dbcli sets no statement limit at all — the server's setting decides,
|
|
95
|
+
so a query that runs longer than the connection timeout is no longer cut off.
|
|
93
96
|
Elasticsearch applies its timeout per request rather than once for the whole connection.
|
|
94
97
|
The `timeout` field itself always takes a literal number — unlike other connection
|
|
95
98
|
fields, it does not accept an `{"$env": "..."}` reference.
|
|
@@ -220,8 +223,8 @@ dbcli list --include-system # Elasticsearch: include `.system` indices
|
|
|
220
223
|
**Permission:** query-only+
|
|
221
224
|
|
|
222
225
|
> **MongoDB:** Lists collections with estimated document count.
|
|
223
|
-
> **Redis:**
|
|
224
|
-
> **Elasticsearch:** Returns indices with `documentCount` from `/
|
|
226
|
+
> **Redis:** Samples the first 1 000 keys scanned via `SCAN MATCH * COUNT 1000`, applying the blacklist during the scan. When the keyspace is larger, table output adds a `Sampled the first 1000 keys scanned` line and JSON output carries `sampled: true` with `sampleLimit`. The header reads `Keys in db <n> (redis):` where `<n>` is the logical DB index.
|
|
227
|
+
> **Elasticsearch:** Returns indices with `documentCount` from one `/_cat/indices?h=index,docs.count&expand_wildcards=all` request (open and closed indices alike). The count is primaries-only, so a replicated index no longer reports its replica copies as extra documents. Aliases are tagged separately. System indices (names starting with `.`) are hidden unless `--include-system` is passed.
|
|
225
228
|
|
|
226
229
|
### schema
|
|
227
230
|
|
|
@@ -243,6 +246,13 @@ dbcli schema --use prod # Scan prod DB; saves to .dbcli/schemas/prod
|
|
|
243
246
|
**Options:** `--format <table|json>`, `--refresh`, `--reset`, `--force`, `--use <connection>`, `--sample-size <n>` (mongo only), `--sample-method <random|natural>` (mongo only)
|
|
244
247
|
**Permission:** query-only+
|
|
245
248
|
|
|
249
|
+
> **Row counts on a full scan:** scanning every table records
|
|
250
|
+
> `rowCountIsEstimate: true` and reports the engine's row *estimate* (`information_schema.TABLES.TABLE_ROWS` on MySQL/MariaDB,
|
|
251
|
+
> `pg_class.reltuples` on PostgreSQL) rather than running `COUNT(*)` per table —
|
|
252
|
+
> a hundred full-table counts is what made scanning a large database unusable.
|
|
253
|
+
> `dbcli schema <table>` on a single table still reports the exact count. Tables
|
|
254
|
+
> are scanned with bounded parallelism (4 at a time).
|
|
255
|
+
|
|
246
256
|
**Schema storage (v1.4+):** Schema is persisted as layered files under `.dbcli/schemas/`. With v2 multi-connection config each connection gets its own subdirectory (`.dbcli/schemas/<connection>/`). Run `dbcli schema --use <connection>` once per connection before querying it — otherwise `schema <table>` may return data from the wrong connection's cache.
|
|
247
257
|
|
|
248
258
|
> **PostgreSQL:** Introspection uses the exact `public` catalog identity throughout. Full catalog/schema/table joins prevent a reused constraint name from contaminating another table; enum lookup includes its namespace; composite primary-key order comes from the exact table OID and index ordinality; and row estimates are scoped to the exact `public` relation. Row-count SQL qualifies and quotes both `"public"` and the exact table identifier, escaping embedded quotes so mixed-case or punctuation-bearing names remain distinct and safe.
|
|
@@ -286,6 +296,12 @@ dbcli query "SELECT * FROM orders" --format html > orders.html # pipe to stdou
|
|
|
286
296
|
**Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--fields <list>`, `--truncate <number>` / `--no-truncate`, `-f, --query-file <path>`, `--use <name[,name]>`, `--slow-ms <number>`, `--recovery`
|
|
287
297
|
**Permission:** query-only+ (Redis: per-command; Elasticsearch: per HTTP method/path)
|
|
288
298
|
|
|
299
|
+
> **Server-side scripts are rejected on every path.** MongoDB `$where`,
|
|
300
|
+
> `$function`, and `$accumulator`, and Elasticsearch `script` / `script_fields`,
|
|
301
|
+
> execute code on the database server. The adapters reject them anywhere in a
|
|
302
|
+
> filter, pipeline, or DSL body — before the request is sent — so `query`, `q`,
|
|
303
|
+
> saved snippets, and DML planning all behave the same way.
|
|
304
|
+
|
|
289
305
|
#### Passive slow-query hint (`--slow-ms`)
|
|
290
306
|
|
|
291
307
|
`query` and `q` read the execution time they already measured for a finished
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ All notable changes to dbcli are documented here.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.54.0] - 2026-08-13 - Query engine hardening: timeout semantics, load-on-demand, deterministic builds
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Separate connection and statement timeouts.** `--timeout` previously did two jobs at once: PostgreSQL fed it to both `connectionTimeoutMillis` and `statement_timeout`, so the 5000ms connection default silently became a global query ceiling, while MySQL consumed neither and ignored `--timeout` entirely. Connection timeout keeps its 5000ms built-in default, statement timeout now has none (the server decides) unless you ask for one, and the new root-level `--statement-timeout <ms>` plus the `statementTimeout` connection field (0–3600000, `0` removes the ceiling) adjust it on its own. MySQL now consumes both, mapping the statement limit onto session-level `max_execution_time` / `max_statement_time` where the server supports it.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **The CLI loads what a command actually needs.** Subcommands register lazily, SQL drivers load at connection time rather than at import, and `node-sql-parser` is both deferred and externalized from the bundle — measured at roughly 8ms off startup for the lazy registration alone.
|
|
17
|
+
- **Full-schema scans cost less.** Per-table queries are merged, row estimates replace `COUNT(*)`, and remaining work runs with bounded parallelism. The query path no longer loads the layered schema in full — it fetches the single table it needs.
|
|
18
|
+
- **Repeated lookups are cached within a process.** Config binding files are read and validated once per process, and the skill update check keeps a TTL cache instead of re-checking on every invocation. Redis and Elasticsearch list operations were narrowed to what the caller asked for.
|
|
19
|
+
- **Identifier quoting and error classification each have one implementation.** Quote/encode helpers were consolidated into a shared utility, and driver errors are now classified by error code first rather than by matching message text.
|
|
20
|
+
- **Server-side script protection lives in the adapter layer**, so every caller is covered by the same guard rather than each command re-implementing it.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- **`bun run build` was non-deterministic.** Consecutive builds of identical sources alternated between two `dist/cli-runtime.mjs` outputs about 690KB apart, depending on whether the bundler pulled in 48 `@inquirer/*` modules. `@inquirer/prompts` is now external, which also removes a silent degradation path where the prompt implementation quietly changed between builds. `bun run build:determinism` checks this in CI.
|
|
25
|
+
- **One CLI query writes exactly one audit entry.** Some paths recorded the same query more than once.
|
|
26
|
+
- **Windows CI is green again.** Path separator assumptions, CRLF handling in test fixtures, and CRLF frontmatter stripping in skill sources were all Unix-only.
|
|
27
|
+
- **The startup benchmark measures the noise floor rather than the median**, which is what actually distinguishes a regression from scheduler jitter, and a guide test no longer flakes on a random UUID colliding with `'5432'`.
|
|
28
|
+
|
|
8
29
|
## [1.53.0] - 2026-08-09 - Offline evidence, semantic contracts, and impact assessment
|
|
9
30
|
|
|
10
31
|
### Added
|
package/assets/SKILL.md
CHANGED
|
@@ -605,4 +605,4 @@ schema. Raw `query` / `export` invocations render a sortable table only.
|
|
|
605
605
|
- Blacklisted tables and columns are redacted from query output.
|
|
606
606
|
- `schema` reports `estimatedRowCount` and `sizeCategory` (small / medium / large / huge). For large/huge tables add `WHERE` or `LIMIT` — bands in [reference.md](reference.md#schema).
|
|
607
607
|
- `doctor` on `mongodb+srv://` reports whether SRV resolves natively or through the DoH fallback — useful when the runtime restricts DNS.
|
|
608
|
-
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `--timeout <ms>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
|
608
|
+
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `--timeout <ms>`, `--statement-timeout <ms>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
package/assets/SKILL.zh-TW.md
CHANGED
|
@@ -472,4 +472,4 @@ dbcli export "SELECT * FROM orders" --format html --output orders.html
|
|
|
472
472
|
- 被 blacklist 的 table / column 會從查詢輸出中遮蔽。
|
|
473
473
|
- `schema` 回報 `estimatedRowCount` 與 `sizeCategory`(small / medium / large / huge)。大 / 巨大表要加 `WHERE` 或 `LIMIT` — 分界值見 [reference.md](reference.md#schema)。
|
|
474
474
|
- 對 `mongodb+srv://` 連線,`doctor` 會回報 SRV 是用原生解析或走 DoH fallback — 在執行環境限制 DNS 時很有用。
|
|
475
|
-
- **全域旗標:** `--version`、`--config <path>`、`--global`、`--use <name>`、`--timeout <ms>`、`-v` / `--verbose` / `-vv`、`-q` / `--quiet`、`--no-color`(也尊重 `NO_COLOR`)。除非指令明確宣告 command-level 選項,否則 root-level 旗標必須放在指令之前。
|
|
475
|
+
- **全域旗標:** `--version`、`--config <path>`、`--global`、`--use <name>`、`--timeout <ms>`、`--statement-timeout <ms>`、`-v` / `--verbose` / `-vv`、`-q` / `--quiet`、`--no-color`(也尊重 `NO_COLOR`)。除非指令明確宣告 command-level 選項,否則 root-level 旗標必須放在指令之前。
|
package/assets/reference.md
CHANGED
|
@@ -83,13 +83,16 @@ command-level option is only valid after the command that declares it.
|
|
|
83
83
|
| `--global` | Select the user-global registry at `~/.config/dbcli/config.json` instead of the current project's `.dbcli` config. Place it before the command path. |
|
|
84
84
|
| `--use <connection>` | Select a named connection for this invocation; place it before the command path unless that command explicitly lists a command-level `--use`. |
|
|
85
85
|
| `--timeout <ms>` | Connection timeout in milliseconds (integer, 100–600000), overriding the connection config's `timeout` field for this invocation. Applies to every engine adapter. Without either the flag or the config field, adapters fall back to their built-in 5000ms default. |
|
|
86
|
+
| `--statement-timeout <ms>` | How long a single statement may run, in milliseconds (integer, 0–3600000; `0` removes the limit), overriding the connection config's `statementTimeout` field. Independent of the connection timeout — raising it does not slow down detection of an unreachable host. Falls back to `--timeout` when unset, and to the server's own setting when neither is given. |
|
|
86
87
|
|
|
87
88
|
`--timeout` is applied only when the adapter is constructed for this invocation — it is
|
|
88
89
|
never written back to `config.json`. Set the connection's `timeout` field instead for a
|
|
89
|
-
value that persists across runs.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
value that persists across runs. `--timeout` caps statement time as well as connection time, so a
|
|
91
|
+
low value cuts off a long-running query with an error that reads like a connection
|
|
92
|
+
problem; the 100ms floor exists specifically to keep that failure mode from being too
|
|
93
|
+
easy to trigger. Use `--statement-timeout` when only the statement limit should change.
|
|
94
|
+
With neither flag, dbcli sets no statement limit at all — the server's setting decides,
|
|
95
|
+
so a query that runs longer than the connection timeout is no longer cut off.
|
|
93
96
|
Elasticsearch applies its timeout per request rather than once for the whole connection.
|
|
94
97
|
The `timeout` field itself always takes a literal number — unlike other connection
|
|
95
98
|
fields, it does not accept an `{"$env": "..."}` reference.
|
|
@@ -220,8 +223,8 @@ dbcli list --include-system # Elasticsearch: include `.system` indices
|
|
|
220
223
|
**Permission:** query-only+
|
|
221
224
|
|
|
222
225
|
> **MongoDB:** Lists collections with estimated document count.
|
|
223
|
-
> **Redis:**
|
|
224
|
-
> **Elasticsearch:** Returns indices with `documentCount` from `/
|
|
226
|
+
> **Redis:** Samples the first 1 000 keys scanned via `SCAN MATCH * COUNT 1000`, applying the blacklist during the scan. When the keyspace is larger, table output adds a `Sampled the first 1000 keys scanned` line and JSON output carries `sampled: true` with `sampleLimit`. The header reads `Keys in db <n> (redis):` where `<n>` is the logical DB index.
|
|
227
|
+
> **Elasticsearch:** Returns indices with `documentCount` from one `/_cat/indices?h=index,docs.count&expand_wildcards=all` request (open and closed indices alike). The count is primaries-only, so a replicated index no longer reports its replica copies as extra documents. Aliases are tagged separately. System indices (names starting with `.`) are hidden unless `--include-system` is passed.
|
|
225
228
|
|
|
226
229
|
### schema
|
|
227
230
|
|
|
@@ -243,6 +246,13 @@ dbcli schema --use prod # Scan prod DB; saves to .dbcli/schemas/prod
|
|
|
243
246
|
**Options:** `--format <table|json>`, `--refresh`, `--reset`, `--force`, `--use <connection>`, `--sample-size <n>` (mongo only), `--sample-method <random|natural>` (mongo only)
|
|
244
247
|
**Permission:** query-only+
|
|
245
248
|
|
|
249
|
+
> **Row counts on a full scan:** scanning every table records
|
|
250
|
+
> `rowCountIsEstimate: true` and reports the engine's row *estimate* (`information_schema.TABLES.TABLE_ROWS` on MySQL/MariaDB,
|
|
251
|
+
> `pg_class.reltuples` on PostgreSQL) rather than running `COUNT(*)` per table —
|
|
252
|
+
> a hundred full-table counts is what made scanning a large database unusable.
|
|
253
|
+
> `dbcli schema <table>` on a single table still reports the exact count. Tables
|
|
254
|
+
> are scanned with bounded parallelism (4 at a time).
|
|
255
|
+
|
|
246
256
|
**Schema storage (v1.4+):** Schema is persisted as layered files under `.dbcli/schemas/`. With v2 multi-connection config each connection gets its own subdirectory (`.dbcli/schemas/<connection>/`). Run `dbcli schema --use <connection>` once per connection before querying it — otherwise `schema <table>` may return data from the wrong connection's cache.
|
|
247
257
|
|
|
248
258
|
> **PostgreSQL:** Introspection uses the exact `public` catalog identity throughout. Full catalog/schema/table joins prevent a reused constraint name from contaminating another table; enum lookup includes its namespace; composite primary-key order comes from the exact table OID and index ordinality; and row estimates are scoped to the exact `public` relation. Row-count SQL qualifies and quotes both `"public"` and the exact table identifier, escaping embedded quotes so mixed-case or punctuation-bearing names remain distinct and safe.
|
|
@@ -286,6 +296,12 @@ dbcli query "SELECT * FROM orders" --format html > orders.html # pipe to stdou
|
|
|
286
296
|
**Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--fields <list>`, `--truncate <number>` / `--no-truncate`, `-f, --query-file <path>`, `--use <name[,name]>`, `--slow-ms <number>`, `--recovery`
|
|
287
297
|
**Permission:** query-only+ (Redis: per-command; Elasticsearch: per HTTP method/path)
|
|
288
298
|
|
|
299
|
+
> **Server-side scripts are rejected on every path.** MongoDB `$where`,
|
|
300
|
+
> `$function`, and `$accumulator`, and Elasticsearch `script` / `script_fields`,
|
|
301
|
+
> execute code on the database server. The adapters reject them anywhere in a
|
|
302
|
+
> filter, pipeline, or DSL body — before the request is sent — so `query`, `q`,
|
|
303
|
+
> saved snippets, and DML planning all behave the same way.
|
|
304
|
+
|
|
289
305
|
#### Passive slow-query hint (`--slow-ms`)
|
|
290
306
|
|
|
291
307
|
`query` and `q` read the execution time they already measured for a finished
|