Re: psql: tab completion differs on semicolon placement

From: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: psql: tab completion differs on semicolon placement
Date: 2021-09-20 19:26:51
Message-ID: 87wnnbt5dw.fsf@wibble.ilmari.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Daniel Gustafsson <daniel(at)yesql(dot)se> writes:

> While testing a patch I fat-fingered a CREATE DATABASE statement by tab
> completing *after* the semicolon, with no space between the objname and
> semicolon. The below options were presented, which at this point aren't really
> applicable:
>
> db=# create database foo;
> ALLOW_CONNECTIONS ENCODING LC_COLLATE LOCALE TABLESPACE
> CONNECTION LIMIT IS_TEMPLATE LC_CTYPE OWNER TEMPLATE
>
> DROP DATABASE has a similar tab completion which makes about as much sense:
>
> db=# drop database foo;WITH (
>
> Checking prev_wd for not ending with ';' as per the attached makes "objname;"
> behave like "objname ;". Is there a reason for not doing that which I'm
> missing? I didn't check for others, but if this seems reasonable I'll go
> through to find any other similar cases.

The same applies to any completion after a MatchAny that ends in a any
of the WORD_BREAKS characters (except whitespace and () which are
handled specially).

#define WORD_BREAKS "\t\n(at)$><=;|&{() "

IMO a fix should be more principled than just special-casing semicolon
and CREATE TABLE. Maybe get_previous_words() should stop when it sees
an unquoted semicolon?

- ilmari

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-09-20 19:48:56 Re: postgres.h included from relcache.h - but removing it breaks pg_upgrade
Previous Message Marcos Pegoraro 2021-09-20 16:16:39 logical replication restrictions