Re: initdb createuser commands

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: initdb createuser commands
Дата
Msg-id bd6bd275-529e-464c-8989-79a6c184ccdf@mm
обсуждение исходный текст
Ответ на Re: initdb createuser commands  (Samuel Williams <space.ship.traveller@gmail.com>)
Ответы Re: initdb createuser commands  (Samuel Williams <space.ship.traveller@gmail.com>)
Список pgsql-general
    Samuel Williams wrote:

> John - that's an interesting example. If it's that easy, why isn't
> that the approach given in tutorials and other documentation? What was
> the motivation for the createuser command?

initdb, createdb and createuser existed even before Postgres
adopted SQL, back when it was developed by the University of
Berkeley.

You can find references to these commands in the doc here:
http://db.cs.berkeley.edu/postgres-v4r2/postgres-setup.ps
which dates back from 1994.
(fun fact: there was no psql yet, the equivalent command was called
"monitor". How about that for a name that has seemingly nothing
to do with postgres? :)

According to these old instructions, commands are installed
by default into /usr/local/postgres/bin,
so that was their namespace. They were not supposed to be mixed
with other non-postgres commands.

That's still the case today if you run ./configure and
"make install" from the current postgresql sources:
these commands end up in /usr/local/pgsql/bin
Some installers such as the EDB installers for Windows or Unix
typically use a dedicated directory for PostgreSQL, so again its
commands don't get mixed with other stuff.

As for the Postgresql pre-compiled packages that come with Linux
distributions, they need to respect the policy of their distros,
meaning that all user-callable commands should be in the default $PATH.
That implies that, for instance, postgresql's "createuser" ends up
in $PATH along with the system's "adduser", even though they have
hardly anything to do with each other, so yes, that's somehow
unfortunate.
But these decisions are made by packagers and distributions, not
by the PostgreSQL developers.

Some of these commands are already documented as deprecated,
for example "createlang", which I find in Ubuntu 14.04 /usr/bin:
$ man createlang
      [...]
      Caution
       createlang is deprecated and may be removed in a future PostgreSQL
       release. Direct use of the CREATE EXTENSION command is recommended
       instead.

The same could theorically be done to createuser/dropuser or
createdb/dropdb, but there's the question of whether this would create
more harm that good, because they're much widely used in
existing scripts and tutorials.

Note that in any case your proposal to use "pg" as an
umbrella-command wouldn't fly with these systems because pg is a
pager from the Debian's util-linux package.

$ which pg
/usr/bin/pg

$ man pg
PG(1)                 User Commands
PG(1)

NAME
       pg - browse pagewise through text files

SYNOPSIS
       pg [-number] [-p string] [-cefnrs] [+line] [+/pattern/] [file...]
...

Also, the same Debian/Ubuntu systems don't have initdb or pg_ctl
in the default $PATH, as these commands are superseded
by different distro-specific pg_* commands . This is also
something that should be considered if thinking of unifying
the binaries.


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite


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

Предыдущее
От: Alexander Farber
Дата:
Сообщение: Re: How to optimize SELECT query with multiple CASE statements?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Rows are repeating by the trigger function