Skip to content

Commit 8b4ab4b

Browse files
committed
Rename some poorly named functions and variables
1 parent a8d8d01 commit 8b4ab4b

File tree

1 file changed

+61
-61
lines changed

1 file changed

+61
-61
lines changed

conn.go

+61-61
Original file line numberDiff line numberDiff line change
@@ -549,11 +549,11 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
549549
errorf("unexpected message %q in simple query execution", t)
550550
}
551551
res = &rows{
552-
cn: cn,
553-
cols: st.cols,
554-
rowTyps: st.rowTyps,
555-
rowFmts: st.rowFmts,
556-
done: true,
552+
cn: cn,
553+
colNames: st.colNames,
554+
colTyps: st.colTyps,
555+
colFmts: st.colFmts,
556+
done: true,
557557
}
558558
case 'Z':
559559
cn.processReadyForQuery(r)
@@ -574,7 +574,7 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
574574
// res might be non-nil here if we received a previous
575575
// CommandComplete, but that's fine; just overwrite it
576576
res = &rows{cn: cn}
577-
res.cols, res.rowFmts, res.rowTyps = parseMeta(r)
577+
res.colNames, res.colFmts, res.colTyps = parsePortalRowDescribe(r)
578578

579579
// To work around a bug in QueryRow in Go 1.2 and earlier, wait
580580
// until the first DataRow has been received.
@@ -587,19 +587,19 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
587587

588588
// Decides which column formats to use for a prepared statement. The input is
589589
// an array of type oids, one element per result column.
590-
func decideColumnFormats(rowTyps []oid.Oid, forceText bool) (rowFmts []format, rowFmtData []byte) {
591-
if len(rowTyps) == 0 {
592-
return nil, rowFmtDataAllText
590+
func decideColumnFormats(colTyps []oid.Oid, forceText bool) (colFmts []format, colFmtData []byte) {
591+
if len(colTyps) == 0 {
592+
return nil, colFmtDataAllText
593593
}
594594

595-
rowFmts = make([]format, len(rowTyps))
595+
colFmts = make([]format, len(colTyps))
596596
if forceText {
597-
return rowFmts, rowFmtDataAllText
597+
return colFmts, colFmtDataAllText
598598
}
599599

600600
allBinary := true
601601
allText := true
602-
for i, o := range rowTyps {
602+
for i, o := range colTyps {
603603
switch o {
604604
// This is the list of types to use binary mode for when receiving them
605605
// through a prepared statement. If a type appears in this list, it
@@ -611,7 +611,7 @@ func decideColumnFormats(rowTyps []oid.Oid, forceText bool) (rowFmts []format, r
611611
case oid.T_int4:
612612
fallthrough
613613
case oid.T_int2:
614-
rowFmts[i] = formatBinary
614+
colFmts[i] = formatBinary
615615
allText = false
616616

617617
default:
@@ -620,16 +620,16 @@ func decideColumnFormats(rowTyps []oid.Oid, forceText bool) (rowFmts []format, r
620620
}
621621

622622
if allBinary {
623-
return rowFmts, rowFmtDataAllBinary
623+
return colFmts, colFmtDataAllBinary
624624
} else if allText {
625-
return rowFmts, rowFmtDataAllText
625+
return colFmts, colFmtDataAllText
626626
} else {
627-
rowFmtData = make([]byte, 2+len(rowFmts)*2)
628-
binary.BigEndian.PutUint16(rowFmtData, uint16(len(rowFmts)))
629-
for i, v := range rowFmts {
630-
binary.BigEndian.PutUint16(rowFmtData[2+i*2:], uint16(v))
627+
colFmtData = make([]byte, 2+len(colFmts)*2)
628+
binary.BigEndian.PutUint16(colFmtData, uint16(len(colFmts)))
629+
for i, v := range colFmts {
630+
binary.BigEndian.PutUint16(colFmtData[2+i*2:], uint16(v))
631631
}
632-
return rowFmts, rowFmtData
632+
return colFmts, colFmtData
633633
}
634634
}
635635

@@ -660,11 +660,11 @@ func (cn *conn) prepareTo(q, stmtName string) (_ *stmt, err error) {
660660
st.paramTyps[i] = r.oid()
661661
}
662662
case 'T':
663-
st.cols, st.rowTyps = parseStatementRowDescribe(r)
664-
st.rowFmts, st.rowFmtData = decideColumnFormats(st.rowTyps, cn.disablePreparedBinaryResult)
663+
st.colNames, st.colTyps = parseStatementRowDescribe(r)
664+
st.colFmts, st.colFmtData = decideColumnFormats(st.colTyps, cn.disablePreparedBinaryResult)
665665
case 'n':
666666
// no data
667-
st.rowFmtData = rowFmtDataAllText
667+
st.colFmtData = colFmtDataAllText
668668
case 'Z':
669669
cn.processReadyForQuery(r)
670670
return st, err
@@ -725,10 +725,10 @@ func (cn *conn) Query(query string, args []driver.Value) (_ driver.Rows, err err
725725

726726
st.exec(args)
727727
return &rows{
728-
cn: cn,
729-
cols: st.cols,
730-
rowTyps: st.rowTyps,
731-
rowFmts: st.rowFmts,
728+
cn: cn,
729+
colNames: st.colNames,
730+
colTyps: st.colTyps,
731+
colFmts: st.colFmts,
732732
}, nil
733733
}
734734

@@ -1143,18 +1143,18 @@ const formatText format = 0
11431143
const formatBinary format = 1
11441144

11451145
// One result-column format code with the value 1 (i.e. all binary).
1146-
var rowFmtDataAllBinary []byte = []byte{0, 1, 0, 1}
1146+
var colFmtDataAllBinary []byte = []byte{0, 1, 0, 1}
11471147

11481148
// No result-column format codes (i.e. all text).
1149-
var rowFmtDataAllText []byte = []byte{0, 0}
1149+
var colFmtDataAllText []byte = []byte{0, 0}
11501150

11511151
type stmt struct {
11521152
cn *conn
11531153
name string
1154-
cols []string
1155-
rowFmts []format
1156-
rowFmtData []byte
1157-
rowTyps []oid.Oid
1154+
colNames []string
1155+
colFmts []format
1156+
colFmtData []byte
1157+
colTyps []oid.Oid
11581158
paramTyps []oid.Oid
11591159
closed bool
11601160
}
@@ -1200,10 +1200,10 @@ func (st *stmt) Query(v []driver.Value) (r driver.Rows, err error) {
12001200

12011201
st.exec(v)
12021202
return &rows{
1203-
cn: st.cn,
1204-
cols: st.cols,
1205-
rowTyps: st.rowTyps,
1206-
rowFmts: st.rowFmts,
1203+
cn: st.cn,
1204+
colNames: st.colNames,
1205+
colTyps: st.colTyps,
1206+
colFmts: st.colFmts,
12071207
}, nil
12081208
}
12091209

@@ -1257,7 +1257,7 @@ func (st *stmt) exec(v []driver.Value) {
12571257
w.bytes(b)
12581258
}
12591259
}
1260-
w.bytes(st.rowFmtData)
1260+
w.bytes(st.colFmtData)
12611261

12621262
w.next('E')
12631263
w.byte(0)
@@ -1376,12 +1376,12 @@ func (cn *conn) parseComplete(commandTag string) (driver.Result, string) {
13761376
}
13771377

13781378
type rows struct {
1379-
cn *conn
1380-
cols []string
1381-
rowTyps []oid.Oid
1382-
rowFmts []format
1383-
done bool
1384-
rb readBuf
1379+
cn *conn
1380+
colNames []string
1381+
colTyps []oid.Oid
1382+
colFmts []format
1383+
done bool
1384+
rb readBuf
13851385
}
13861386

13871387
func (rs *rows) Close() error {
@@ -1399,7 +1399,7 @@ func (rs *rows) Close() error {
13991399
}
14001400

14011401
func (rs *rows) Columns() []string {
1402-
return rs.cols
1402+
return rs.colNames
14031403
}
14041404

14051405
func (rs *rows) Next(dest []driver.Value) (err error) {
@@ -1438,7 +1438,7 @@ func (rs *rows) Next(dest []driver.Value) (err error) {
14381438
dest[i] = nil
14391439
continue
14401440
}
1441-
dest[i] = decode(&conn.parameterStatus, rs.rb.next(l), rs.rowTyps[i], rs.rowFmts[i])
1441+
dest[i] = decode(&conn.parameterStatus, rs.rb.next(l), rs.colTyps[i], rs.colFmts[i])
14421442
}
14431443
return
14441444
default:
@@ -1500,32 +1500,32 @@ func (c *conn) processReadyForQuery(r *readBuf) {
15001500
c.txnStatus = transactionStatus(r.byte())
15011501
}
15021502

1503-
func parseStatementRowDescribe(r *readBuf) (cols []string, rowTyps []oid.Oid) {
1503+
func parseStatementRowDescribe(r *readBuf) (colNames []string, colTyps []oid.Oid) {
15041504
n := r.int16()
1505-
cols = make([]string, n)
1506-
rowTyps = make([]oid.Oid, n)
1507-
for i := range cols {
1508-
cols[i] = r.string()
1505+
colNames = make([]string, n)
1506+
colTyps = make([]oid.Oid, n)
1507+
for i := range colNames {
1508+
colNames[i] = r.string()
15091509
r.next(6)
1510-
rowTyps[i] = r.oid()
1510+
colTyps[i] = r.oid()
15111511
r.next(6)
1512-
// format code not known; always 0
1512+
// format code not known when describing a statement; always 0
15131513
r.next(2)
15141514
}
15151515
return
15161516
}
15171517

1518-
func parseMeta(r *readBuf) (cols []string, rowFmts []format, rowTyps []oid.Oid) {
1518+
func parsePortalRowDescribe(r *readBuf) (colNames []string, colFmts []format, colTyps []oid.Oid) {
15191519
n := r.int16()
1520-
cols = make([]string, n)
1521-
rowFmts = make([]format, n)
1522-
rowTyps = make([]oid.Oid, n)
1523-
for i := range cols {
1524-
cols[i] = r.string()
1520+
colNames = make([]string, n)
1521+
colFmts = make([]format, n)
1522+
colTyps = make([]oid.Oid, n)
1523+
for i := range colNames {
1524+
colNames[i] = r.string()
15251525
r.next(6)
1526-
rowTyps[i] = r.oid()
1526+
colTyps[i] = r.oid()
15271527
r.next(6)
1528-
rowFmts[i] = format(r.int16())
1528+
colFmts[i] = format(r.int16())
15291529
}
15301530
return
15311531
}

0 commit comments

Comments
 (0)