Fix incorrect PostgreSQL connection string for Unix sockets (#28865) (#28870)

Backport #28865 by @sdvcrx

Fix #28864

Co-authored-by: sdvcrx <memory.silentvoyage@gmail.com>
(cherry picked from commit 8c7bda8755cc5fd1b12c5516fb60b7f63af4aecf)
This commit is contained in:
Giteabot 2024-01-22 00:06:34 +08:00 committed by Earl Warren
parent 6aa5554161
commit 131a8f0324
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 10 additions and 2 deletions

View file

@ -170,8 +170,8 @@ func getPostgreSQLConnectionString(dbHost, dbUser, dbPasswd, dbName, dbsslMode s
RawQuery: dbParam,
}
query := connURL.Query()
if strings.HasPrefix(dbHost, "/") { // looks like a unix socket
query.Add("host", dbHost)
if strings.HasPrefix(host, "/") { // looks like a unix socket
query.Add("host", host)
connURL.Host = ":" + port
}
query.Set("sslmode", dbsslMode)