Re: psql command aliases support

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: psql command aliases support
Дата
Msg-id 87myobgiv8.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: psql command aliases support  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: psql command aliases support  (Peter Eisentraut <peter_e@gmx.net>)
Re: psql command aliases support  (Bernd Helmle <mailings@oopsware.de>)
Список pgsql-patches
"Peter Eisentraut" <peter_e@gmx.net> 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
happened.

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!

В списке pgsql-patches по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: [BUGS] BUG #4070: Join more then ~15 tables let postgreSQL produces wrong data
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: psql command aliases support