@@ -10,7 +10,6 @@ import (
10
10
"os/exec"
11
11
"path/filepath"
12
12
"regexp"
13
- "strconv"
14
13
"strings"
15
14
"testing"
16
15
"time"
@@ -252,25 +251,28 @@ func PGDump(dbURL string) ([]byte, error) {
252
251
}
253
252
254
253
const minimumPostgreSQLVersion = 13
254
+ const postgresImageSha = "sha256:467e7f2fb97b2f29d616e0be1d02218a7bbdfb94eb3cda7461fd80165edfd1f7"
255
255
256
256
// PGDumpSchemaOnly is for use by gen/dump only.
257
257
// It runs pg_dump against dbURL and sets a consistent timezone and encoding.
258
258
func PGDumpSchemaOnly (dbURL string ) ([]byte , error ) {
259
259
hasPGDump := false
260
- if _ , err := exec .LookPath ("pg_dump" ); err == nil {
261
- out , err := exec .Command ("pg_dump" , "--version" ).Output ()
262
- if err == nil {
263
- // Parse output:
264
- // pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
265
- parts := strings .Split (string (out ), " " )
266
- if len (parts ) > 2 {
267
- version , err := strconv .Atoi (strings .Split (parts [2 ], "." )[0 ])
268
- if err == nil && version >= minimumPostgreSQLVersion {
269
- hasPGDump = true
270
- }
271
- }
272
- }
273
- }
260
+ // TODO: Temporarily pin pg_dump to the docker image until
261
+ // https://github.com/sqlc-dev/sqlc/issues/4065 is resolved.
262
+ // if _, err := exec.LookPath("pg_dump"); err == nil {
263
+ // out, err := exec.Command("pg_dump", "--version").Output()
264
+ // if err == nil {
265
+ // // Parse output:
266
+ // // pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
267
+ // parts := strings.Split(string(out), " ")
268
+ // if len(parts) > 2 {
269
+ // version, err := strconv.Atoi(strings.Split(parts[2], ".")[0])
270
+ // if err == nil && version >= minimumPostgreSQLVersion {
271
+ // hasPGDump = true
272
+ // }
273
+ // }
274
+ // }
275
+ // }
274
276
275
277
cmdArgs := []string {
276
278
"pg_dump" ,
@@ -295,7 +297,7 @@ func PGDumpSchemaOnly(dbURL string) ([]byte, error) {
295
297
"run" ,
296
298
"--rm" ,
297
299
"--network=host" ,
298
- fmt .Sprintf ("%s:%d" , postgresImage , minimumPostgreSQLVersion ),
300
+ fmt .Sprintf ("%s:%d@%s " , postgresImage , minimumPostgreSQLVersion , postgresImageSha ),
299
301
}, cmdArgs ... )
300
302
}
301
303
cmd := exec .Command (cmdArgs [0 ], cmdArgs [1 :]... ) //#nosec
0 commit comments