Fix panic in Pipeline when PgConn is busy or closed

This commit is contained in:
Ryan Fowler 2023-12-16 09:23:17 -08:00 committed by Jack Christensen
parent 603c8c1e90
commit dfd198003a

View File

@ -2053,6 +2053,13 @@ func (p *Pipeline) Flush() error {
// Sync establishes a synchronization point and flushes the queued requests. // Sync establishes a synchronization point and flushes the queued requests.
func (p *Pipeline) Sync() error { func (p *Pipeline) Sync() error {
if p.closed {
if p.err != nil {
return p.err
}
return errors.New("pipeline closed")
}
p.conn.frontend.SendSync(&pgproto3.Sync{}) p.conn.frontend.SendSync(&pgproto3.Sync{})
err := p.Flush() err := p.Flush()
if err != nil { if err != nil {