RFC: Adding \history [options] [filename] to psql (Snippets and Shared Queries)

From: Kirk Wolak <wolakk(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RFC: Adding \history [options] [filename] to psql (Snippets and Shared Queries)
Date: 2023-06-05 15:50:04
Message-ID: CACLU5mRCnk4BjcT+R-vV-9A4GWU_+neine95QSf9mD47QP5QTA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Everyone,
After recently deep diving on some readline features and optimizing my
bash environment to have a static set of "snippets" that I can always
find...

it takes just a couple of history API calls to add some interesting
features for those that want them. The result of adding 3-4 such commands
(all under \history, and with compatible flags):

- Saving your current history without exiting (currently doable as \s
:HISTFILE)
- Reloading your history file (so you can easily share something across
sessions) w/o exiting.
- Stack Loading of specific history (like a shared snippets library, and a
personal snippets library) [clearing your history, then loading them in a
custom order]

The upside is really about clearly identifying and sharing permanent
snippets, while having that list be editable externally. Again, bringing
teams online who don't always know the PG way of doing things (Waits,
Locks, Space, High CPU queries, Running Queries).

My intention is to leverage the way PSQL keeps the Comment above the SQL
with the SQL.
Then I can step backwards searching for "context" markers (Ctrl-R) or
-- <CONTEXT> [F8] {history-search-backward}

To rip through my snippets

Kirk...
PS: I could do all of this under \s [options] [filename] it's just less
clear...

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2023-06-05 16:00:34 Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG
Previous Message Heikki Linnakangas 2023-06-05 15:43:54 Re: Let's make PostgreSQL multi-threaded