BUG #15002: Unexpected behaviour in psql \r command

Started by PG Bug reporting formover 8 years ago3 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 15002
Logged by: Petr Korobeinikov
Email address: pkorobeinikov@gmail.com
PostgreSQL version: 10.0
Operating system: Any (reproduced in macOS Sierra, Slackware)
Description:

Dear hackers!

Unexpected behaviour of \r subcommand has been introduced in 10.0
(e984ef5861df4bc9733b36271d05763e82de7c04).

Previously (at least in 9.6) previous_buf hasn’t been used for any kinds of
\e subcommand.
Now if query_buf is empty previous buffer contents is used.

It makes useless \r subcommand in cases when clean buffer required in next
\e.
Multiple calls of \r takes no effect.

Code snippet:
```
794 +
795 + /* Applies to previous query if current buffer is empty
*/
796 + copy_previous_query(query_buf, previous_buf);
797 +
798 if (do_edit(fname, query_buf, lineno, NULL))
799 status = PSQL_CMD_NEWEDIT;
```

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: PG Bug reporting form (#1)
Re: BUG #15002: Unexpected behaviour in psql \r command

On Tue, Jan 9, 2018 at 10:45 AM, PG Bug reporting form <
noreply@postgresql.org> wrote:

Previously (at least in 9.6) previous_buf hasn’t been used for any kinds of
\e subcommand.
Now if query_buf is empty previous buffer contents is used.

​IIUC the complaint is that it is no longer possible to use \edit​ to
generate a completely empty temporary query that can then be written from
scratch.

The v10 behavior is desirable so that leaves either learning a new idiom to
accomplish your goal or adding something like "\edit -" to explicitly
invoke the desired behavior.

Doing:

# SELECT <enter>
# \edit

Seems reasonably straight forward to get a editor for a newly query instead
of the previous one.

David J.

#3Petr Korobeinikov
pkorobeinikov@gmail.com
In reply to: David G. Johnston (#2)
Re: BUG #15002: Unexpected behaviour in psql \r command

In this case \r subcommand seems to be completely useless.
It does absolutely nothing.

2018-01-09 20:58 GMT+03:00 David G. Johnston <david.g.johnston@gmail.com>:

Show quoted text

On Tue, Jan 9, 2018 at 10:45 AM, PG Bug reporting form <
noreply@postgresql.org> wrote:

Previously (at least in 9.6) previous_buf hasn’t been used for any kinds
of
\e subcommand.
Now if query_buf is empty previous buffer contents is used.

​IIUC the complaint is that it is no longer possible to use \edit​ to
generate a completely empty temporary query that can then be written from
scratch.

The v10 behavior is desirable so that leaves either learning a new idiom
to accomplish your goal or adding something like "\edit -" to explicitly
invoke the desired behavior.

Doing:

# SELECT <enter>
# \edit

Seems reasonably straight forward to get a editor for a newly query
instead of the previous one.

David J.