Re: psql command aliases support

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Bernd Helmle" <mailings(at)oopsware(dot)de>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, <pgsql-patches(at)postgresql(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: psql command aliases support
Date: 2008-04-03 16:09:49
Message-ID: 87abkahqcy.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

"Bernd Helmle" <mailings(at)oopsware(dot)de> writes:

> --On Donnerstag, April 03, 2008 14:36:59 +0100 Gregory Stark
> <stark(at)enterprisedb(dot)com> wrote:
>
>>> \o foo instead of \i foo -- check your keyboard layout
>>
>> The point is here you've typed a different command entirely.
>> Unsurprisingly it's going to do something different.
>
> Uh well, you surely don't know that if you accidently hit o instead of i....one
> reason more for an alias \output and \input ;)
>
> To be serious, i take your point, but i'm under the impression that you simply
> can't safe the user against all mistakes they are going to make ever. Your
> concerns apply to every existing alias implementation as well and you aren't
> safe against decisions of your distributor to add conflicting aliases to their
> default bashrc as well.

I think I'm not managing to express myself clearly here. Generalizing the
complaint into simply "if you typo something different happens" is losing too
much information.

With shell aliases if you typo "foo" into "bar" then, yes, something different
will happen than what you expected. However the new behaviour will still be of
the same "kind" -- that is it runs a shell command, just the wrong shell
command. If there's no command by that name you get an error not some
unrelated shell functionality.

In the proposed alias syntax if you typo \cold into \coldd it will print a
mysterious error about trying to connect to a database or if you typo \old
into \oldd it will write out a file and stop printing query output. The user
might not even realize that \c and \o are commands since they think they're
running commands \colld and \oldd.

I think you have to find a syntax where the current commands continue to mean
exactly what they always meant and where typos can't result in an entirely
different kind of behaviour.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's 24x7 Postgres support!

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Brendan Jurd 2008-04-03 16:10:26 Re: printTable API (was: Show INHERIT in \du)
Previous Message Bruce Momjian 2008-04-03 16:07:54 Re: psql \G command -- send query and output using extended format