Lists: | pgsql-hackers |
---|
From: | "Colin 't Hart" <colin(at)sharpheart(dot)org> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | [PATCH] Add \ns command to psql |
Date: | 2013-04-16 09:40:16 |
Message-ID: | CAMon-aS+8P9EVCDVMJfECQvxRzb59Adfab_ts_M7LaRECOetfA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
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'd like to make a case for including this patch as it makes use of
schemas/namespaces much easier. There was resistance to including this
before just because some developers don't use schemas very much. But
we use a lot of them. And I'm sure we're not alone.
Previously I used just \n but there was some resistance to this
because the single letter commands are becoming scarce.
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).
Cheers,
Colin
Attachment | Content-Type | Size |
---|---|---|
command.c.diff | application/octet-stream | 1.6 KB |
tab-complete.c.diff | application/octet-stream | 655 bytes |
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 |
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