diff options
Diffstat (limited to 'vendor/github.com/jackc/pgx/v4')
| -rw-r--r-- | vendor/github.com/jackc/pgx/v4/CHANGELOG.md | 13 | ||||
| -rw-r--r-- | vendor/github.com/jackc/pgx/v4/README.md | 2 | ||||
| -rw-r--r-- | vendor/github.com/jackc/pgx/v4/conn.go | 10 | ||||
| -rw-r--r-- | vendor/github.com/jackc/pgx/v4/internal/sanitize/sanitize.go | 66 | ||||
| -rw-r--r-- | vendor/github.com/jackc/pgx/v4/stdlib/sql.go | 19 | 
5 files changed, 81 insertions, 29 deletions
| diff --git a/vendor/github.com/jackc/pgx/v4/CHANGELOG.md b/vendor/github.com/jackc/pgx/v4/CHANGELOG.md index e8f201295..8efe01a9c 100644 --- a/vendor/github.com/jackc/pgx/v4/CHANGELOG.md +++ b/vendor/github.com/jackc/pgx/v4/CHANGELOG.md @@ -1,3 +1,16 @@ +# 4.18.1 (February 27, 2023) + +* Fix: Support pgx v4 and v5 stdlib in same program (Tomáš Procházka) + +# 4.18.0 (February 11, 2023) + +* Upgrade pgconn to v1.14.0 +* Upgrade pgproto3 to v2.3.2 +* Upgrade pgtype to v1.14.0 +* Fix query sanitizer when query text contains Unicode replacement character +* Fix context with value in BeforeConnect (David Harju) +* Support pgx v4 and v5 stdlib in same program (Vitalii Solodilov) +  # 4.17.2 (September 3, 2022)  * Fix panic when logging batch error (Tom Möller) diff --git a/vendor/github.com/jackc/pgx/v4/README.md b/vendor/github.com/jackc/pgx/v4/README.md index 16d8f46f7..ec9212715 100644 --- a/vendor/github.com/jackc/pgx/v4/README.md +++ b/vendor/github.com/jackc/pgx/v4/README.md @@ -3,7 +3,7 @@  --- -This is the stable `v4` release. `v5` is now in beta testing with final release expected in September. See https://github.com/jackc/pgx/issues/1273 for more information. Please consider testing `v5`. +This is the previous stable `v4` release. `v5` been released.  ---  # pgx - PostgreSQL Driver and Toolkit diff --git a/vendor/github.com/jackc/pgx/v4/conn.go b/vendor/github.com/jackc/pgx/v4/conn.go index 854561e02..6f83f4972 100644 --- a/vendor/github.com/jackc/pgx/v4/conn.go +++ b/vendor/github.com/jackc/pgx/v4/conn.go @@ -535,9 +535,13 @@ type QueryResultFormats []int16  // QueryResultFormatsByOID controls the result format (text=0, binary=1) of a query by the result column OID.  type QueryResultFormatsByOID map[uint32]int16 -// Query executes sql with args. It is safe to attempt to read from the returned Rows even if an error is returned. The -// error will be the available in rows.Err() after rows are closed. So it is allowed to ignore the error returned from -// Query and handle it in Rows. +// Query sends a query to the server and returns a Rows to read the results. Only errors encountered sending the query +// and initializing Rows will be returned. Err() on the returned Rows must be checked after the Rows is closed to +// determine if the query executed successfully. +// +// The returned Rows must be closed before the connection can be used again. It is safe to attempt to read from the +// returned Rows even if an error is returned. The error will be the available in rows.Err() after rows are closed. It +// is allowed to ignore the error returned from Query and handle it in Rows.  //  // Err() on the returned Rows must be checked after the Rows is closed to determine if the query executed successfully  // as some errors can only be detected by reading the entire response. e.g. A divide by zero error on the last row. diff --git a/vendor/github.com/jackc/pgx/v4/internal/sanitize/sanitize.go b/vendor/github.com/jackc/pgx/v4/internal/sanitize/sanitize.go index a7a94e93e..5eef456c3 100644 --- a/vendor/github.com/jackc/pgx/v4/internal/sanitize/sanitize.go +++ b/vendor/github.com/jackc/pgx/v4/internal/sanitize/sanitize.go @@ -18,6 +18,12 @@ type Query struct {  	Parts []Part  } +// utf.DecodeRune returns the utf8.RuneError for errors. But that is actually rune U+FFFD -- the unicode replacement +// character. utf8.RuneError is not an error if it is also width 3. +// +// https://github.com/jackc/pgx/issues/1380 +const replacementcharacterwidth = 3 +  func (q *Query) Sanitize(args ...interface{}) (string, error) {  	argUse := make([]bool, len(args))  	buf := &bytes.Buffer{} @@ -138,11 +144,13 @@ func rawState(l *sqlLexer) stateFn {  				return multilineCommentState  			}  		case utf8.RuneError: -			if l.pos-l.start > 0 { -				l.parts = append(l.parts, l.src[l.start:l.pos]) -				l.start = l.pos +			if width != replacementcharacterwidth { +				if l.pos-l.start > 0 { +					l.parts = append(l.parts, l.src[l.start:l.pos]) +					l.start = l.pos +				} +				return nil  			} -			return nil  		}  	}  } @@ -160,11 +168,13 @@ func singleQuoteState(l *sqlLexer) stateFn {  			}  			l.pos += width  		case utf8.RuneError: -			if l.pos-l.start > 0 { -				l.parts = append(l.parts, l.src[l.start:l.pos]) -				l.start = l.pos +			if width != replacementcharacterwidth { +				if l.pos-l.start > 0 { +					l.parts = append(l.parts, l.src[l.start:l.pos]) +					l.start = l.pos +				} +				return nil  			} -			return nil  		}  	}  } @@ -182,11 +192,13 @@ func doubleQuoteState(l *sqlLexer) stateFn {  			}  			l.pos += width  		case utf8.RuneError: -			if l.pos-l.start > 0 { -				l.parts = append(l.parts, l.src[l.start:l.pos]) -				l.start = l.pos +			if width != replacementcharacterwidth { +				if l.pos-l.start > 0 { +					l.parts = append(l.parts, l.src[l.start:l.pos]) +					l.start = l.pos +				} +				return nil  			} -			return nil  		}  	}  } @@ -228,11 +240,13 @@ func escapeStringState(l *sqlLexer) stateFn {  			}  			l.pos += width  		case utf8.RuneError: -			if l.pos-l.start > 0 { -				l.parts = append(l.parts, l.src[l.start:l.pos]) -				l.start = l.pos +			if width != replacementcharacterwidth { +				if l.pos-l.start > 0 { +					l.parts = append(l.parts, l.src[l.start:l.pos]) +					l.start = l.pos +				} +				return nil  			} -			return nil  		}  	}  } @@ -249,11 +263,13 @@ func oneLineCommentState(l *sqlLexer) stateFn {  		case '\n', '\r':  			return rawState  		case utf8.RuneError: -			if l.pos-l.start > 0 { -				l.parts = append(l.parts, l.src[l.start:l.pos]) -				l.start = l.pos +			if width != replacementcharacterwidth { +				if l.pos-l.start > 0 { +					l.parts = append(l.parts, l.src[l.start:l.pos]) +					l.start = l.pos +				} +				return nil  			} -			return nil  		}  	}  } @@ -283,11 +299,13 @@ func multilineCommentState(l *sqlLexer) stateFn {  			l.nested--  		case utf8.RuneError: -			if l.pos-l.start > 0 { -				l.parts = append(l.parts, l.src[l.start:l.pos]) -				l.start = l.pos +			if width != replacementcharacterwidth { +				if l.pos-l.start > 0 { +					l.parts = append(l.parts, l.src[l.start:l.pos]) +					l.start = l.pos +				} +				return nil  			} -			return nil  		}  	}  } diff --git a/vendor/github.com/jackc/pgx/v4/stdlib/sql.go b/vendor/github.com/jackc/pgx/v4/stdlib/sql.go index da377ecee..f43ae3249 100644 --- a/vendor/github.com/jackc/pgx/v4/stdlib/sql.go +++ b/vendor/github.com/jackc/pgx/v4/stdlib/sql.go @@ -84,7 +84,13 @@ func init() {  		configs: make(map[string]*pgx.ConnConfig),  	}  	fakeTxConns = make(map[*pgx.Conn]*sql.Tx) -	sql.Register("pgx", pgxDriver) + +	// if pgx driver was already registered by different pgx major version then we +	// skip registration under the default name. +	if !contains(sql.Drivers(), "pgx") { +		sql.Register("pgx", pgxDriver) +	} +	sql.Register("pgx/v4", pgxDriver)  	databaseSQLResultFormats = pgx.QueryResultFormatsByOID{  		pgtype.BoolOID:        1, @@ -103,6 +109,17 @@ func init() {  	}  } +// TODO replace by slices.Contains when experimental package will be merged to stdlib +// https://pkg.go.dev/golang.org/x/exp/slices#Contains +func contains(list []string, y string) bool { +	for _, x := range list { +		if x == y { +			return true +		} +	} +	return false +} +  var (  	fakeTxMutex sync.Mutex  	fakeTxConns map[*pgx.Conn]*sql.Tx | 
