Skip to content

Commit e1034d9

Browse files
committed
Fix template1 encoding on debian
1 parent 0daf411 commit e1034d9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

manifests/server/initdb.pp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,21 @@
8080
}
8181
}
8282
}
83+
} elsif $encoding != undef {
84+
# [workaround]
85+
# by default pg_createcluster encoding derived from locale
86+
# but it do does not work by installing postgresql via puppet because puppet
87+
# always override LANG to 'C'
88+
postgresql_psql { "Set template1 encoding to ${encoding}":
89+
command => "UPDATE pg_database
90+
SET datistemplate = FALSE
91+
WHERE datname = 'template1'
92+
;
93+
UPDATE pg_database
94+
SET encoding = pg_char_to_encoding('${encoding}'), datistemplate = TRUE
95+
WHERE datname = 'template1'",
96+
unless => "SELECT datname FROM pg_database WHERE
97+
datname = 'template1' AND pg_encoding_to_char(encoding) = '${encoding}'",
98+
}
8399
}
84100
}

0 commit comments

Comments
 (0)