From beb4e2cfbcd7f41e6389254496cc5feae7d99d9c Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 16 Apr 2022 07:24:25 -0500 Subject: [PATCH] SQLCODE 42501 is fatal connect error Don't try fallback configs. Match libpq behavior. fixes https://github.com/jackc/pgconn/issues/108 --- pgconn.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pgconn.go b/pgconn.go index 0d07ac57..f1304d08 100644 --- a/pgconn.go +++ b/pgconn.go @@ -157,9 +157,11 @@ func ConnectConfig(ctx context.Context, config *Config) (pgConn *PgConn, err err const ERRCODE_INVALID_PASSWORD = "28P01" // wrong password const ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION = "28000" // wrong password or bad pg_hba.conf settings const ERRCODE_INVALID_CATALOG_NAME = "3D000" // db does not exist + const ERRCODE_INSUFFICIENT_PRIVILEGE = "42501" // missing connect privilege if pgerr.Code == ERRCODE_INVALID_PASSWORD || pgerr.Code == ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION || - pgerr.Code == ERRCODE_INVALID_CATALOG_NAME { + pgerr.Code == ERRCODE_INVALID_CATALOG_NAME || + pgerr.Code == ERRCODE_INSUFFICIENT_PRIVILEGE { break } }