diff --git a/pgconn.go b/pgconn.go index f8b8a659..7bf2f20e 100644 --- a/pgconn.go +++ b/pgconn.go @@ -335,7 +335,7 @@ func connect(ctx context.Context, config *Config, fallbackConfig *FallbackConfig } } return pgConn, nil - case *pgproto3.ParameterStatus: + case *pgproto3.ParameterStatus, *pgproto3.NoticeResponse: // handled by ReceiveMessage case *pgproto3.ErrorResponse: pgConn.conn.Close() diff --git a/pgconn_test.go b/pgconn_test.go index b22792fb..32186fc6 100644 --- a/pgconn_test.go +++ b/pgconn_test.go @@ -1298,6 +1298,7 @@ func TestConnOnNotice(t *testing.T) { config.OnNotice = func(c *pgconn.PgConn, notice *pgconn.Notice) { msg = notice.Message } + config.RuntimeParams["client_min_messages"] = "notice" // Ensure we only get the message we expect. pgConn, err := pgconn.ConnectConfig(context.Background(), config) require.NoError(t, err) @@ -1954,7 +1955,11 @@ func TestConnSendBytesAndReceiveMessage(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() - pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_CONN_STRING")) + config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_CONN_STRING")) + require.NoError(t, err) + config.RuntimeParams["client_min_messages"] = "notice" // Ensure we only get the messages we expect. + + pgConn, err := pgconn.ConnectConfig(context.Background(), config) require.NoError(t, err) defer closeConn(t, pgConn)