jackc / pgx

PostgreSQL driver and toolkit for Go
MIT License
10.83k stars 845 forks source link

target_session_attrs cannot be used with replication connection #2168

Open thedolphin opened 2 days ago

thedolphin commented 2 days ago

Describe the bug

target_session_attrs cannot be used with replication connection

To Reproduce


config, _ := pgconn.ParseConfig("target_session_attrs=read-write")
config.RuntimeParams["replication"] = "database"
pgConn, err := pgconn.ConnectConfig(ctx, config)
if err != nil {
    log.Print(err)
}

Expected behavior

Primary server was found and connection succeeded

Actual behavior

ValidateConnect failed: ERROR: extended query protocol not supported in a replication connection (SQLSTATE 08P01)

Version

Additional context

Seems that ExecParams in ValidateConnectTargetSessionAttrs* functions is redundant and could be replaced with Exec function, while it triggers extended query protocol usage https://github.com/jackc/pgx/blob/b9e2b20fb13a7eb8e6bf105c074c291b349b6dec/pgconn/config.go#L864