Skip to content

feat: named saved queries + lazy connection pool (0.17.0)#56

Merged
killertux merged 1 commit into
mainfrom
feat/saved-queries-and-lazy-pool
May 26, 2026
Merged

feat: named saved queries + lazy connection pool (0.17.0)#56
killertux merged 1 commit into
mainfrom
feat/saved-queries-and-lazy-pool

Conversation

@killertux
Copy link
Copy Markdown
Owner

Summary

  • New per-connection named queries: :save <name>, :load <name> (inserts at cursor), :run-saved [name] (bare form opens a picker overlay). Stored as one .sql file per query under <data_dir>/queries/<conn>/<name>.sql. Overwrite confirms via an Enter/Esc bottom-bar prompt; placeholders still bounce through the existing params popup because :run-saved dispatches through query::dispatch_query.
  • Lazy connection pools for postgres + mysql: connect_lazy + min_connections(0) + idle_timeout(60s). The pinned session conn is now held only while a transaction is open — transitions are derived from sqlparser (BEGIN/COMMIT/ROLLBACK). :reset swaps in a fresh pool and close()s the old one to force-disconnect every backend. SQLite gets the same tx-aware session release but keeps its pool intact so :memory: databases don't evaporate.
  • Bump to 0.17.0 (minor — user-facing new commands).

Test plan

  • cargo fmt && cargo clippy --all-targets -- -D warnings && cargo test (619 tests pass locally)
  • Manual: connect to a sqlite :memory: connection, :save smoke with a SELECT 1 WHERE x = :id; in the buffer, :run-saved smoke and verify the params prompt fires
  • Manual: :run-saved (no name) → picker opens; Enter dispatches; Esc closes
  • Manual: :save smoke again → overwrite confirm overlay; test both Enter and Esc
  • Manual (postgres): BEGIN; SELECT 1; then idle 70s — backend should be dropped (check pg_stat_activity); :reset after BEGIN force-kills the session backend

- Add :save / :load / :run-saved commands for per-connection named
  queries persisted under <data_dir>/queries/<conn>/<name>.sql. :load
  inserts at the cursor; :run-saved [name] reuses the existing query
  pipeline so placeholder prompts still fire. Bare :run-saved opens
  an overlay picker.
- Switch postgres + mysql pools to connect_lazy with min_connections(0)
  and idle_timeout(60s), and only pin a session connection while a
  transaction is open (tx state derived via sqlparser). :reset now
  closes and rebuilds the pool to force-drop every backend connection.
  Sqlite keeps the same tx-aware release but no idle-timeout (would
  drop :memory: data).
- Bump to 0.17.0.
@killertux killertux merged commit eff569e into main May 26, 2026
3 checks passed
@killertux killertux deleted the feat/saved-queries-and-lazy-pool branch May 26, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant