Source File
conn_go18.go
Belonging Package
github.com/lib/pq
package pq
import (
)
case sql.LevelReadUncommitted:
= " ISOLATION LEVEL READ UNCOMMITTED"
case sql.LevelReadCommitted:
= " ISOLATION LEVEL READ COMMITTED"
case sql.LevelRepeatableRead:
= " ISOLATION LEVEL REPEATABLE READ"
case sql.LevelSerializable:
= " ISOLATION LEVEL SERIALIZABLE"
default:
return nil, fmt.Errorf("pq: isolation level not supported: %d", .Isolation)
}
if .ReadOnly {
+= " READ ONLY"
} else {
+= " READ WRITE"
}
, := .begin()
if != nil {
return nil,
}
.txnFinish = .watchCancel()
return , nil
}
func ( *conn) ( context.Context) error {
if := .watchCancel(); != nil {
defer ()
}
, := .simpleQuery(";")
if != nil {
return driver.ErrBadConn // https://golang.org/pkg/database/sql/driver/#Pinger
}
.Close()
return nil
}
func ( *conn) ( context.Context) func() {
if := .Done(); != nil {
:= make(chan struct{})
go func() {
select {
, := context.WithTimeout(context.Background(), time.Second*10)
defer ()
_ = .cancel()
<- struct{}{}
case <-:
}
}()
return func() {
select {
case <-:
case <- struct{}{}:
}
}
}
return nil
}
func ( *conn) ( context.Context) error {
, := dial(, .dialer, .opts)
if != nil {
return
}
defer .Close()
{
:= conn{
c: ,
}
= .ssl(.opts)
if != nil {
return
}
:= .writeBuf(0)
.int32(80877102) // cancel request code
.int32(.processID)
.int32(.secretKey)
if := .sendStartupPacket(); != nil {
return
}
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |