2
0

Fix connect when receiving NoticeResponse

refs #102
This commit is contained in:
Jack Christensen
2022-01-20 16:40:44 -06:00
parent 109c4c2d95
commit 05d532b5df
2 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -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()
+6 -1
View File
@@ -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)