Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc0f1b9d

Browse files
[2.26 backport] fix: pin pg_dump version when generating schema (#19696) (#19765)
This is required by#19756 The latest release of all `pg_dump` major versions, going back to 13,started inserting `\restrict` `\unrestrict` keywords into dumps. Thiscurrently breaks sqlc in `gen/dump` and our check migration script. Fulldetails of the postgres change are available here:https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=575f54d4cTo fix, we'll always use the `pg_dump` in our postgres 13.21 dockerimage for schema dumps, instead of what's on the runner/local machine.Coder doesn't restore from postgres dumps, so we're not vulnerable toattacks that would be patched by the latest postgres version.Regardless, we'll unpin ASAP.Once sqlc is updated to handle these keywords, we need to startstripping them when comparing the schema in the migration check script,and then we can unpin the pg_dump version. This is being tracked atcoder/internal#965Co-authored-by: Ethan <39577870+ethanndickson@users.noreply.github.com>
1 parenta056cb6 commitc0f1b9d

File tree

1 file changed

+21
-17
lines changed
  • coderd/database/dbtestutil

1 file changed

+21
-17
lines changed

‎coderd/database/dbtestutil/db.go‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os/exec"
1111
"path/filepath"
1212
"regexp"
13-
"strconv"
1413
"strings"
1514
"testing"
1615
"time"
@@ -251,26 +250,31 @@ func PGDump(dbURL string) ([]byte, error) {
251250
returnstdout.Bytes(),nil
252251
}
253252

254-
constminimumPostgreSQLVersion=13
253+
const (
254+
minimumPostgreSQLVersion=13
255+
postgresImageSha="sha256:467e7f2fb97b2f29d616e0be1d02218a7bbdfb94eb3cda7461fd80165edfd1f7"
256+
)
255257

256258
// PGDumpSchemaOnly is for use by gen/dump only.
257259
// It runs pg_dump against dbURL and sets a consistent timezone and encoding.
258260
funcPGDumpSchemaOnly(dbURLstring) ([]byte,error) {
259261
hasPGDump:=false
260-
if_,err:=exec.LookPath("pg_dump");err==nil {
261-
out,err:=exec.Command("pg_dump","--version").Output()
262-
iferr==nil {
263-
// Parse output:
264-
// pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
265-
parts:=strings.Split(string(out)," ")
266-
iflen(parts)>2 {
267-
version,err:=strconv.Atoi(strings.Split(parts[2],".")[0])
268-
iferr==nil&&version>=minimumPostgreSQLVersion {
269-
hasPGDump=true
270-
}
271-
}
272-
}
273-
}
262+
// TODO: Temporarily pin pg_dump to the docker image until
263+
// https://github.com/sqlc-dev/sqlc/issues/4065 is resolved.
264+
// if _, err := exec.LookPath("pg_dump"); err == nil {
265+
// out, err := exec.Command("pg_dump", "--version").Output()
266+
// if err == nil {
267+
// // Parse output:
268+
// // pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
269+
// parts := strings.Split(string(out), " ")
270+
// if len(parts) > 2 {
271+
// version, err := strconv.Atoi(strings.Split(parts[2], ".")[0])
272+
// if err == nil && version >= minimumPostgreSQLVersion {
273+
// hasPGDump = true
274+
// }
275+
// }
276+
// }
277+
// }
274278

275279
cmdArgs:= []string{
276280
"pg_dump",
@@ -295,7 +299,7 @@ func PGDumpSchemaOnly(dbURL string) ([]byte, error) {
295299
"run",
296300
"--rm",
297301
"--network=host",
298-
fmt.Sprintf("%s:%d",postgresImage,minimumPostgreSQLVersion),
302+
fmt.Sprintf("%s:%d@%s",postgresImage,minimumPostgreSQLVersion,postgresImageSha),
299303
},cmdArgs...)
300304
}
301305
cmd:=exec.Command(cmdArgs[0],cmdArgs[1:]...)//#nosec

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp