Re: psql command aliases support - Mailing list pgsql-patches

From Gregory Stark
Subject Re: psql command aliases support
Date
Msg-id 87abkahqcy.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: psql command aliases support  (Bernd Helmle <mailings@oopsware.de>)
Responses Re: psql command aliases support  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
"Bernd Helmle" <mailings@oopsware.de> writes:

> --On Donnerstag, April 03, 2008 14:36:59 +0100 Gregory Stark
> <stark@enterprisedb.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!

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Configurable Penalty Costs for Levenshtein
Next
From: Alvaro Herrera
Date:
Subject: Re: Re: [BUGS] BUG #4070: Join more then ~15 tables let postgreSQL produces wrong data