[PATCH] Add support to psql for edit-and-execute-command

From: "Joe Wildish" <joe(at)lateraljoin(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [PATCH] Add support to psql for edit-and-execute-command
Date: 2020-05-17 23:29:56
Message-ID: F2CCADF3-B70D-4821-B244-181F3C00FA6A@lateraljoin.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

Attached is a small patch for adding "edit-and-execute-command" readline
support to psql. Bash has this concept and I miss it when using psql. It
allows you to amend the current line in an editor by pressing "v" (when
in vi mode) or "C-x C-e" (when in emacs mode). Those are the default
bindings from bash although of course they can be amended in inputrc.

Most of the patch is actually shifting "do_edit" from "command.c" to
"common.c". There is a small amendment to that function to allow vi to
launch at the correct column offset.

I noticed that there is some logic in configure for detecting certain
readline functions. I assume this is for compatibility sake with
libedit/editline? Rather than testing for each rl_* function I hid the
functionality behind HAVE_READLINE_READLINE_H .. don't know if this is
acceptable?

-Joe

Attachment Content-Type Size
0001-Add-support-to-psql-for-edit-and-execute-command.patch text/plain 19.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-05-18 04:48:01 Re: Parallel copy
Previous Message Pavel Borisov 2020-05-17 19:53:21 Re: [PATCH] fix GIN index search sometimes losing results