@@ -10,7 +10,6 @@ import (
1010 "os/exec"
1111 "path/filepath"
1212 "regexp"
13- "strconv"
1413 "strings"
1514 "testing"
1615 "time"
@@ -254,26 +253,31 @@ func PGDump(dbURL string) ([]byte, error) {
254253 return stdout .Bytes (), nil
255254}
256255
257- const minimumPostgreSQLVersion = 13
256+ const (
257+ minimumPostgreSQLVersion = 13
258+ postgresImageSha = "sha256:467e7f2fb97b2f29d616e0be1d02218a7bbdfb94eb3cda7461fd80165edfd1f7"
259+ )
258260
259261// PGDumpSchemaOnly is for use by gen/dump only.
260262// It runs pg_dump against dbURL and sets a consistent timezone and encoding.
261263func PGDumpSchemaOnly (dbURL string ) ([]byte , error ) {
262264 hasPGDump := false
263- if _ , err := exec .LookPath ("pg_dump" ); err == nil {
264- out , err := exec .Command ("pg_dump" , "--version" ).Output ()
265- if err == nil {
266- // Parse output:
267- // pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
268- parts := strings .Split (string (out ), " " )
269- if len (parts ) > 2 {
270- version , err := strconv .Atoi (strings .Split (parts [2 ], "." )[0 ])
271- if err == nil && version >= minimumPostgreSQLVersion {
272- hasPGDump = true
273- }
274- }
275- }
276- }
265+ // TODO: Temporarily pin pg_dump to the docker image until
266+ // https://github.com/sqlc-dev/sqlc/issues/4065 is resolved.
267+ // if _, err := exec.LookPath("pg_dump"); err == nil {
268+ // out, err := exec.Command("pg_dump", "--version").Output()
269+ // if err == nil {
270+ // // Parse output:
271+ // // pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
272+ // parts := strings.Split(string(out), " ")
273+ // if len(parts) > 2 {
274+ // version, err := strconv.Atoi(strings.Split(parts[2], ".")[0])
275+ // if err == nil && version >= minimumPostgreSQLVersion {
276+ // hasPGDump = true
277+ // }
278+ // }
279+ // }
280+ // }
277281
278282 cmdArgs := []string {
279283 "pg_dump" ,
@@ -298,7 +302,7 @@ func PGDumpSchemaOnly(dbURL string) ([]byte, error) {
298302 "run" ,
299303 "--rm" ,
300304 "--network=host" ,
301- fmt .Sprintf ("%s:%d" , postgresImage , minimumPostgreSQLVersion ),
305+ fmt .Sprintf ("%s:%d@%s " , postgresImage , minimumPostgreSQLVersion , postgresImageSha ),
302306 }, cmdArgs ... )
303307 }
304308 cmd := exec .Command (cmdArgs [0 ], cmdArgs [1 :]... ) //#nosec
0 commit comments