Upgrading server dependancies (#8154)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8d66523ba7
Коммит
961c04cae9
10
vendor/github.com/lib/pq/conn.go
сгенерированный
поставляемый
10
vendor/github.com/lib/pq/conn.go
сгенерированный
поставляемый
@@ -339,6 +339,15 @@ func DialOpen(d Dialer, name string) (_ driver.Conn, err error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// cn.ssl and cn.startup panic on error. Make sure we don't leak cn.c.
|
||||
panicking := true
|
||||
defer func() {
|
||||
if panicking {
|
||||
cn.c.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
cn.ssl(o)
|
||||
cn.buf = bufio.NewReader(cn.c)
|
||||
cn.startup(o)
|
||||
@@ -347,6 +356,7 @@ func DialOpen(d Dialer, name string) (_ driver.Conn, err error) {
|
||||
if timeout, ok := o["connect_timeout"]; ok && timeout != "0" {
|
||||
err = cn.c.SetDeadline(time.Time{})
|
||||
}
|
||||
panicking = false
|
||||
return cn, err
|
||||
}
|
||||
|
||||
|
||||
58
vendor/github.com/lib/pq/conn_test.go
сгенерированный
поставляемый
58
vendor/github.com/lib/pq/conn_test.go
сгенерированный
поставляемый
@@ -28,7 +28,7 @@ func forceBinaryParameters() bool {
|
||||
}
|
||||
}
|
||||
|
||||
func openTestConnConninfo(conninfo string) (*sql.DB, error) {
|
||||
func testConninfo(conninfo string) string {
|
||||
defaultTo := func(envvar string, value string) {
|
||||
if os.Getenv(envvar) == "" {
|
||||
os.Setenv(envvar, value)
|
||||
@@ -43,8 +43,11 @@ func openTestConnConninfo(conninfo string) (*sql.DB, error) {
|
||||
!strings.HasPrefix(conninfo, "postgresql://") {
|
||||
conninfo = conninfo + " binary_parameters=yes"
|
||||
}
|
||||
return conninfo
|
||||
}
|
||||
|
||||
return sql.Open("postgres", conninfo)
|
||||
func openTestConnConninfo(conninfo string) (*sql.DB, error) {
|
||||
return sql.Open("postgres", testConninfo(conninfo))
|
||||
}
|
||||
|
||||
func openTestConn(t Fatalistic) *sql.DB {
|
||||
@@ -637,6 +640,57 @@ func TestErrorDuringStartup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type testConn struct {
|
||||
closed bool
|
||||
net.Conn
|
||||
}
|
||||
|
||||
func (c *testConn) Close() error {
|
||||
c.closed = true
|
||||
return c.Conn.Close()
|
||||
}
|
||||
|
||||
type testDialer struct {
|
||||
conns []*testConn
|
||||
}
|
||||
|
||||
func (d *testDialer) Dial(ntw, addr string) (net.Conn, error) {
|
||||
c, err := net.Dial(ntw, addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tc := &testConn{Conn: c}
|
||||
d.conns = append(d.conns, tc)
|
||||
return tc, nil
|
||||
}
|
||||
|
||||
func (d *testDialer) DialTimeout(ntw, addr string, timeout time.Duration) (net.Conn, error) {
|
||||
c, err := net.DialTimeout(ntw, addr, timeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tc := &testConn{Conn: c}
|
||||
d.conns = append(d.conns, tc)
|
||||
return tc, nil
|
||||
}
|
||||
|
||||
func TestErrorDuringStartupClosesConn(t *testing.T) {
|
||||
// Don't use the normal connection setup, this is intended to
|
||||
// blow up in the startup packet from a non-existent user.
|
||||
var d testDialer
|
||||
c, err := DialOpen(&d, testConninfo("user=thisuserreallydoesntexist"))
|
||||
if err == nil {
|
||||
c.Close()
|
||||
t.Fatal("expected dial error")
|
||||
}
|
||||
if len(d.conns) != 1 {
|
||||
t.Fatalf("got len(d.conns) = %d, want = %d", len(d.conns), 1)
|
||||
}
|
||||
if !d.conns[0].closed {
|
||||
t.Error("connection leaked")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBadConn(t *testing.T) {
|
||||
var err error
|
||||
|
||||
|
||||
1
vendor/github.com/lib/pq/error.go
сгенерированный
поставляемый
1
vendor/github.com/lib/pq/error.go
сгенерированный
поставляемый
@@ -153,6 +153,7 @@ var errorCodeNames = map[ErrorCode]string{
|
||||
"22004": "null_value_not_allowed",
|
||||
"22002": "null_value_no_indicator_parameter",
|
||||
"22003": "numeric_value_out_of_range",
|
||||
"2200H": "sequence_generator_limit_exceeded",
|
||||
"22026": "string_data_length_mismatch",
|
||||
"22001": "string_data_right_truncation",
|
||||
"22011": "substring_error",
|
||||
|
||||
4
vendor/github.com/lib/pq/notify.go
сгенерированный
поставляемый
4
vendor/github.com/lib/pq/notify.go
сгенерированный
поставляемый
@@ -637,7 +637,7 @@ func (l *Listener) disconnectCleanup() error {
|
||||
// after the connection has been established.
|
||||
func (l *Listener) resync(cn *ListenerConn, notificationChan <-chan *Notification) error {
|
||||
doneChan := make(chan error)
|
||||
go func() {
|
||||
go func(notificationChan <-chan *Notification) {
|
||||
for channel := range l.channels {
|
||||
// If we got a response, return that error to our caller as it's
|
||||
// going to be more descriptive than cn.Err().
|
||||
@@ -658,7 +658,7 @@ func (l *Listener) resync(cn *ListenerConn, notificationChan <-chan *Notificatio
|
||||
}
|
||||
}
|
||||
doneChan <- nil
|
||||
}()
|
||||
}(notificationChan)
|
||||
|
||||
// Ignore notifications while synchronization is going on to avoid
|
||||
// deadlocks. We have to send a nil notification over Notify anyway as
|
||||
|
||||
Ссылка в новой задаче
Block a user