@@ -27,12 +27,12 @@ var (
27
27
ErrNotSupported = errors .New ("pq: Unsupported command" )
28
28
ErrInFailedTransaction = errors .New ("pq: Could not complete operation in a failed transaction" )
29
29
ErrSSLNotSupported = errors .New ("pq: SSL is not enabled on the server" )
30
- ErrSSLKeyHasWorldPermissions = errors .New ("pq: Private key file has group or world access. Permissions should be u=rw (0600) or less. " )
31
- ErrCouldNotDetectUsername = errors .New ("pq: Could not detect default username. Please provide one explicitly. " )
30
+ ErrSSLKeyHasWorldPermissions = errors .New ("pq: Private key file has group or world access. Permissions should be u=rw (0600) or less" )
31
+ ErrCouldNotDetectUsername = errors .New ("pq: Could not detect default username. Please provide one explicitly" )
32
32
33
33
errUnexpectedReady = errors .New ("unexpected ReadyForQuery" )
34
34
errNoRowsAffected = errors .New ("no RowsAffected available after the empty statement" )
35
- errNoLastInsertId = errors .New ("no LastInsertId available after the empty statement" )
35
+ errNoLastInsertID = errors .New ("no LastInsertId available after the empty statement" )
36
36
)
37
37
38
38
type Driver struct {}
@@ -131,7 +131,7 @@ type conn struct {
131
131
}
132
132
133
133
// Handle driver-side settings in parsed connection string.
134
- func (c * conn ) handleDriverSettings (o values ) (err error ) {
134
+ func (cn * conn ) handleDriverSettings (o values ) (err error ) {
135
135
boolSetting := func (key string , val * bool ) error {
136
136
if value , ok := o [key ]; ok {
137
137
if value == "yes" {
@@ -145,18 +145,18 @@ func (c *conn) handleDriverSettings(o values) (err error) {
145
145
return nil
146
146
}
147
147
148
- err = boolSetting ("disable_prepared_binary_result" , & c .disablePreparedBinaryResult )
148
+ err = boolSetting ("disable_prepared_binary_result" , & cn .disablePreparedBinaryResult )
149
149
if err != nil {
150
150
return err
151
151
}
152
- err = boolSetting ("binary_parameters" , & c .binaryParameters )
152
+ err = boolSetting ("binary_parameters" , & cn .binaryParameters )
153
153
if err != nil {
154
154
return err
155
155
}
156
156
return nil
157
157
}
158
158
159
- func (c * conn ) handlePgpass (o values ) {
159
+ func (cn * conn ) handlePgpass (o values ) {
160
160
// if a password was supplied, do not process .pgpass
161
161
if _ , ok := o ["password" ]; ok {
162
162
return
@@ -229,10 +229,10 @@ func (c *conn) handlePgpass(o values) {
229
229
}
230
230
}
231
231
232
- func (c * conn ) writeBuf (b byte ) * writeBuf {
233
- c .scratch [0 ] = b
232
+ func (cn * conn ) writeBuf (b byte ) * writeBuf {
233
+ cn .scratch [0 ] = b
234
234
return & writeBuf {
235
- buf : c .scratch [:5 ],
235
+ buf : cn .scratch [:5 ],
236
236
pos : 1 ,
237
237
}
238
238
}
@@ -310,9 +310,8 @@ func DialOpen(d Dialer, name string) (_ driver.Conn, err error) {
310
310
u , err := userCurrent ()
311
311
if err != nil {
312
312
return nil , err
313
- } else {
314
- o ["user" ] = u
315
313
}
314
+ o ["user" ] = u
316
315
}
317
316
318
317
cn := & conn {
@@ -698,7 +697,7 @@ var emptyRows noRows
698
697
var _ driver.Result = noRows {}
699
698
700
699
func (noRows ) LastInsertId () (int64 , error ) {
701
- return 0 , errNoLastInsertId
700
+ return 0 , errNoLastInsertID
702
701
}
703
702
704
703
func (noRows ) RowsAffected () (int64 , error ) {
@@ -840,16 +839,15 @@ func (cn *conn) query(query string, args []driver.Value) (_ *rows, err error) {
840
839
rows .colNames , rows .colFmts , rows .colTyps = cn .readPortalDescribeResponse ()
841
840
cn .postExecuteWorkaround ()
842
841
return rows , nil
843
- } else {
844
- st := cn .prepareTo (query , "" )
845
- st .exec (args )
846
- return & rows {
847
- cn : cn ,
848
- colNames : st .colNames ,
849
- colTyps : st .colTyps ,
850
- colFmts : st .colFmts ,
851
- }, nil
852
842
}
843
+ st := cn .prepareTo (query , "" )
844
+ st .exec (args )
845
+ return & rows {
846
+ cn : cn ,
847
+ colNames : st .colNames ,
848
+ colTyps : st .colTyps ,
849
+ colFmts : st .colFmts ,
850
+ }, nil
853
851
}
854
852
855
853
// 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
876
874
cn .postExecuteWorkaround ()
877
875
res , _ , err = cn .readExecuteResponse ("Execute" )
878
876
return res , err
879
- } else {
880
- // Use the unnamed statement to defer planning until bind
881
- // time, or else value-based selectivity estimates cannot be
882
- // used.
883
- st := cn .prepareTo (query , "" )
884
- r , err := st .Exec (args )
885
- if err != nil {
886
- panic (err )
887
- }
888
- return r , err
889
877
}
878
+ // Use the unnamed statement to defer planning until bind
879
+ // time, or else value-based selectivity estimates cannot be
880
+ // used.
881
+ st := cn .prepareTo (query , "" )
882
+ r , err := st .Exec (args )
883
+ if err != nil {
884
+ panic (err )
885
+ }
886
+ return r , err
890
887
}
891
888
892
889
func (cn * conn ) send (m * writeBuf ) {
@@ -1147,10 +1144,10 @@ const formatText format = 0
1147
1144
const formatBinary format = 1
1148
1145
1149
1146
// One result-column format code with the value 1 (i.e. all binary).
1150
- var colFmtDataAllBinary [] byte = []byte {0 , 1 , 0 , 1 }
1147
+ var colFmtDataAllBinary = []byte {0 , 1 , 0 , 1 }
1151
1148
1152
1149
// No result-column format codes (i.e. all text).
1153
- var colFmtDataAllText [] byte = []byte {0 , 0 }
1150
+ var colFmtDataAllText = []byte {0 , 0 }
1154
1151
1155
1152
type stmt struct {
1156
1153
cn * conn
@@ -1515,7 +1512,7 @@ func (cn *conn) sendBinaryModeQuery(query string, args []driver.Value) {
1515
1512
cn .send (b )
1516
1513
}
1517
1514
1518
- func (c * conn ) processParameterStatus (r * readBuf ) {
1515
+ func (cn * conn ) processParameterStatus (r * readBuf ) {
1519
1516
var err error
1520
1517
1521
1518
param := r .string ()
@@ -1526,22 +1523,22 @@ func (c *conn) processParameterStatus(r *readBuf) {
1526
1523
var minor int
1527
1524
_ , err = fmt .Sscanf (r .string (), "%d.%d.%d" , & major1 , & major2 , & minor )
1528
1525
if err == nil {
1529
- c .parameterStatus .serverVersion = major1 * 10000 + major2 * 100 + minor
1526
+ cn .parameterStatus .serverVersion = major1 * 10000 + major2 * 100 + minor
1530
1527
}
1531
1528
1532
1529
case "TimeZone" :
1533
- c .parameterStatus .currentLocation , err = time .LoadLocation (r .string ())
1530
+ cn .parameterStatus .currentLocation , err = time .LoadLocation (r .string ())
1534
1531
if err != nil {
1535
- c .parameterStatus .currentLocation = nil
1532
+ cn .parameterStatus .currentLocation = nil
1536
1533
}
1537
1534
1538
1535
default :
1539
1536
// ignore
1540
1537
}
1541
1538
}
1542
1539
1543
- func (c * conn ) processReadyForQuery (r * readBuf ) {
1544
- c .txnStatus = transactionStatus (r .byte ())
1540
+ func (cn * conn ) processReadyForQuery (r * readBuf ) {
1541
+ cn .txnStatus = transactionStatus (r .byte ())
1545
1542
}
1546
1543
1547
1544
func (cn * conn ) readReadyForQuery () {
@@ -1556,9 +1553,9 @@ func (cn *conn) readReadyForQuery() {
1556
1553
}
1557
1554
}
1558
1555
1559
- func (c * conn ) processBackendKeyData (r * readBuf ) {
1560
- c .processID = r .int32 ()
1561
- c .secretKey = r .int32 ()
1556
+ func (cn * conn ) processBackendKeyData (r * readBuf ) {
1557
+ cn .processID = r .int32 ()
1558
+ cn .secretKey = r .int32 ()
1562
1559
}
1563
1560
1564
1561
func (cn * conn ) readParseResponse () {
0 commit comments