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

[2.26 backport] fix: pin pg_dump version when generating schema (#19696)#19765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kacpersaw merged 1 commit intorelease/2.26fromkacpersaw/cherry-pick/19696
Sep 11, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletionscoderd/database/dbtestutil/db.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,6 @@ import (
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
"testing"
"time"
Expand DownExpand Up@@ -251,26 +250,31 @@ func PGDump(dbURL string) ([]byte, error) {
return stdout.Bytes(), nil
}

const minimumPostgreSQLVersion = 13
const (
minimumPostgreSQLVersion = 13
postgresImageSha = "sha256:467e7f2fb97b2f29d616e0be1d02218a7bbdfb94eb3cda7461fd80165edfd1f7"
)

// PGDumpSchemaOnly is for use by gen/dump only.
// It runs pg_dump against dbURL and sets a consistent timezone and encoding.
func PGDumpSchemaOnly(dbURL string) ([]byte, error) {
hasPGDump := false
if _, err := exec.LookPath("pg_dump"); err == nil {
out, err := exec.Command("pg_dump", "--version").Output()
if err == nil {
// Parse output:
// pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
parts := strings.Split(string(out), " ")
if len(parts) > 2 {
version, err := strconv.Atoi(strings.Split(parts[2], ".")[0])
if err == nil && version >= minimumPostgreSQLVersion {
hasPGDump = true
}
}
}
}
// TODO: Temporarily pin pg_dump to the docker image until
// https://github.com/sqlc-dev/sqlc/issues/4065 is resolved.
// if _, err := exec.LookPath("pg_dump"); err == nil {
// out, err := exec.Command("pg_dump", "--version").Output()
// if err == nil {
// // Parse output:
// // pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
// parts := strings.Split(string(out), " ")
// if len(parts) > 2 {
// version, err := strconv.Atoi(strings.Split(parts[2], ".")[0])
// if err == nil && version >= minimumPostgreSQLVersion {
// hasPGDump = true
// }
// }
// }
// }

cmdArgs := []string{
"pg_dump",
Expand All@@ -295,7 +299,7 @@ func PGDumpSchemaOnly(dbURL string) ([]byte, error) {
"run",
"--rm",
"--network=host",
fmt.Sprintf("%s:%d", postgresImage, minimumPostgreSQLVersion),
fmt.Sprintf("%s:%d@%s", postgresImage, minimumPostgreSQLVersion, postgresImageSha),
}, cmdArgs...)
}
cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...) //#nosec
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp