chore(deps): bump github.com/lib/pq from 1.10.3 to 1.10.7
Bumps [github.com/lib/pq](https://github.com/lib/pq) from 1.10.3 to 1.10.7. - [Release notes](https://github.com/lib/pq/releases) - [Commits](https://github.com/lib/pq/compare/v1.10.3...v1.10.7) --- updated-dependencies: - dependency-name: github.com/lib/pq dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
6e92c0eb40
commit
ed3683cb32
2
go.mod
2
go.mod
@ -11,7 +11,7 @@ require (
|
|||||||
github.com/go-ping/ping v0.0.0-20210911151512-381826476871
|
github.com/go-ping/ping v0.0.0-20210911151512-381826476871
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.0
|
||||||
github.com/lib/pq v1.10.3
|
github.com/lib/pq v1.10.7
|
||||||
github.com/miekg/dns v1.1.43
|
github.com/miekg/dns v1.1.43
|
||||||
github.com/prometheus/client_golang v1.13.0
|
github.com/prometheus/client_golang v1.13.0
|
||||||
github.com/wcharczuk/go-chart/v2 v2.1.0
|
github.com/wcharczuk/go-chart/v2 v2.1.0
|
||||||
|
4
go.sum
4
go.sum
@ -169,8 +169,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
|||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
|
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
|
||||||
github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
|
4
vendor/github.com/lib/pq/array.go
generated
vendored
4
vendor/github.com/lib/pq/array.go
generated
vendored
@ -587,8 +587,8 @@ func (a *Int32Array) scanBytes(src []byte) error {
|
|||||||
} else {
|
} else {
|
||||||
b := make(Int32Array, len(elems))
|
b := make(Int32Array, len(elems))
|
||||||
for i, v := range elems {
|
for i, v := range elems {
|
||||||
var x int
|
x, err := strconv.ParseInt(string(v), 10, 32)
|
||||||
if x, err = strconv.Atoi(string(v)); err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("pq: parsing array element index %d: %v", i, err)
|
return fmt.Errorf("pq: parsing array element index %d: %v", i, err)
|
||||||
}
|
}
|
||||||
b[i] = int32(x)
|
b[i] = int32(x)
|
||||||
|
159
vendor/github.com/lib/pq/conn.go
generated
vendored
159
vendor/github.com/lib/pq/conn.go
generated
vendored
@ -18,7 +18,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
@ -31,7 +31,9 @@ var (
|
|||||||
ErrNotSupported = errors.New("pq: Unsupported command")
|
ErrNotSupported = errors.New("pq: Unsupported command")
|
||||||
ErrInFailedTransaction = errors.New("pq: Could not complete operation in a failed transaction")
|
ErrInFailedTransaction = errors.New("pq: Could not complete operation in a failed transaction")
|
||||||
ErrSSLNotSupported = errors.New("pq: SSL is not enabled on the server")
|
ErrSSLNotSupported = errors.New("pq: SSL is not enabled on the server")
|
||||||
ErrSSLKeyHasWorldPermissions = errors.New("pq: Private key file has group or world access. Permissions should be u=rw (0600) or less")
|
ErrSSLKeyUnknownOwnership = errors.New("pq: Could not get owner information for private key, may not be properly protected")
|
||||||
|
ErrSSLKeyHasWorldPermissions = errors.New("pq: Private key has world access. Permissions should be u=rw,g=r (0640) if owned by root, or u=rw (0600), or less")
|
||||||
|
|
||||||
ErrCouldNotDetectUsername = errors.New("pq: Could not detect default username. Please provide one explicitly")
|
ErrCouldNotDetectUsername = errors.New("pq: Could not detect default username. Please provide one explicitly")
|
||||||
|
|
||||||
errUnexpectedReady = errors.New("unexpected ReadyForQuery")
|
errUnexpectedReady = errors.New("unexpected ReadyForQuery")
|
||||||
@ -140,9 +142,10 @@ type conn struct {
|
|||||||
saveMessageType byte
|
saveMessageType byte
|
||||||
saveMessageBuffer []byte
|
saveMessageBuffer []byte
|
||||||
|
|
||||||
// If true, this connection is bad and all public-facing functions should
|
// If an error is set, this connection is bad and all public-facing
|
||||||
// return ErrBadConn.
|
// functions should return the appropriate error by calling get()
|
||||||
bad *atomic.Value
|
// (ErrBadConn) or getForNext().
|
||||||
|
err syncErr
|
||||||
|
|
||||||
// If set, this connection should never use the binary format when
|
// If set, this connection should never use the binary format when
|
||||||
// receiving query results from prepared statements. Only provided for
|
// receiving query results from prepared statements. Only provided for
|
||||||
@ -166,6 +169,40 @@ type conn struct {
|
|||||||
gss GSS
|
gss GSS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type syncErr struct {
|
||||||
|
err error
|
||||||
|
sync.Mutex
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return ErrBadConn if connection is bad.
|
||||||
|
func (e *syncErr) get() error {
|
||||||
|
e.Lock()
|
||||||
|
defer e.Unlock()
|
||||||
|
if e.err != nil {
|
||||||
|
return driver.ErrBadConn
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the error set on the connection. Currently only used by rows.Next.
|
||||||
|
func (e *syncErr) getForNext() error {
|
||||||
|
e.Lock()
|
||||||
|
defer e.Unlock()
|
||||||
|
return e.err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set error, only if it isn't set yet.
|
||||||
|
func (e *syncErr) set(err error) {
|
||||||
|
if err == nil {
|
||||||
|
panic("attempt to set nil err")
|
||||||
|
}
|
||||||
|
e.Lock()
|
||||||
|
defer e.Unlock()
|
||||||
|
if e.err == nil {
|
||||||
|
e.err = err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Handle driver-side settings in parsed connection string.
|
// Handle driver-side settings in parsed connection string.
|
||||||
func (cn *conn) handleDriverSettings(o values) (err error) {
|
func (cn *conn) handleDriverSettings(o values) (err error) {
|
||||||
boolSetting := func(key string, val *bool) error {
|
boolSetting := func(key string, val *bool) error {
|
||||||
@ -287,7 +324,7 @@ func DialOpen(d Dialer, dsn string) (_ driver.Conn, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c.dialer = d
|
c.Dialer(d)
|
||||||
return c.open(context.Background())
|
return c.open(context.Background())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,12 +343,9 @@ func (c *Connector) open(ctx context.Context) (cn *conn, err error) {
|
|||||||
o[k] = v
|
o[k] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
bad := &atomic.Value{}
|
|
||||||
bad.Store(false)
|
|
||||||
cn = &conn{
|
cn = &conn{
|
||||||
opts: o,
|
opts: o,
|
||||||
dialer: c.dialer,
|
dialer: c.dialer,
|
||||||
bad: bad,
|
|
||||||
}
|
}
|
||||||
err = cn.handleDriverSettings(o)
|
err = cn.handleDriverSettings(o)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -516,22 +550,9 @@ func (cn *conn) isInTransaction() bool {
|
|||||||
cn.txnStatus == txnStatusInFailedTransaction
|
cn.txnStatus == txnStatusInFailedTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cn *conn) setBad() {
|
|
||||||
if cn.bad != nil {
|
|
||||||
cn.bad.Store(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cn *conn) getBad() bool {
|
|
||||||
if cn.bad != nil {
|
|
||||||
return cn.bad.Load().(bool)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cn *conn) checkIsInTransaction(intxn bool) {
|
func (cn *conn) checkIsInTransaction(intxn bool) {
|
||||||
if cn.isInTransaction() != intxn {
|
if cn.isInTransaction() != intxn {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected transaction status %v", cn.txnStatus)
|
errorf("unexpected transaction status %v", cn.txnStatus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -541,8 +562,8 @@ func (cn *conn) Begin() (_ driver.Tx, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cn *conn) begin(mode string) (_ driver.Tx, err error) {
|
func (cn *conn) begin(mode string) (_ driver.Tx, err error) {
|
||||||
if cn.getBad() {
|
if err := cn.err.get(); err != nil {
|
||||||
return nil, driver.ErrBadConn
|
return nil, err
|
||||||
}
|
}
|
||||||
defer cn.errRecover(&err)
|
defer cn.errRecover(&err)
|
||||||
|
|
||||||
@ -552,11 +573,11 @@ func (cn *conn) begin(mode string) (_ driver.Tx, err error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if commandTag != "BEGIN" {
|
if commandTag != "BEGIN" {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
return nil, fmt.Errorf("unexpected command tag %s", commandTag)
|
return nil, fmt.Errorf("unexpected command tag %s", commandTag)
|
||||||
}
|
}
|
||||||
if cn.txnStatus != txnStatusIdleInTransaction {
|
if cn.txnStatus != txnStatusIdleInTransaction {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
return nil, fmt.Errorf("unexpected transaction status %v", cn.txnStatus)
|
return nil, fmt.Errorf("unexpected transaction status %v", cn.txnStatus)
|
||||||
}
|
}
|
||||||
return cn, nil
|
return cn, nil
|
||||||
@ -570,8 +591,8 @@ func (cn *conn) closeTxn() {
|
|||||||
|
|
||||||
func (cn *conn) Commit() (err error) {
|
func (cn *conn) Commit() (err error) {
|
||||||
defer cn.closeTxn()
|
defer cn.closeTxn()
|
||||||
if cn.getBad() {
|
if err := cn.err.get(); err != nil {
|
||||||
return driver.ErrBadConn
|
return err
|
||||||
}
|
}
|
||||||
defer cn.errRecover(&err)
|
defer cn.errRecover(&err)
|
||||||
|
|
||||||
@ -592,12 +613,12 @@ func (cn *conn) Commit() (err error) {
|
|||||||
_, commandTag, err := cn.simpleExec("COMMIT")
|
_, commandTag, err := cn.simpleExec("COMMIT")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if cn.isInTransaction() {
|
if cn.isInTransaction() {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if commandTag != "COMMIT" {
|
if commandTag != "COMMIT" {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
return fmt.Errorf("unexpected command tag %s", commandTag)
|
return fmt.Errorf("unexpected command tag %s", commandTag)
|
||||||
}
|
}
|
||||||
cn.checkIsInTransaction(false)
|
cn.checkIsInTransaction(false)
|
||||||
@ -606,8 +627,8 @@ func (cn *conn) Commit() (err error) {
|
|||||||
|
|
||||||
func (cn *conn) Rollback() (err error) {
|
func (cn *conn) Rollback() (err error) {
|
||||||
defer cn.closeTxn()
|
defer cn.closeTxn()
|
||||||
if cn.getBad() {
|
if err := cn.err.get(); err != nil {
|
||||||
return driver.ErrBadConn
|
return err
|
||||||
}
|
}
|
||||||
defer cn.errRecover(&err)
|
defer cn.errRecover(&err)
|
||||||
return cn.rollback()
|
return cn.rollback()
|
||||||
@ -618,7 +639,7 @@ func (cn *conn) rollback() (err error) {
|
|||||||
_, commandTag, err := cn.simpleExec("ROLLBACK")
|
_, commandTag, err := cn.simpleExec("ROLLBACK")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if cn.isInTransaction() {
|
if cn.isInTransaction() {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -658,7 +679,7 @@ func (cn *conn) simpleExec(q string) (res driver.Result, commandTag string, err
|
|||||||
case 'T', 'D':
|
case 'T', 'D':
|
||||||
// ignore any results
|
// ignore any results
|
||||||
default:
|
default:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unknown response for simple query: %q", t)
|
errorf("unknown response for simple query: %q", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -680,7 +701,7 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
|
|||||||
// the user can close, though, to avoid connections from being
|
// the user can close, though, to avoid connections from being
|
||||||
// leaked. A "rows" with done=true works fine for that purpose.
|
// leaked. A "rows" with done=true works fine for that purpose.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected message %q in simple query execution", t)
|
errorf("unexpected message %q in simple query execution", t)
|
||||||
}
|
}
|
||||||
if res == nil {
|
if res == nil {
|
||||||
@ -707,7 +728,7 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
|
|||||||
err = parseError(r)
|
err = parseError(r)
|
||||||
case 'D':
|
case 'D':
|
||||||
if res == nil {
|
if res == nil {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected DataRow in simple query execution")
|
errorf("unexpected DataRow in simple query execution")
|
||||||
}
|
}
|
||||||
// the query didn't fail; kick off to Next
|
// the query didn't fail; kick off to Next
|
||||||
@ -722,7 +743,7 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
|
|||||||
// To work around a bug in QueryRow in Go 1.2 and earlier, wait
|
// To work around a bug in QueryRow in Go 1.2 and earlier, wait
|
||||||
// until the first DataRow has been received.
|
// until the first DataRow has been received.
|
||||||
default:
|
default:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unknown response for simple query: %q", t)
|
errorf("unknown response for simple query: %q", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -815,8 +836,8 @@ func (cn *conn) prepareTo(q, stmtName string) *stmt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cn *conn) Prepare(q string) (_ driver.Stmt, err error) {
|
func (cn *conn) Prepare(q string) (_ driver.Stmt, err error) {
|
||||||
if cn.getBad() {
|
if err := cn.err.get(); err != nil {
|
||||||
return nil, driver.ErrBadConn
|
return nil, err
|
||||||
}
|
}
|
||||||
defer cn.errRecover(&err)
|
defer cn.errRecover(&err)
|
||||||
|
|
||||||
@ -854,8 +875,8 @@ func (cn *conn) Query(query string, args []driver.Value) (driver.Rows, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cn *conn) query(query string, args []driver.Value) (_ *rows, err error) {
|
func (cn *conn) query(query string, args []driver.Value) (_ *rows, err error) {
|
||||||
if cn.getBad() {
|
if err := cn.err.get(); err != nil {
|
||||||
return nil, driver.ErrBadConn
|
return nil, err
|
||||||
}
|
}
|
||||||
if cn.inCopy {
|
if cn.inCopy {
|
||||||
return nil, errCopyInProgress
|
return nil, errCopyInProgress
|
||||||
@ -888,8 +909,8 @@ func (cn *conn) query(query string, args []driver.Value) (_ *rows, err error) {
|
|||||||
|
|
||||||
// Implement the optional "Execer" interface for one-shot queries
|
// Implement the optional "Execer" interface for one-shot queries
|
||||||
func (cn *conn) Exec(query string, args []driver.Value) (res driver.Result, err error) {
|
func (cn *conn) Exec(query string, args []driver.Value) (res driver.Result, err error) {
|
||||||
if cn.getBad() {
|
if err := cn.err.get(); err != nil {
|
||||||
return nil, driver.ErrBadConn
|
return nil, err
|
||||||
}
|
}
|
||||||
defer cn.errRecover(&err)
|
defer cn.errRecover(&err)
|
||||||
|
|
||||||
@ -960,7 +981,7 @@ func (cn *conn) sendSimpleMessage(typ byte) (err error) {
|
|||||||
// the message yourself.
|
// the message yourself.
|
||||||
func (cn *conn) saveMessage(typ byte, buf *readBuf) {
|
func (cn *conn) saveMessage(typ byte, buf *readBuf) {
|
||||||
if cn.saveMessageType != 0 {
|
if cn.saveMessageType != 0 {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected saveMessageType %d", cn.saveMessageType)
|
errorf("unexpected saveMessageType %d", cn.saveMessageType)
|
||||||
}
|
}
|
||||||
cn.saveMessageType = typ
|
cn.saveMessageType = typ
|
||||||
@ -1106,7 +1127,7 @@ func isDriverSetting(key string) bool {
|
|||||||
return true
|
return true
|
||||||
case "password":
|
case "password":
|
||||||
return true
|
return true
|
||||||
case "sslmode", "sslcert", "sslkey", "sslrootcert", "sslinline":
|
case "sslmode", "sslcert", "sslkey", "sslrootcert", "sslinline", "sslsni":
|
||||||
return true
|
return true
|
||||||
case "fallback_application_name":
|
case "fallback_application_name":
|
||||||
return true
|
return true
|
||||||
@ -1330,8 +1351,8 @@ func (st *stmt) Close() (err error) {
|
|||||||
if st.closed {
|
if st.closed {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if st.cn.getBad() {
|
if err := st.cn.err.get(); err != nil {
|
||||||
return driver.ErrBadConn
|
return err
|
||||||
}
|
}
|
||||||
defer st.cn.errRecover(&err)
|
defer st.cn.errRecover(&err)
|
||||||
|
|
||||||
@ -1344,14 +1365,14 @@ func (st *stmt) Close() (err error) {
|
|||||||
|
|
||||||
t, _ := st.cn.recv1()
|
t, _ := st.cn.recv1()
|
||||||
if t != '3' {
|
if t != '3' {
|
||||||
st.cn.setBad()
|
st.cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected close response: %q", t)
|
errorf("unexpected close response: %q", t)
|
||||||
}
|
}
|
||||||
st.closed = true
|
st.closed = true
|
||||||
|
|
||||||
t, r := st.cn.recv1()
|
t, r := st.cn.recv1()
|
||||||
if t != 'Z' {
|
if t != 'Z' {
|
||||||
st.cn.setBad()
|
st.cn.err.set(driver.ErrBadConn)
|
||||||
errorf("expected ready for query, but got: %q", t)
|
errorf("expected ready for query, but got: %q", t)
|
||||||
}
|
}
|
||||||
st.cn.processReadyForQuery(r)
|
st.cn.processReadyForQuery(r)
|
||||||
@ -1364,8 +1385,8 @@ func (st *stmt) Query(v []driver.Value) (r driver.Rows, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (st *stmt) query(v []driver.Value) (r *rows, err error) {
|
func (st *stmt) query(v []driver.Value) (r *rows, err error) {
|
||||||
if st.cn.getBad() {
|
if err := st.cn.err.get(); err != nil {
|
||||||
return nil, driver.ErrBadConn
|
return nil, err
|
||||||
}
|
}
|
||||||
defer st.cn.errRecover(&err)
|
defer st.cn.errRecover(&err)
|
||||||
|
|
||||||
@ -1377,8 +1398,8 @@ func (st *stmt) query(v []driver.Value) (r *rows, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (st *stmt) Exec(v []driver.Value) (res driver.Result, err error) {
|
func (st *stmt) Exec(v []driver.Value) (res driver.Result, err error) {
|
||||||
if st.cn.getBad() {
|
if err := st.cn.err.get(); err != nil {
|
||||||
return nil, driver.ErrBadConn
|
return nil, err
|
||||||
}
|
}
|
||||||
defer st.cn.errRecover(&err)
|
defer st.cn.errRecover(&err)
|
||||||
|
|
||||||
@ -1464,7 +1485,7 @@ func (cn *conn) parseComplete(commandTag string) (driver.Result, string) {
|
|||||||
if affectedRows == nil && strings.HasPrefix(commandTag, "INSERT ") {
|
if affectedRows == nil && strings.HasPrefix(commandTag, "INSERT ") {
|
||||||
parts := strings.Split(commandTag, " ")
|
parts := strings.Split(commandTag, " ")
|
||||||
if len(parts) != 3 {
|
if len(parts) != 3 {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected INSERT command tag %s", commandTag)
|
errorf("unexpected INSERT command tag %s", commandTag)
|
||||||
}
|
}
|
||||||
affectedRows = &parts[len(parts)-1]
|
affectedRows = &parts[len(parts)-1]
|
||||||
@ -1476,7 +1497,7 @@ func (cn *conn) parseComplete(commandTag string) (driver.Result, string) {
|
|||||||
}
|
}
|
||||||
n, err := strconv.ParseInt(*affectedRows, 10, 64)
|
n, err := strconv.ParseInt(*affectedRows, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("could not parse commandTag: %s", err)
|
errorf("could not parse commandTag: %s", err)
|
||||||
}
|
}
|
||||||
return driver.RowsAffected(n), commandTag
|
return driver.RowsAffected(n), commandTag
|
||||||
@ -1543,8 +1564,8 @@ func (rs *rows) Next(dest []driver.Value) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
conn := rs.cn
|
conn := rs.cn
|
||||||
if conn.getBad() {
|
if err := conn.err.getForNext(); err != nil {
|
||||||
return driver.ErrBadConn
|
return err
|
||||||
}
|
}
|
||||||
defer conn.errRecover(&err)
|
defer conn.errRecover(&err)
|
||||||
|
|
||||||
@ -1568,7 +1589,7 @@ func (rs *rows) Next(dest []driver.Value) (err error) {
|
|||||||
case 'D':
|
case 'D':
|
||||||
n := rs.rb.int16()
|
n := rs.rb.int16()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
conn.setBad()
|
conn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected DataRow after error %s", err)
|
errorf("unexpected DataRow after error %s", err)
|
||||||
}
|
}
|
||||||
if n < len(dest) {
|
if n < len(dest) {
|
||||||
@ -1762,7 +1783,7 @@ func (cn *conn) readReadyForQuery() {
|
|||||||
cn.processReadyForQuery(r)
|
cn.processReadyForQuery(r)
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected message %q; expected ReadyForQuery", t)
|
errorf("unexpected message %q; expected ReadyForQuery", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1782,7 +1803,7 @@ func (cn *conn) readParseResponse() {
|
|||||||
cn.readReadyForQuery()
|
cn.readReadyForQuery()
|
||||||
panic(err)
|
panic(err)
|
||||||
default:
|
default:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected Parse response %q", t)
|
errorf("unexpected Parse response %q", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1807,7 +1828,7 @@ func (cn *conn) readStatementDescribeResponse() (paramTyps []oid.Oid, colNames [
|
|||||||
cn.readReadyForQuery()
|
cn.readReadyForQuery()
|
||||||
panic(err)
|
panic(err)
|
||||||
default:
|
default:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected Describe statement response %q", t)
|
errorf("unexpected Describe statement response %q", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1825,7 +1846,7 @@ func (cn *conn) readPortalDescribeResponse() rowsHeader {
|
|||||||
cn.readReadyForQuery()
|
cn.readReadyForQuery()
|
||||||
panic(err)
|
panic(err)
|
||||||
default:
|
default:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected Describe response %q", t)
|
errorf("unexpected Describe response %q", t)
|
||||||
}
|
}
|
||||||
panic("not reached")
|
panic("not reached")
|
||||||
@ -1841,7 +1862,7 @@ func (cn *conn) readBindResponse() {
|
|||||||
cn.readReadyForQuery()
|
cn.readReadyForQuery()
|
||||||
panic(err)
|
panic(err)
|
||||||
default:
|
default:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected Bind response %q", t)
|
errorf("unexpected Bind response %q", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1868,7 +1889,7 @@ func (cn *conn) postExecuteWorkaround() {
|
|||||||
cn.saveMessage(t, r)
|
cn.saveMessage(t, r)
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected message during extended query execution: %q", t)
|
errorf("unexpected message during extended query execution: %q", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1881,7 +1902,7 @@ func (cn *conn) readExecuteResponse(protocolState string) (res driver.Result, co
|
|||||||
switch t {
|
switch t {
|
||||||
case 'C':
|
case 'C':
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected CommandComplete after error %s", err)
|
errorf("unexpected CommandComplete after error %s", err)
|
||||||
}
|
}
|
||||||
res, commandTag = cn.parseComplete(r.string())
|
res, commandTag = cn.parseComplete(r.string())
|
||||||
@ -1895,7 +1916,7 @@ func (cn *conn) readExecuteResponse(protocolState string) (res driver.Result, co
|
|||||||
err = parseError(r)
|
err = parseError(r)
|
||||||
case 'T', 'D', 'I':
|
case 'T', 'D', 'I':
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unexpected %q after error %s", t, err)
|
errorf("unexpected %q after error %s", t, err)
|
||||||
}
|
}
|
||||||
if t == 'I' {
|
if t == 'I' {
|
||||||
@ -1903,7 +1924,7 @@ func (cn *conn) readExecuteResponse(protocolState string) (res driver.Result, co
|
|||||||
}
|
}
|
||||||
// ignore any results
|
// ignore any results
|
||||||
default:
|
default:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
errorf("unknown %s response: %q", protocolState, t)
|
errorf("unknown %s response: %q", protocolState, t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1999,6 +2020,8 @@ func parseEnviron(env []string) (out map[string]string) {
|
|||||||
accrue("sslkey")
|
accrue("sslkey")
|
||||||
case "PGSSLROOTCERT":
|
case "PGSSLROOTCERT":
|
||||||
accrue("sslrootcert")
|
accrue("sslrootcert")
|
||||||
|
case "PGSSLSNI":
|
||||||
|
accrue("sslsni")
|
||||||
case "PGREQUIRESSL", "PGSSLCRL":
|
case "PGREQUIRESSL", "PGSSLCRL":
|
||||||
unsupported()
|
unsupported()
|
||||||
case "PGREQUIREPEER":
|
case "PGREQUIREPEER":
|
||||||
|
8
vendor/github.com/lib/pq/conn_go18.go
generated
vendored
8
vendor/github.com/lib/pq/conn_go18.go
generated
vendored
@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"sync/atomic"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -115,7 +114,7 @@ func (cn *conn) watchCancel(ctx context.Context) func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the connection state to bad so it does not get reused.
|
// Set the connection state to bad so it does not get reused.
|
||||||
cn.setBad()
|
cn.err.set(ctx.Err())
|
||||||
|
|
||||||
// At this point the function level context is canceled,
|
// At this point the function level context is canceled,
|
||||||
// so it must not be used for the additional network
|
// so it must not be used for the additional network
|
||||||
@ -131,7 +130,7 @@ func (cn *conn) watchCancel(ctx context.Context) func() {
|
|||||||
return func() {
|
return func() {
|
||||||
select {
|
select {
|
||||||
case <-finished:
|
case <-finished:
|
||||||
cn.setBad()
|
cn.err.set(ctx.Err())
|
||||||
cn.Close()
|
cn.Close()
|
||||||
case finished <- struct{}{}:
|
case finished <- struct{}{}:
|
||||||
}
|
}
|
||||||
@ -157,11 +156,8 @@ func (cn *conn) cancel(ctx context.Context) error {
|
|||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
||||||
{
|
{
|
||||||
bad := &atomic.Value{}
|
|
||||||
bad.Store(false)
|
|
||||||
can := conn{
|
can := conn{
|
||||||
c: c,
|
c: c,
|
||||||
bad: bad,
|
|
||||||
}
|
}
|
||||||
err = can.ssl(o)
|
err = can.ssl(o)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
5
vendor/github.com/lib/pq/connector.go
generated
vendored
5
vendor/github.com/lib/pq/connector.go
generated
vendored
@ -27,6 +27,11 @@ func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) {
|
|||||||
return c.open(ctx)
|
return c.open(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dialer allows change the dialer used to open connections.
|
||||||
|
func (c *Connector) Dialer(dialer Dialer) {
|
||||||
|
c.dialer = dialer
|
||||||
|
}
|
||||||
|
|
||||||
// Driver returns the underlying driver of this Connector.
|
// Driver returns the underlying driver of this Connector.
|
||||||
func (c *Connector) Driver() driver.Driver {
|
func (c *Connector) Driver() driver.Driver {
|
||||||
return &Driver{}
|
return &Driver{}
|
||||||
|
112
vendor/github.com/lib/pq/copy.go
generated
vendored
112
vendor/github.com/lib/pq/copy.go
generated
vendored
@ -1,6 +1,7 @@
|
|||||||
package pq
|
package pq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
@ -49,12 +50,14 @@ type copyin struct {
|
|||||||
buffer []byte
|
buffer []byte
|
||||||
rowData chan []byte
|
rowData chan []byte
|
||||||
done chan bool
|
done chan bool
|
||||||
driver.Result
|
|
||||||
|
|
||||||
closed bool
|
closed bool
|
||||||
|
|
||||||
sync.Mutex // guards err
|
mu struct {
|
||||||
|
sync.Mutex
|
||||||
err error
|
err error
|
||||||
|
driver.Result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ciBufferSize = 64 * 1024
|
const ciBufferSize = 64 * 1024
|
||||||
@ -98,13 +101,13 @@ awaitCopyInResponse:
|
|||||||
err = parseError(r)
|
err = parseError(r)
|
||||||
case 'Z':
|
case 'Z':
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ci.setBad()
|
ci.setBad(driver.ErrBadConn)
|
||||||
errorf("unexpected ReadyForQuery in response to COPY")
|
errorf("unexpected ReadyForQuery in response to COPY")
|
||||||
}
|
}
|
||||||
cn.processReadyForQuery(r)
|
cn.processReadyForQuery(r)
|
||||||
return nil, err
|
return nil, err
|
||||||
default:
|
default:
|
||||||
ci.setBad()
|
ci.setBad(driver.ErrBadConn)
|
||||||
errorf("unknown response for copy query: %q", t)
|
errorf("unknown response for copy query: %q", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,7 +126,7 @@ awaitCopyInResponse:
|
|||||||
cn.processReadyForQuery(r)
|
cn.processReadyForQuery(r)
|
||||||
return nil, err
|
return nil, err
|
||||||
default:
|
default:
|
||||||
ci.setBad()
|
ci.setBad(driver.ErrBadConn)
|
||||||
errorf("unknown response for CopyFail: %q", t)
|
errorf("unknown response for CopyFail: %q", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,7 +147,7 @@ func (ci *copyin) resploop() {
|
|||||||
var r readBuf
|
var r readBuf
|
||||||
t, err := ci.cn.recvMessage(&r)
|
t, err := ci.cn.recvMessage(&r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ci.setBad()
|
ci.setBad(driver.ErrBadConn)
|
||||||
ci.setError(err)
|
ci.setError(err)
|
||||||
ci.done <- true
|
ci.done <- true
|
||||||
return
|
return
|
||||||
@ -166,7 +169,7 @@ func (ci *copyin) resploop() {
|
|||||||
err := parseError(&r)
|
err := parseError(&r)
|
||||||
ci.setError(err)
|
ci.setError(err)
|
||||||
default:
|
default:
|
||||||
ci.setBad()
|
ci.setBad(driver.ErrBadConn)
|
||||||
ci.setError(fmt.Errorf("unknown response during CopyIn: %q", t))
|
ci.setError(fmt.Errorf("unknown response during CopyIn: %q", t))
|
||||||
ci.done <- true
|
ci.done <- true
|
||||||
return
|
return
|
||||||
@ -174,46 +177,41 @@ func (ci *copyin) resploop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ci *copyin) setBad() {
|
func (ci *copyin) setBad(err error) {
|
||||||
ci.Lock()
|
ci.cn.err.set(err)
|
||||||
ci.cn.setBad()
|
|
||||||
ci.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ci *copyin) isBad() bool {
|
func (ci *copyin) getBad() error {
|
||||||
ci.Lock()
|
return ci.cn.err.get()
|
||||||
b := ci.cn.getBad()
|
|
||||||
ci.Unlock()
|
|
||||||
return b
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ci *copyin) isErrorSet() bool {
|
func (ci *copyin) err() error {
|
||||||
ci.Lock()
|
ci.mu.Lock()
|
||||||
isSet := (ci.err != nil)
|
err := ci.mu.err
|
||||||
ci.Unlock()
|
ci.mu.Unlock()
|
||||||
return isSet
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// setError() sets ci.err if one has not been set already. Caller must not be
|
// setError() sets ci.err if one has not been set already. Caller must not be
|
||||||
// holding ci.Mutex.
|
// holding ci.Mutex.
|
||||||
func (ci *copyin) setError(err error) {
|
func (ci *copyin) setError(err error) {
|
||||||
ci.Lock()
|
ci.mu.Lock()
|
||||||
if ci.err == nil {
|
if ci.mu.err == nil {
|
||||||
ci.err = err
|
ci.mu.err = err
|
||||||
}
|
}
|
||||||
ci.Unlock()
|
ci.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ci *copyin) setResult(result driver.Result) {
|
func (ci *copyin) setResult(result driver.Result) {
|
||||||
ci.Lock()
|
ci.mu.Lock()
|
||||||
ci.Result = result
|
ci.mu.Result = result
|
||||||
ci.Unlock()
|
ci.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ci *copyin) getResult() driver.Result {
|
func (ci *copyin) getResult() driver.Result {
|
||||||
ci.Lock()
|
ci.mu.Lock()
|
||||||
result := ci.Result
|
result := ci.mu.Result
|
||||||
ci.Unlock()
|
ci.mu.Unlock()
|
||||||
if result == nil {
|
if result == nil {
|
||||||
return driver.RowsAffected(0)
|
return driver.RowsAffected(0)
|
||||||
}
|
}
|
||||||
@ -240,13 +238,13 @@ func (ci *copyin) Exec(v []driver.Value) (r driver.Result, err error) {
|
|||||||
return nil, errCopyInClosed
|
return nil, errCopyInClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
if ci.isBad() {
|
if err := ci.getBad(); err != nil {
|
||||||
return nil, driver.ErrBadConn
|
return nil, err
|
||||||
}
|
}
|
||||||
defer ci.cn.errRecover(&err)
|
defer ci.cn.errRecover(&err)
|
||||||
|
|
||||||
if ci.isErrorSet() {
|
if err := ci.err(); err != nil {
|
||||||
return nil, ci.err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(v) == 0 {
|
if len(v) == 0 {
|
||||||
@ -276,14 +274,51 @@ func (ci *copyin) Exec(v []driver.Value) (r driver.Result, err error) {
|
|||||||
return driver.RowsAffected(0), nil
|
return driver.RowsAffected(0), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CopyData inserts a raw string into the COPY stream. The insert is
|
||||||
|
// asynchronous and CopyData can return errors from previous CopyData calls to
|
||||||
|
// the same COPY stmt.
|
||||||
|
//
|
||||||
|
// You need to call Exec(nil) to sync the COPY stream and to get any
|
||||||
|
// errors from pending data, since Stmt.Close() doesn't return errors
|
||||||
|
// to the user.
|
||||||
|
func (ci *copyin) CopyData(ctx context.Context, line string) (r driver.Result, err error) {
|
||||||
|
if ci.closed {
|
||||||
|
return nil, errCopyInClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
if finish := ci.cn.watchCancel(ctx); finish != nil {
|
||||||
|
defer finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := ci.getBad(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer ci.cn.errRecover(&err)
|
||||||
|
|
||||||
|
if err := ci.err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ci.buffer = append(ci.buffer, []byte(line)...)
|
||||||
|
ci.buffer = append(ci.buffer, '\n')
|
||||||
|
|
||||||
|
if len(ci.buffer) > ciBufferFlushSize {
|
||||||
|
ci.flush(ci.buffer)
|
||||||
|
// reset buffer, keep bytes for message identifier and length
|
||||||
|
ci.buffer = ci.buffer[:5]
|
||||||
|
}
|
||||||
|
|
||||||
|
return driver.RowsAffected(0), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ci *copyin) Close() (err error) {
|
func (ci *copyin) Close() (err error) {
|
||||||
if ci.closed { // Don't do anything, we're already closed
|
if ci.closed { // Don't do anything, we're already closed
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
ci.closed = true
|
ci.closed = true
|
||||||
|
|
||||||
if ci.isBad() {
|
if err := ci.getBad(); err != nil {
|
||||||
return driver.ErrBadConn
|
return err
|
||||||
}
|
}
|
||||||
defer ci.cn.errRecover(&err)
|
defer ci.cn.errRecover(&err)
|
||||||
|
|
||||||
@ -299,8 +334,7 @@ func (ci *copyin) Close() (err error) {
|
|||||||
<-ci.done
|
<-ci.done
|
||||||
ci.cn.inCopy = false
|
ci.cn.inCopy = false
|
||||||
|
|
||||||
if ci.isErrorSet() {
|
if err := ci.err(); err != nil {
|
||||||
err = ci.err
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
10
vendor/github.com/lib/pq/encode.go
generated
vendored
10
vendor/github.com/lib/pq/encode.go
generated
vendored
@ -422,7 +422,7 @@ func ParseTimestamp(currentLocation *time.Location, str string) (time.Time, erro
|
|||||||
|
|
||||||
if remainderIdx < len(str) && str[remainderIdx] == '.' {
|
if remainderIdx < len(str) && str[remainderIdx] == '.' {
|
||||||
fracStart := remainderIdx + 1
|
fracStart := remainderIdx + 1
|
||||||
fracOff := strings.IndexAny(str[fracStart:], "-+ ")
|
fracOff := strings.IndexAny(str[fracStart:], "-+Z ")
|
||||||
if fracOff < 0 {
|
if fracOff < 0 {
|
||||||
fracOff = len(str) - fracStart
|
fracOff = len(str) - fracStart
|
||||||
}
|
}
|
||||||
@ -432,7 +432,7 @@ func ParseTimestamp(currentLocation *time.Location, str string) (time.Time, erro
|
|||||||
remainderIdx += fracOff + 1
|
remainderIdx += fracOff + 1
|
||||||
}
|
}
|
||||||
if tzStart := remainderIdx; tzStart < len(str) && (str[tzStart] == '-' || str[tzStart] == '+') {
|
if tzStart := remainderIdx; tzStart < len(str) && (str[tzStart] == '-' || str[tzStart] == '+') {
|
||||||
// time zone separator is always '-' or '+' (UTC is +00)
|
// time zone separator is always '-' or '+' or 'Z' (UTC is +00)
|
||||||
var tzSign int
|
var tzSign int
|
||||||
switch c := str[tzStart]; c {
|
switch c := str[tzStart]; c {
|
||||||
case '-':
|
case '-':
|
||||||
@ -454,7 +454,11 @@ func ParseTimestamp(currentLocation *time.Location, str string) (time.Time, erro
|
|||||||
remainderIdx += 3
|
remainderIdx += 3
|
||||||
}
|
}
|
||||||
tzOff = tzSign * ((tzHours * 60 * 60) + (tzMin * 60) + tzSec)
|
tzOff = tzSign * ((tzHours * 60 * 60) + (tzMin * 60) + tzSec)
|
||||||
|
} else if tzStart < len(str) && str[tzStart] == 'Z' {
|
||||||
|
// time zone Z separator indicates UTC is +00
|
||||||
|
remainderIdx += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
var isoYear int
|
var isoYear int
|
||||||
|
|
||||||
if isBC {
|
if isBC {
|
||||||
@ -559,7 +563,7 @@ func parseBytea(s []byte) (result []byte, err error) {
|
|||||||
if len(s) < 4 {
|
if len(s) < 4 {
|
||||||
return nil, fmt.Errorf("invalid bytea sequence %v", s)
|
return nil, fmt.Errorf("invalid bytea sequence %v", s)
|
||||||
}
|
}
|
||||||
r, err := strconv.ParseInt(string(s[1:4]), 8, 9)
|
r, err := strconv.ParseUint(string(s[1:4]), 8, 8)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not parse bytea value: %s", err.Error())
|
return nil, fmt.Errorf("could not parse bytea value: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
17
vendor/github.com/lib/pq/error.go
generated
vendored
17
vendor/github.com/lib/pq/error.go
generated
vendored
@ -402,6 +402,11 @@ func (err *Error) Fatal() bool {
|
|||||||
return err.Severity == Efatal
|
return err.Severity == Efatal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SQLState returns the SQLState of the error.
|
||||||
|
func (err *Error) SQLState() string {
|
||||||
|
return string(err.Code)
|
||||||
|
}
|
||||||
|
|
||||||
// Get implements the legacy PGError interface. New code should use the fields
|
// Get implements the legacy PGError interface. New code should use the fields
|
||||||
// of the Error struct directly.
|
// of the Error struct directly.
|
||||||
func (err *Error) Get(k byte) (v string) {
|
func (err *Error) Get(k byte) (v string) {
|
||||||
@ -444,7 +449,7 @@ func (err *Error) Get(k byte) (v string) {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err Error) Error() string {
|
func (err *Error) Error() string {
|
||||||
return "pq: " + err.Message
|
return "pq: " + err.Message
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +489,7 @@ func (cn *conn) errRecover(err *error) {
|
|||||||
case nil:
|
case nil:
|
||||||
// Do nothing
|
// Do nothing
|
||||||
case runtime.Error:
|
case runtime.Error:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
panic(v)
|
panic(v)
|
||||||
case *Error:
|
case *Error:
|
||||||
if v.Fatal() {
|
if v.Fatal() {
|
||||||
@ -493,10 +498,10 @@ func (cn *conn) errRecover(err *error) {
|
|||||||
*err = v
|
*err = v
|
||||||
}
|
}
|
||||||
case *net.OpError:
|
case *net.OpError:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
*err = v
|
*err = v
|
||||||
case *safeRetryError:
|
case *safeRetryError:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
*err = driver.ErrBadConn
|
*err = driver.ErrBadConn
|
||||||
case error:
|
case error:
|
||||||
if v == io.EOF || v.Error() == "remote error: handshake failure" {
|
if v == io.EOF || v.Error() == "remote error: handshake failure" {
|
||||||
@ -506,13 +511,13 @@ func (cn *conn) errRecover(err *error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
panic(fmt.Sprintf("unknown error: %#v", e))
|
panic(fmt.Sprintf("unknown error: %#v", e))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any time we return ErrBadConn, we need to remember it since *Tx doesn't
|
// Any time we return ErrBadConn, we need to remember it since *Tx doesn't
|
||||||
// mark the connection bad in database/sql.
|
// mark the connection bad in database/sql.
|
||||||
if *err == driver.ErrBadConn {
|
if *err == driver.ErrBadConn {
|
||||||
cn.setBad()
|
cn.err.set(driver.ErrBadConn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
vendor/github.com/lib/pq/ssl.go
generated
vendored
11
vendor/github.com/lib/pq/ssl.go
generated
vendored
@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ssl generates a function to upgrade a net.Conn based on the "sslmode" and
|
// ssl generates a function to upgrade a net.Conn based on the "sslmode" and
|
||||||
@ -50,6 +51,16 @@ func ssl(o values) (func(net.Conn) (net.Conn, error), error) {
|
|||||||
return nil, fmterrorf(`unsupported sslmode %q; only "require" (default), "verify-full", "verify-ca", and "disable" supported`, mode)
|
return nil, fmterrorf(`unsupported sslmode %q; only "require" (default), "verify-full", "verify-ca", and "disable" supported`, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set Server Name Indication (SNI), if enabled by connection parameters.
|
||||||
|
// By default SNI is on, any value which is not starting with "1" disables
|
||||||
|
// SNI -- that is the same check vanilla libpq uses.
|
||||||
|
if sslsni := o["sslsni"]; sslsni == "" || strings.HasPrefix(sslsni, "1") {
|
||||||
|
// RFC 6066 asks to not set SNI if the host is a literal IP address (IPv4
|
||||||
|
// or IPv6). This check is coded already crypto.tls.hostnameInSNI, so
|
||||||
|
// just always set ServerName here and let crypto/tls do the filtering.
|
||||||
|
tlsConf.ServerName = o["host"]
|
||||||
|
}
|
||||||
|
|
||||||
err := sslClientCertificates(&tlsConf, o)
|
err := sslClientCertificates(&tlsConf, o)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
78
vendor/github.com/lib/pq/ssl_permissions.go
generated
vendored
78
vendor/github.com/lib/pq/ssl_permissions.go
generated
vendored
@ -3,7 +3,28 @@
|
|||||||
|
|
||||||
package pq
|
package pq
|
||||||
|
|
||||||
import "os"
|
import (
|
||||||
|
"errors"
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
rootUserID = uint32(0)
|
||||||
|
|
||||||
|
// The maximum permissions that a private key file owned by a regular user
|
||||||
|
// is allowed to have. This translates to u=rw.
|
||||||
|
maxUserOwnedKeyPermissions os.FileMode = 0600
|
||||||
|
|
||||||
|
// The maximum permissions that a private key file owned by root is allowed
|
||||||
|
// to have. This translates to u=rw,g=r.
|
||||||
|
maxRootOwnedKeyPermissions os.FileMode = 0640
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errSSLKeyHasUnacceptableUserPermissions = errors.New("permissions for files not owned by root should be u=rw (0600) or less")
|
||||||
|
errSSLKeyHasUnacceptableRootPermissions = errors.New("permissions for root owned files should be u=rw,g=r (0640) or less")
|
||||||
|
)
|
||||||
|
|
||||||
// sslKeyPermissions checks the permissions on user-supplied ssl key files.
|
// sslKeyPermissions checks the permissions on user-supplied ssl key files.
|
||||||
// The key file should have very little access.
|
// The key file should have very little access.
|
||||||
@ -14,8 +35,59 @@ func sslKeyPermissions(sslkey string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if info.Mode().Perm()&0077 != 0 {
|
|
||||||
return ErrSSLKeyHasWorldPermissions
|
err = hasCorrectPermissions(info)
|
||||||
|
|
||||||
|
// return ErrSSLKeyHasWorldPermissions for backwards compatability with
|
||||||
|
// existing code.
|
||||||
|
if err == errSSLKeyHasUnacceptableUserPermissions || err == errSSLKeyHasUnacceptableRootPermissions {
|
||||||
|
err = ErrSSLKeyHasWorldPermissions
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// hasCorrectPermissions checks the file info (and the unix-specific stat_t
|
||||||
|
// output) to verify that the permissions on the file are correct.
|
||||||
|
//
|
||||||
|
// If the file is owned by the same user the process is running as,
|
||||||
|
// the file should only have 0600 (u=rw). If the file is owned by root,
|
||||||
|
// and the group matches the group that the process is running in, the
|
||||||
|
// permissions cannot be more than 0640 (u=rw,g=r). The file should
|
||||||
|
// never have world permissions.
|
||||||
|
//
|
||||||
|
// Returns an error when the permission check fails.
|
||||||
|
func hasCorrectPermissions(info os.FileInfo) error {
|
||||||
|
// if file's permission matches 0600, allow access.
|
||||||
|
userPermissionMask := (os.FileMode(0777) ^ maxUserOwnedKeyPermissions)
|
||||||
|
|
||||||
|
// regardless of if we're running as root or not, 0600 is acceptable,
|
||||||
|
// so we return if we match the regular user permission mask.
|
||||||
|
if info.Mode().Perm()&userPermissionMask == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need to pull the Unix file information to get the file's owner.
|
||||||
|
// If we can't access it, there's some sort of operating system level error
|
||||||
|
// and we should fail rather than attempting to use faulty information.
|
||||||
|
sysInfo := info.Sys()
|
||||||
|
if sysInfo == nil {
|
||||||
|
return ErrSSLKeyUnknownOwnership
|
||||||
|
}
|
||||||
|
|
||||||
|
unixStat, ok := sysInfo.(*syscall.Stat_t)
|
||||||
|
if !ok {
|
||||||
|
return ErrSSLKeyUnknownOwnership
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the file is owned by root, we allow 0640 (u=rw,g=r) to match what
|
||||||
|
// Postgres does.
|
||||||
|
if unixStat.Uid == rootUserID {
|
||||||
|
rootPermissionMask := (os.FileMode(0777) ^ maxRootOwnedKeyPermissions)
|
||||||
|
if info.Mode().Perm()&rootPermissionMask != 0 {
|
||||||
|
return errSSLKeyHasUnacceptableRootPermissions
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return errSSLKeyHasUnacceptableUserPermissions
|
||||||
}
|
}
|
||||||
|
4
vendor/github.com/lib/pq/user_posix.go
generated
vendored
4
vendor/github.com/lib/pq/user_posix.go
generated
vendored
@ -1,7 +1,7 @@
|
|||||||
// Package pq is a pure Go Postgres driver for the database/sql package.
|
// Package pq is a pure Go Postgres driver for the database/sql package.
|
||||||
|
|
||||||
//go:build aix || darwin || dragonfly || freebsd || linux || nacl || netbsd || openbsd || plan9 || solaris || rumprun || illumos
|
//go:build aix || darwin || dragonfly || freebsd || (linux && !android) || nacl || netbsd || openbsd || plan9 || solaris || rumprun || illumos
|
||||||
// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris rumprun illumos
|
// +build aix darwin dragonfly freebsd linux,!android nacl netbsd openbsd plan9 solaris rumprun illumos
|
||||||
|
|
||||||
package pq
|
package pq
|
||||||
|
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -42,7 +42,7 @@ github.com/gorilla/mux
|
|||||||
# github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
|
# github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
|
||||||
## explicit
|
## explicit
|
||||||
github.com/kballard/go-shellquote
|
github.com/kballard/go-shellquote
|
||||||
# github.com/lib/pq v1.10.3
|
# github.com/lib/pq v1.10.7
|
||||||
## explicit; go 1.13
|
## explicit; go 1.13
|
||||||
github.com/lib/pq
|
github.com/lib/pq
|
||||||
github.com/lib/pq/oid
|
github.com/lib/pq/oid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user