Remove "FROM" in "DELETE FROM" when using tab-completion

tanghy.fnst@fujitsu.com <tanghy.fnst@fujitsu.com>

From: "tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2021-05-10T05:36:35Z
Lists: pgsql-hackers

Attachments

Hi

When using psql help with SQL commands, I found an inconsistency tab-completion for command "DELETE" as follows.

=# \h de[TAB]
deallocate   declare      delete from

=# \help[TAB]
ABORT                      CLUSTER                    DELETE FROM

=# \help[ENTER]
Available help:
...
ANALYZE                          CREATE OPERATOR CLASS            DELETE
...

=# \h delete
Command:     DELETE
Description: delete rows of a table
...

You see, the tab-completion for "DELETE" is "DELETE FROM" which is not same as help-command said(which is "DELETE").
I tried to figure out why "FROM" is introduced here, but no good result got. In [1] someone changed "DELETE" to "DELETE FROM" but no reason added.

IMO, the "FROM" is unnecessary just like "INTO" for "INSERT" command. So I tried to fix the inconsistency by removing "FROM" from "DELETE FROM" in tab-complete.c.
Please see the attached patch. Any comment or different thought is very welcome.

[1]
https://github.com/postgres/postgres/commit/4c1f9a0f0bb41c31b26bb88ba8c5d3fca4521dd7

Regards,
Tang

Commits

  1. Make saner the tab completion of INSERT and DELETE in psql

  2. psql tab completion improvements, from Greg Sabino Mullane: