+12
-13
lines changedFilter options
+12
-13
lines changed Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
15
15
* Upload files to Azure Blob Storage
16
16
* Add a systemd timer for Debian in the package generated by goreleaser
17
17
* Check the syntax of the configuration file
18
-
18
+
* Always create a createdb.sql file for plain format instead of dumping with --create
19
19
20
20
## pg_back 2.0.1
21
21
Original file line number Diff line number Diff line change
@@ -359,7 +359,12 @@ func run() (retVal error) {
359
359
// if it fails once it fails all the time.
360
360
if canDumpACL {
361
361
l.Verboseln("dumping create database query and ACL of", dbname)
362
-
b, err = dumpCreateDBAndACL(db, dbname)
362
+
force := false
363
+
if d.Options.Format == 'p' {
364
+
force = true
365
+
}
366
+
367
+
b, err = dumpCreateDBAndACL(db, dbname, force)
363
368
var verr *pgVersionError
364
369
if err != nil {
365
370
if !errors.As(err, &verr) {
@@ -566,13 +571,6 @@ func (d *dump) dump(fc chan<- sumFileJob) error {
566
571
}
567
572
}
568
573
569
-
// It is recommended to use --create with the plain format
570
-
// from PostgreSQL 11 to get the ACL and configuration of the
571
-
// database
572
-
if d.PgDumpVersion >= 110000 && fileEnd == "sql" {
573
-
args = append(args, "--create")
574
-
}
575
-
576
574
// Included and excluded schemas and table
577
575
for _, obj := range d.Options.Schemas {
578
576
args = append(args, "-n", obj)
Original file line number Diff line number Diff line change
@@ -208,22 +208,23 @@ func (e *pgVersionError) Error() string {
208
208
}
209
209
210
210
// pg_dumpacl stuff
211
-
func dumpCreateDBAndACL(db *pg, dbname string) (string, error) {
211
+
func dumpCreateDBAndACL(db *pg, dbname string, force bool) (string, error) {
212
212
var s string
213
213
214
214
if dbname == "" {
215
215
return "", fmt.Errorf("empty input dbname")
216
216
}
217
217
218
-
// this query only work from 9.0, where datcollate and datctype were added to pg_database
218
+
// this query only work from 9.0, where datcollate and datctype were
219
+
// added to pg_database
219
220
if db.version < 90000 {
220
221
return "", &pgVersionError{s: "cluster version is older than 9.0, not dumping ACL"}
221
222
}
222
223
223
224
// this is no longer necessary after 11. Dumping ACL is the
224
225
// job of pg_dump so we have to check its version, not the
225
226
// server
226
-
if pgToolVersion("pg_dump") >= 110000 {
227
+
if pgToolVersion("pg_dump") >= 110000 && !force {
227
228
l.Verboseln("no need to dump create database query and database ACL with pg_dump from >=11")
228
229
return "", nil
229
230
}
Original file line number Diff line number Diff line change
@@ -280,7 +280,7 @@ func TestDumpCreateDBAndACL(t *testing.T) {
280
280
281
281
for _, st := range tests {
282
282
t.Run(fmt.Sprintf("%s", st.db), func(t *testing.T) {
283
-
got, err := dumpCreateDBAndACL(testdb, st.db)
283
+
got, err := dumpCreateDBAndACL(testdb, st.db, false)
284
284
if err != nil {
285
285
t.Errorf("expected non nil error, got %q", err)
286
286
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4