From 8990c125cf4a71bcf938328b43d52a289053725e Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Fri, 12 Mar 2021 11:55:01 +0500 Subject: [PATCH] Stop fallback on ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION --- pgconn.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pgconn.go b/pgconn.go index 668808aa..197aad4a 100644 --- a/pgconn.go +++ b/pgconn.go @@ -152,9 +152,10 @@ func ConnectConfig(ctx context.Context, config *Config) (pgConn *PgConn, err err break } else if pgerr, ok := err.(*PgError); ok { err = &connectError{config: config, msg: "server error", err: pgerr} - ERRCODE_INVALID_PASSWORD := "28P01" - if pgerr.Code == ERRCODE_INVALID_PASSWORD { - break; + ERRCODE_INVALID_PASSWORD := "28P01" // worng password + ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION := "28000" // db does not exist + if pgerr.Code == ERRCODE_INVALID_PASSWORD || pgerr.Code == ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION { + break } } }