Re: Creating database problem

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Creating database problem
Дата
Msg-id 16422.1099063614@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Creating database problem  ("M.A. Oude Kotte" <marc@solcon.nl>)
Список pgsql-general
"M.A. Oude Kotte" <marc@solcon.nl> writes:
> When I try to execute "CREATE DATABASE somename" while connected to
> database template1 as a non-superuser with createdb-rights, I get the
> error message "source database "template1" is being accessed by other
> users". This is correct, as I'm connected to the same server using
> pgAdmin III on a different PC. But my question is, why this error
> message?

It's a locking issue: if the other guy is changing the database while
you copy it, you'd get an inconsistent copy.

The test is not bulletproof, since in theory someone could connect to
the source database after we make the check and alter it underneath us
while the copy is still proceeding.  But it's better than no defense at all.

One possible way to work around the issue is to specify TEMPLATE template0
in CREATE DATABASE; there shouldn't be anybody connected there.

In retrospect it was probably a misfeature that template1 is both the
default database-to-copy and the default database-to-connect-to, but
this usage is so deeply entrenched that no one really wants to change it.

            regards, tom lane

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

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: Question regarding the mailing list.
Следующее
От: "C G"
Дата:
Сообщение: adding missing FROM-clause