@@ -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"
@@ -254,26 +253,31 @@ func PGDump(dbURL string) ([]byte, error) {
254
253
return stdout .Bytes (),nil
255
254
}
256
255
257
- const minimumPostgreSQLVersion = 13
256
+ const (
257
+ minimumPostgreSQLVersion = 13
258
+ postgresImageSha = "sha256:467e7f2fb97b2f29d616e0be1d02218a7bbdfb94eb3cda7461fd80165edfd1f7"
259
+ )
258
260
259
261
// PGDumpSchemaOnly is for use by gen/dump only.
260
262
// It runs pg_dump against dbURL and sets a consistent timezone and encoding.
261
263
func PGDumpSchemaOnly (dbURL string ) ([]byte ,error ) {
262
264
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
+ // }
277
281
278
282
cmdArgs := []string {
279
283
"pg_dump" ,
@@ -298,7 +302,7 @@ func PGDumpSchemaOnly(dbURL string) ([]byte, error) {
298
302
"run" ,
299
303
"--rm" ,
300
304
"--network=host" ,
301
- fmt .Sprintf ("%s:%d" ,postgresImage ,minimumPostgreSQLVersion ),
305
+ fmt .Sprintf ("%s:%d@%s " ,postgresImage ,minimumPostgreSQLVersion , postgresImageSha ),
302
306
},cmdArgs ... )
303
307
}
304
308
cmd := exec .Command (cmdArgs [0 ],cmdArgs [1 :]... )//#nosec