A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/orgrim/pg_back/commit/fa67fe96e905f0f43c13a7ccf7b2ff97236751be below:

refactor pgDumpVersion to accept other tools · orgrim/pg_back@fa67fe9 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+26

-10

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+26

-10

lines changed Original file line number Diff line number Diff line change

@@ -450,7 +450,7 @@ func (d *dump) dump() error {

450 450

// It is recommended to use --create with the plain format

451 451

// from PostgreSQL 11 to get the ACL and configuration of the

452 452

// database

453 -

if pgDumpVersion() >= 110000 && fileEnd == "sql" {

453 +

if pgToolVersion("pg_dump") >= 110000 && fileEnd == "sql" {

454 454

args = append(args, "--create")

455 455

}

456 456

@@ -576,17 +576,33 @@ func formatDumpPath(dir string, timeFormat string, suffix string, dbname string,

576 576

return filepath.Join(d, f)

577 577

}

578 578 579 -

func pgDumpVersion() int {

580 -

vs, err := exec.Command(filepath.Join(binDir, "pg_dump"), "-V").Output()

579 +

func pgToolVersion(tool string) int {

580 +

vs, err := exec.Command(filepath.Join(binDir, tool), "--version").Output()

581 581

if err != nil {

582 -

l.Warnln("failed to retrieve version of pg_dump:", err)

582 +

l.Warnf("failed to retrieve version of %s: %s", tool, err)

583 583

return 0

584 584

}

585 585 586 -

var maj, min, rev int

587 -

fmt.Sscanf(string(vs), "pg_dump (PostgreSQL) %d.%d.%d", &maj, &min, &rev)

586 +

var maj, min, rev, numver int

587 +

n, _ := fmt.Sscanf(string(vs), tool+" (PostgreSQL) %d.%d.%d", &maj, &min, &rev)

588 588 589 -

return (maj*100+min)*100 + rev

589 +

if n == 3 {

590 +

// Before PostgreSQL 10, the format si MAJ.MIN.REV

591 +

numver = (maj*100+min)*100 + rev

592 +

} else if n == 2 {

593 +

// From PostgreSQL 10, the format si MAJ.REV, so the rev ends

594 +

// up in min with the scan

595 +

numver = maj*10000 + min

596 +

} else {

597 +

// We have the special case of the development version, where the

598 +

// format is MAJdevel

599 +

fmt.Sscanf(string(vs), tool+" (PostgreSQL) %ddevel", &maj)

600 +

numver = maj * 10000

601 +

}

602 + 603 +

l.Verboseln(tool, "version is:", numver)

604 + 605 +

return numver

590 606

}

591 607 592 608

func dumpGlobals(dir string, timeFormat string, conninfo *ConnInfo, fc chan<- string) error {

Original file line number Diff line number Diff line change

@@ -223,7 +223,7 @@ func dumpCreateDBAndACL(db *pg, dbname string) (string, error) {

223 223

// this is no longer necessary after 11. Dumping ACL is the

224 224

// job of pg_dump so we have to check its version, not the

225 225

// server

226 -

if pgDumpVersion() >= 110000 {

226 +

if pgToolVersion("pg_dump") >= 110000 {

227 227

l.Verboseln("no need to dump create database query and database ACL with pg_dump from >=11")

228 228

return "", nil

229 229

}

@@ -400,7 +400,7 @@ func dumpDBConfig(db *pg, dbname string) (string, error) {

400 400

// this is no longer necessary after 11. Dumping ACL is the

401 401

// job of pg_dump so we have to check its version, not the

402 402

// server

403 -

if pgDumpVersion() >= 110000 {

403 +

if pgToolVersion("pg_dump") >= 110000 {

404 404

l.Verboseln("no need to dump database configuration with pg_dump from >=11")

405 405

return "", nil

406 406

}

Original file line number Diff line number Diff line change

@@ -57,7 +57,7 @@ func needPgConn(t *testing.T) {

57 57

}

58 58 59 59

func needPgDump(t *testing.T) {

60 -

if pgDumpVersion() >= 110000 {

60 +

if pgToolVersion("pg_dump") >= 110000 {

61 61

t.Skip("testing with a pg_dump version > 11")

62 62

}

63 63

}

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