postgresql: use postgres db instead of template1
In PostgreSQL template1 database is kind of special, as all new databases are
copied from it, when you do CREATE DATABASE. This implies a few restrictions:
e.g. you can't have more than one active session to template1, if one of them
tries to create a database. It will fail with:
ERROR: source database "template1" is being accessed by other users
Using of postgres database instead of template1 resolves this issue.
Closes-Bug: #1355929
Change-Id: I8b1a36163984fbef6be66964456072d32da6a9d0
(cherry picked from commit 02fa15b4ca
)
This commit is contained in:
parent
74128f7b2b
commit
98a6c1e4c4
|
@ -260,9 +260,9 @@ class BaseMigrationTestCase(test.NoDBTestCase):
|
|||
os.environ['PGUSER'] = user
|
||||
# note(boris-42): We must create and drop database, we can't
|
||||
# drop database which we have connected to, so for such
|
||||
# operations there is a special database template1.
|
||||
# operations there is a special database postgres.
|
||||
sqlcmd = ("psql -w -U %(user)s -h %(host)s -c"
|
||||
" '%(sql)s' -d template1")
|
||||
" '%(sql)s' -d postgres")
|
||||
sqldict = {'user': user, 'host': host}
|
||||
|
||||
sqldict['sql'] = ("drop database if exists %s;") % database
|
||||
|
@ -325,7 +325,7 @@ class BaseMigrationTestCase(test.NoDBTestCase):
|
|||
os.environ['PGUSER'] = user
|
||||
|
||||
sqlcmd = ("psql -w -U %(user)s -h %(host)s -c"
|
||||
" '%(sql)s' -d template1")
|
||||
" '%(sql)s' -d postgres")
|
||||
|
||||
sql = ("create database if not exists %s;") % database
|
||||
createtable = sqlcmd % {'user': user, 'host': host, 'sql': sql}
|
||||
|
|
Loading…
Reference in New Issue