Do not mutate config.Config.OnNotification in connect

fixes #618
pull/626/head
Jack Christensen 2019-10-12 11:06:43 -05:00
parent 178b4c1a64
commit 10d5f5eaa8
1 changed files with 7 additions and 0 deletions

View File

@ -169,6 +169,13 @@ func connect(ctx context.Context, config *ConnConfig) (c *Conn, err error) {
panic("config must be created by ParseConfig")
}
// This isn't really a deep copy. But it is enough to avoid the config.Config.OnNotification mutation from affecting
// other connections with the same config. See https://github.com/jackc/pgx/issues/618.
{
configCopy := *config
config = &configCopy
}
c = &Conn{
config: config,
connInfo: pgtype.NewConnInfo(),