summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/lib/pq/conn.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-08-17 17:19:06 -0700
committerGitHub <noreply@github.com>2017-08-17 17:19:06 -0700
commit96eab1202717e073782ec399a4e0820cae15b1bb (patch)
tree011012982be971c7e9ef91466f026bc0956ac9a2 /vendor/github.com/lib/pq/conn.go
parent2c895ee66eed626721135acfcc48254c6e3f3b29 (diff)
downloadchat-96eab1202717e073782ec399a4e0820cae15b1bb.tar.gz
chat-96eab1202717e073782ec399a4e0820cae15b1bb.tar.bz2
chat-96eab1202717e073782ec399a4e0820cae15b1bb.zip
Updating server dependancies. (#7246)
Diffstat (limited to 'vendor/github.com/lib/pq/conn.go')
-rw-r--r--vendor/github.com/lib/pq/conn.go83
1 files changed, 40 insertions, 43 deletions
diff --git a/vendor/github.com/lib/pq/conn.go b/vendor/github.com/lib/pq/conn.go
index 3747ffcaf..1725ab0d3 100644
--- a/vendor/github.com/lib/pq/conn.go
+++ b/vendor/github.com/lib/pq/conn.go
@@ -27,12 +27,12 @@ var (
ErrNotSupported = errors.New("pq: Unsupported command")
ErrInFailedTransaction = errors.New("pq: Could not complete operation in a failed transaction")
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.")
- ErrCouldNotDetectUsername = errors.New("pq: Could not detect default username. Please provide one explicitly.")
+ ErrSSLKeyHasWorldPermissions = errors.New("pq: Private key file has group or world access. Permissions should be u=rw (0600) or less")
+ ErrCouldNotDetectUsername = errors.New("pq: Could not detect default username. Please provide one explicitly")
errUnexpectedReady = errors.New("unexpected ReadyForQuery")
errNoRowsAffected = errors.New("no RowsAffected available after the empty statement")
- errNoLastInsertId = errors.New("no LastInsertId available after the empty statement")
+ errNoLastInsertID = errors.New("no LastInsertId available after the empty statement")
)
type Driver struct{}
@@ -131,7 +131,7 @@ type conn struct {
}
// Handle driver-side settings in parsed connection string.
-func (c *conn) handleDriverSettings(o values) (err error) {
+func (cn *conn) handleDriverSettings(o values) (err error) {
boolSetting := func(key string, val *bool) error {
if value, ok := o[key]; ok {
if value == "yes" {
@@ -145,18 +145,18 @@ func (c *conn) handleDriverSettings(o values) (err error) {
return nil
}
- err = boolSetting("disable_prepared_binary_result", &c.disablePreparedBinaryResult)
+ err = boolSetting("disable_prepared_binary_result", &cn.disablePreparedBinaryResult)
if err != nil {
return err
}
- err = boolSetting("binary_parameters", &c.binaryParameters)
+ err = boolSetting("binary_parameters", &cn.binaryParameters)
if err != nil {
return err
}
return nil
}
-func (c *conn) handlePgpass(o values) {
+func (cn *conn) handlePgpass(o values) {
// if a password was supplied, do not process .pgpass
if _, ok := o["password"]; ok {
return
@@ -229,10 +229,10 @@ func (c *conn) handlePgpass(o values) {
}
}
-func (c *conn) writeBuf(b byte) *writeBuf {
- c.scratch[0] = b
+func (cn *conn) writeBuf(b byte) *writeBuf {
+ cn.scratch[0] = b
return &writeBuf{
- buf: c.scratch[:5],
+ buf: cn.scratch[:5],
pos: 1,
}
}
@@ -310,9 +310,8 @@ func DialOpen(d Dialer, name string) (_ driver.Conn, err error) {
u, err := userCurrent()
if err != nil {
return nil, err
- } else {
- o["user"] = u
}
+ o["user"] = u
}
cn := &conn{
@@ -698,7 +697,7 @@ var emptyRows noRows
var _ driver.Result = noRows{}
func (noRows) LastInsertId() (int64, error) {
- return 0, errNoLastInsertId
+ return 0, errNoLastInsertID
}
func (noRows) RowsAffected() (int64, error) {
@@ -840,16 +839,15 @@ func (cn *conn) query(query string, args []driver.Value) (_ *rows, err error) {
rows.colNames, rows.colFmts, rows.colTyps = cn.readPortalDescribeResponse()
cn.postExecuteWorkaround()
return rows, nil
- } else {
- st := cn.prepareTo(query, "")
- st.exec(args)
- return &rows{
- cn: cn,
- colNames: st.colNames,
- colTyps: st.colTyps,
- colFmts: st.colFmts,
- }, nil
}
+ st := cn.prepareTo(query, "")
+ st.exec(args)
+ return &rows{
+ cn: cn,
+ colNames: st.colNames,
+ colTyps: st.colTyps,
+ colFmts: st.colFmts,
+ }, nil
}
// Implement the optional "Execer" interface for one-shot queries
@@ -876,17 +874,16 @@ func (cn *conn) Exec(query string, args []driver.Value) (res driver.Result, err
cn.postExecuteWorkaround()
res, _, err = cn.readExecuteResponse("Execute")
return res, err
- } else {
- // Use the unnamed statement to defer planning until bind
- // time, or else value-based selectivity estimates cannot be
- // used.
- st := cn.prepareTo(query, "")
- r, err := st.Exec(args)
- if err != nil {
- panic(err)
- }
- return r, err
}
+ // Use the unnamed statement to defer planning until bind
+ // time, or else value-based selectivity estimates cannot be
+ // used.
+ st := cn.prepareTo(query, "")
+ r, err := st.Exec(args)
+ if err != nil {
+ panic(err)
+ }
+ return r, err
}
func (cn *conn) send(m *writeBuf) {
@@ -1147,10 +1144,10 @@ const formatText format = 0
const formatBinary format = 1
// One result-column format code with the value 1 (i.e. all binary).
-var colFmtDataAllBinary []byte = []byte{0, 1, 0, 1}
+var colFmtDataAllBinary = []byte{0, 1, 0, 1}
// No result-column format codes (i.e. all text).
-var colFmtDataAllText []byte = []byte{0, 0}
+var colFmtDataAllText = []byte{0, 0}
type stmt struct {
cn *conn
@@ -1515,7 +1512,7 @@ func (cn *conn) sendBinaryModeQuery(query string, args []driver.Value) {
cn.send(b)
}
-func (c *conn) processParameterStatus(r *readBuf) {
+func (cn *conn) processParameterStatus(r *readBuf) {
var err error
param := r.string()
@@ -1526,13 +1523,13 @@ func (c *conn) processParameterStatus(r *readBuf) {
var minor int
_, err = fmt.Sscanf(r.string(), "%d.%d.%d", &major1, &major2, &minor)
if err == nil {
- c.parameterStatus.serverVersion = major1*10000 + major2*100 + minor
+ cn.parameterStatus.serverVersion = major1*10000 + major2*100 + minor
}
case "TimeZone":
- c.parameterStatus.currentLocation, err = time.LoadLocation(r.string())
+ cn.parameterStatus.currentLocation, err = time.LoadLocation(r.string())
if err != nil {
- c.parameterStatus.currentLocation = nil
+ cn.parameterStatus.currentLocation = nil
}
default:
@@ -1540,8 +1537,8 @@ func (c *conn) processParameterStatus(r *readBuf) {
}
}
-func (c *conn) processReadyForQuery(r *readBuf) {
- c.txnStatus = transactionStatus(r.byte())
+func (cn *conn) processReadyForQuery(r *readBuf) {
+ cn.txnStatus = transactionStatus(r.byte())
}
func (cn *conn) readReadyForQuery() {
@@ -1556,9 +1553,9 @@ func (cn *conn) readReadyForQuery() {
}
}
-func (c *conn) processBackendKeyData(r *readBuf) {
- c.processID = r.int32()
- c.secretKey = r.int32()
+func (cn *conn) processBackendKeyData(r *readBuf) {
+ cn.processID = r.int32()
+ cn.secretKey = r.int32()
}
func (cn *conn) readParseResponse() {