[PATCH] Add \ns command to psql
[PATCH] Add \ns command to psql
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
Re: [PATCH] Add \ns command to psql
От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Tue, Apr 16, 2013 at 5:40 AM, Colin 't Hart 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 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 is eight keystrokes, where \ns 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