File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ Features:
99
1010- Xapian indexing improved: Slightly faster and slightly smaller database.
1111 Closes issue2550687. Thanks to Olly Betts for the patch. (Bernhard Reiter)
12+ - PostgreSQL backend minor improvement: database creation less likely to fail
13+ for PostgreSQL versions >= 8.1 as the table "postgres" is used by default.
14+ Closes issue2550543. Thanks to Kai Storbeck for the patch. (Bernhard Reiter)
1215
1316Fixed:
1417
Original file line number Diff line number Diff line change @@ -50,16 +50,22 @@ def db_nuke(config, fail_ok=0):
5050 if os .path .exists (config .DATABASE ):
5151 shutil .rmtree (config .DATABASE )
5252
53- def db_command (config , command ):
53+ def db_command (config , command , database = 'postgres' ):
5454 '''Perform some sort of database-level command. Retry 10 times if we
5555 fail by conflicting with another user.
56+
57+ Since PostgreSQL version 8.1 there is a database "postgres",
58+ before "template1" seems to habe been used, so we fall back to it.
59+ Compare to issue2550543.
5660 '''
5761 template1 = connection_dict (config )
58- template1 ['database' ] = 'template1'
62+ template1 ['database' ] = database
5963
6064 try :
6165 conn = psycopg .connect (** template1 )
6266 except psycopg .OperationalError , message :
67+ if str (message ).find ('database "postgres" does not exist' ) >= 0 :
68+ return db_command (config , command , database = 'template1' )
6369 raise hyperdb .DatabaseError (message )
6470
6571 conn .set_isolation_level (0 )
You can’t perform that action at this time.
0 commit comments