Commit 19e1063b authored by Simon Esposito's avatar Simon Esposito
Browse files

Upgrade to pgx v5.4.2

parent f64d8e27
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ require (
	github.com/heroiclabs/sql-migrate v0.0.0-20230615133120-fb3ad977aaaf
	github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa
	github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59
	github.com/jackc/pgx/v5 v5.4.1
	github.com/jackc/pgx/v5 v5.4.2
	github.com/prometheus/client_golang v1.16.0
	github.com/stretchr/testify v1.8.4
	github.com/twmb/murmur3 v1.1.8
+2 −2
Original line number Diff line number Diff line
@@ -264,8 +264,8 @@ github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186 h1:ZQM8qLT/E/CGD6XX0E6q9FAwxJYmWpJufzmLMaFuzgQ=
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
github.com/jackc/pgx/v5 v5.4.1 h1:oKfB/FhuVtit1bBM3zNRRsZ925ZkMN3HXL+LgLUM9lE=
github.com/jackc/pgx/v5 v5.4.1/go.mod h1:q6iHT8uDNXWiFNOlRqJzBTaSH3+2xCXkokxHZC5qWFY=
github.com/jackc/pgx/v5 v5.4.2 h1:u1gmGDwbdRUZiwisBm/Ky2M14uQyUP65bG8+20nnyrg=
github.com/jackc/pgx/v5 v5.4.2/go.mod h1:q6iHT8uDNXWiFNOlRqJzBTaSH3+2xCXkokxHZC5qWFY=
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
+9 −0
Original line number Diff line number Diff line
# 5.4.2 (July 11, 2023)

* Fix: RowScanner errors are fatal to Rows
* Fix: Enable failover efforts when pg_hba.conf disallows non-ssl connections (Brandon Kauffman)
* Hstore text codec internal improvements (Evan Jones)
* Fix: Stop timers for background reader when not in use. Fixes memory leak when closing connections (Adrian-Stefan Mares)
* Fix: Stop background reader as soon as possible.
* Add PgConn.SyncConn(). This combined with the above fix makes it safe to directly use the underlying net.Conn.

# 5.4.1 (June 18, 2023)

* Fix: concurrency bug with pgtypeDefaultMap and simple protocol (Lev Zakharov)
+1 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ These adapters can be used with the tracelog package.
* [github.com/jackc/pgx-zap](https://github.com/jackc/pgx-zap)
* [github.com/jackc/pgx-zerolog](https://github.com/jackc/pgx-zerolog)
* [github.com/mcosta74/pgx-slog](https://github.com/mcosta74/pgx-slog)
* [github.com/kataras/pgx-golog](https://github.com/kataras/pgx-golog)

## 3rd Party Libraries with PGX Support

+27 −20
Original line number Diff line number Diff line
@@ -9,9 +9,9 @@ import (
)

const (
	bgReaderStatusStopped = iota
	bgReaderStatusRunning
	bgReaderStatusStopping
	StatusStopped = iota
	StatusRunning
	StatusStopping
)

// BGReader is an io.Reader that can optionally buffer reads in the background. It is safe for concurrent use.
@@ -19,7 +19,7 @@ type BGReader struct {
	r io.Reader

	cond        *sync.Cond
	bgReaderStatus int32
	status      int32
	readResults []readResult
}

@@ -34,14 +34,14 @@ func (r *BGReader) Start() {
	r.cond.L.Lock()
	defer r.cond.L.Unlock()

	switch r.bgReaderStatus {
	case bgReaderStatusStopped:
		r.bgReaderStatus = bgReaderStatusRunning
	switch r.status {
	case StatusStopped:
		r.status = StatusRunning
		go r.bgRead()
	case bgReaderStatusRunning:
	case StatusRunning:
		// no-op
	case bgReaderStatusStopping:
		r.bgReaderStatus = bgReaderStatusRunning
	case StatusStopping:
		r.status = StatusRunning
	}
}

@@ -51,16 +51,23 @@ func (r *BGReader) Stop() {
	r.cond.L.Lock()
	defer r.cond.L.Unlock()

	switch r.bgReaderStatus {
	case bgReaderStatusStopped:
	switch r.status {
	case StatusStopped:
		// no-op
	case bgReaderStatusRunning:
		r.bgReaderStatus = bgReaderStatusStopping
	case bgReaderStatusStopping:
	case StatusRunning:
		r.status = StatusStopping
	case StatusStopping:
		// no-op
	}
}

// Status returns the current status of the background reader.
func (r *BGReader) Status() int32 {
	r.cond.L.Lock()
	defer r.cond.L.Unlock()
	return r.status
}

func (r *BGReader) bgRead() {
	keepReading := true
	for keepReading {
@@ -70,8 +77,8 @@ func (r *BGReader) bgRead() {

		r.cond.L.Lock()
		r.readResults = append(r.readResults, readResult{buf: buf, err: err})
		if r.bgReaderStatus == bgReaderStatusStopping || err != nil {
			r.bgReaderStatus = bgReaderStatusStopped
		if r.status == StatusStopping || err != nil {
			r.status = StatusStopped
			keepReading = false
		}
		r.cond.L.Unlock()
@@ -89,7 +96,7 @@ func (r *BGReader) Read(p []byte) (int, error) {
	}

	// There are no unread background read results and the background reader is stopped.
	if r.bgReaderStatus == bgReaderStatusStopped {
	if r.status == StatusStopped {
		return r.r.Read(p)
	}

Loading