"Peter Eisentraut" <[EMAIL PROTECTED]> writes:

> This is a valid concern, but it is orthogonal to the alias feature.  You have 
> the same problem already if you mistype
> \oo instead of \o
> \ofoo instead of \obar

Not really. In these cases you know what \o is going to do, you've just typo'd
the filename. The case I was saying was a "conflict" was because you were
using an entirely different feature and might not never have even met \o.

> \o instead of \p
> \oset instead of \pset

Sure, if you typo \o instead of select * from pg_class you might be surprised
too. You can't protect against typing an entirely different command than
intended. At least you can then go look up what \o does and figure out what

If you type \ofoo instead of \obar I think there's a big difference between
having it accidentally do what you wanted it to do but to the wrong file and
having it do something entirely unrelated to what you intended and end up
overwriting a file instead of run a simple select.

> or even more amusingly
> \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.

\old means something *today*. In the proposed syntax by creating the alias
you're changing what it means. You're not changing other \ofoo arguments
though which is where the possibility for confusion arises.

Consider instead if Debian decided to include a convenient \deb alias for a
select query against the package repository. Now if I happen to have an "eb"
table I will be surprised when \deb doesn't work.

And lengthening the alias doesn't really help (aside from defeating the
purpose of having aliases). If they define \debian they would still be
interfering if I should have a table named "ebian".

As rule of thumb, I think if you try to execute an alias which doesn't exist,
you should get an "alias does not exist" command. You should not get an
"Invalid command" nor "Did not find relation" and certainly not some random
command you've never met before being run reading or overwriting random files.

I repeat my suggestion of having a \query command so you could do:

\setquery deb select * from debian_packages where packagename like :1
\setquery bbdb select * from bbdb where name like :1

\query deb postgres
\query bbdb peter

to run a saved query. I'm not attached to "setquery" though.

  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's RemoteDBA services!

Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:

Reply via email to