Re: [PATCH] Add \ns command to psql

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: "Colin 't Hart" <colin(at)sharpheart(dot)org>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add \ns command to psql
Date: 2013-04-17 22:58:47
Message-ID: CA+TgmobNjnpZUDH_Hihu6L7V9S3wHqC9ujF8YK5aF8mnNrZMLQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 16, 2013 at 5:40 AM, Colin 't Hart <colin(at)sharpheart(dot)org> wrote:
> Here's a new version of a small patch to psql I'm using locally.
>
> It adds a command \ns to psql which is a shortcut to set the
> SEARCH_PATH variable.
>
> I've also added tab completion making this command much more useful. I
> don't think tab completition would be possible if this command was
> defined as a variable (which was another suggestion offered at the
> time).

It's possible that the tab completion argument is a sufficient reason
for including this, but I'm kinda skeptical. The amount of typing
saved is pretty minimal, considering that set sea<tab> completes to
set search_path. Assuming we had proper tab completion for set
search_path = (and off-hand, it doesn't look like that does anything
useful), this would be saving 5 keystrokes every time you want to
change the search path (set sea<tab> is eight keystrokes, where
\ns<space> is four... but it also saves you the semicolon at the end).
I'm sure some people would find that worthwhile, but personally, I
don't. Short commands are cryptic, and IMHO psql is already an
impenetrable thicket of difficult-to-remember abbreviations. I've
been using it for more than 10 years now and I still have to to run \?
on a semi-regular basis. I think that if we start adding things like
this, that help message is going to rapidly fill up with a whole lot
more abbreviations for things that are quite a bit incrementally less
useful than what's there right now.

After all, if we're going to have \ns to set the search path, why not
have something similar for work_mem, or random_page_cost? I set both
of those variables more often than I set search_path; and there could
easily be someone else out there whose favorite GUC is client_encoding
or whatever. And, for that matter, why stop with GUCs? \ct for
CREATE TABLE would save lots of typing, too....

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Pflug 2013-04-17 23:09:23 Re: Enabling Checksums
Previous Message Tom Lane 2013-04-17 22:32:05 Re: Enabling Checksums