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

chore: close db properly in early exit paths in ConnectToPostgres#18448

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

Open
hugodutka wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromhugodutka/connect-to-postgres-close-db
Open
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
9 changes: 4 additions & 5 deletionscli/server.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2363,10 +2363,8 @@ func ConnectToPostgres(ctx context.Context, logger slog.Logger, driver string, d
if !version.Next() {
// it's critical we assign to the err variable, otherwise the defer statement
// that runs db.Close() will not execute it
if err = version.Err(); err != nil {
return nil, xerrors.Errorf("no rows returned for version select: %w", err)
}
return nil, xerrors.Errorf("no rows returned for version select")
err = xerrors.Errorf("no rows returned for version select: %w", version.Err())
return nil, err
}
var versionNum int
err = version.Scan(&versionNum)
Expand All@@ -2375,7 +2373,8 @@ func ConnectToPostgres(ctx context.Context, logger slog.Logger, driver string, d
}

if versionNum < 130000 {
return nil, xerrors.Errorf("PostgreSQL version must be v13.0.0 or higher! Got: %d", versionNum)
err = xerrors.Errorf("PostgreSQL version must be v13.0.0 or higher! Got: %d", versionNum)
return nil, err
}
logger.Debug(ctx, "connected to postgresql", slog.F("version", versionNum))

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp