@@ -7,11 +7,22 @@ put into postgresql conf.
7
7
8
8
On success, starts database
9
9
"""
10
- import os ,sys ,subprocess ,glob ,re ,os .path ,time
10
+ import os ,sys ,subprocess ,glob ,re ,os .path ,time , re
11
11
12
12
if len (sys .argv )!= 2 :
13
13
print >> sys .stderr ,"Usage %s data-directory" % sys .argv [0 ]
14
14
sys .exit (1 )
15
+
16
+ def prepare_extlist (value ):
17
+ v = re .sub ("[']" , '' , value )
18
+ l = re .split ("\s*,\s*" ,v )
19
+ if "pg_pathman" in l :
20
+ # remove duplicates and reorder extension list to move pg_pathman to tail
21
+ nl = sorted (list (set (l )), cmp = lambda a ,b : 1 if a == "pg_pathman" else - 1 )
22
+ new_value = "'{}'" .format ("," .join (nl ))
23
+ return new_value
24
+ else :
25
+ return value
15
26
16
27
datadir = sys .argv [1 ]
17
28
@@ -27,7 +38,7 @@ if exitcode:
27
38
sys .exit (exitcode )
28
39
# Collect extra config option
29
40
addopts = {}
30
- for module in sorted ( glob .glob ("contrib/*" ), cmp = lambda a , b : 1 if a == "pg_pathman" else - 1 ):
41
+ for module in glob .glob ("contrib/*" ):
31
42
if not os .path .isdir (module ):
32
43
continue
33
44
if not os .access (module + "/Makefile" ,os .R_OK ):
@@ -59,7 +70,7 @@ for module in sorted(glob.glob("contrib/*"), cmp = lambda a,b: 1 if a=="pg_pathm
59
70
if addopts :
60
71
with open (datadir + "/postgresql.conf" ,"a" ) as f :
61
72
for opt ,value in addopts .items ():
62
- print >> f ,"%s=%s" % (opt ,value )
73
+ print >> f ,"%s=%s" % (opt ,prepare_extlist ( value ) )
63
74
with open ("initdb.log" ,"a" ) as f :
64
75
exitcode = subprocess .call (["pg_ctl" ,"start" ,"-D" ,datadir ,"-l" ,datadir + "/postmaster.log" ],env = env ,stdout = f ,stderr = subprocess .STDOUT )
65
76
if exitcode :
@@ -73,5 +84,3 @@ while time.time() < failtime:
73
84
sys .exit (0 )
74
85
print >> sys .stderr ,"Database havent't started in 60 seconds"
75
86
sys .exit (1 )
76
-
77
-
0 commit comments