"M.A. Oude Kotte" <[EMAIL PROTECTED]> 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 ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly