@@ -549,11 +549,11 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
549
549
errorf ("unexpected message %q in simple query execution" , t )
550
550
}
551
551
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 ,
557
557
}
558
558
case 'Z' :
559
559
cn .processReadyForQuery (r )
@@ -574,7 +574,7 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
574
574
// res might be non-nil here if we received a previous
575
575
// CommandComplete, but that's fine; just overwrite it
576
576
res = & rows {cn : cn }
577
- res .cols , res .rowFmts , res .rowTyps = parseMeta (r )
577
+ res .colNames , res .colFmts , res .colTyps = parsePortalRowDescribe (r )
578
578
579
579
// To work around a bug in QueryRow in Go 1.2 and earlier, wait
580
580
// until the first DataRow has been received.
@@ -587,19 +587,19 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
587
587
588
588
// Decides which column formats to use for a prepared statement. The input is
589
589
// 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
593
593
}
594
594
595
- rowFmts = make ([]format , len (rowTyps ))
595
+ colFmts = make ([]format , len (colTyps ))
596
596
if forceText {
597
- return rowFmts , rowFmtDataAllText
597
+ return colFmts , colFmtDataAllText
598
598
}
599
599
600
600
allBinary := true
601
601
allText := true
602
- for i , o := range rowTyps {
602
+ for i , o := range colTyps {
603
603
switch o {
604
604
// This is the list of types to use binary mode for when receiving them
605
605
// 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
611
611
case oid .T_int4 :
612
612
fallthrough
613
613
case oid .T_int2 :
614
- rowFmts [i ] = formatBinary
614
+ colFmts [i ] = formatBinary
615
615
allText = false
616
616
617
617
default :
@@ -620,16 +620,16 @@ func decideColumnFormats(rowTyps []oid.Oid, forceText bool) (rowFmts []format, r
620
620
}
621
621
622
622
if allBinary {
623
- return rowFmts , rowFmtDataAllBinary
623
+ return colFmts , colFmtDataAllBinary
624
624
} else if allText {
625
- return rowFmts , rowFmtDataAllText
625
+ return colFmts , colFmtDataAllText
626
626
} 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 ))
631
631
}
632
- return rowFmts , rowFmtData
632
+ return colFmts , colFmtData
633
633
}
634
634
}
635
635
@@ -660,11 +660,11 @@ func (cn *conn) prepareTo(q, stmtName string) (_ *stmt, err error) {
660
660
st .paramTyps [i ] = r .oid ()
661
661
}
662
662
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 )
665
665
case 'n' :
666
666
// no data
667
- st .rowFmtData = rowFmtDataAllText
667
+ st .colFmtData = colFmtDataAllText
668
668
case 'Z' :
669
669
cn .processReadyForQuery (r )
670
670
return st , err
@@ -725,10 +725,10 @@ func (cn *conn) Query(query string, args []driver.Value) (_ driver.Rows, err err
725
725
726
726
st .exec (args )
727
727
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 ,
732
732
}, nil
733
733
}
734
734
@@ -1143,18 +1143,18 @@ const formatText format = 0
1143
1143
const formatBinary format = 1
1144
1144
1145
1145
// 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 }
1147
1147
1148
1148
// No result-column format codes (i.e. all text).
1149
- var rowFmtDataAllText []byte = []byte {0 , 0 }
1149
+ var colFmtDataAllText []byte = []byte {0 , 0 }
1150
1150
1151
1151
type stmt struct {
1152
1152
cn * conn
1153
1153
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
1158
1158
paramTyps []oid.Oid
1159
1159
closed bool
1160
1160
}
@@ -1200,10 +1200,10 @@ func (st *stmt) Query(v []driver.Value) (r driver.Rows, err error) {
1200
1200
1201
1201
st .exec (v )
1202
1202
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 ,
1207
1207
}, nil
1208
1208
}
1209
1209
@@ -1257,7 +1257,7 @@ func (st *stmt) exec(v []driver.Value) {
1257
1257
w .bytes (b )
1258
1258
}
1259
1259
}
1260
- w .bytes (st .rowFmtData )
1260
+ w .bytes (st .colFmtData )
1261
1261
1262
1262
w .next ('E' )
1263
1263
w .byte (0 )
@@ -1376,12 +1376,12 @@ func (cn *conn) parseComplete(commandTag string) (driver.Result, string) {
1376
1376
}
1377
1377
1378
1378
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
1385
1385
}
1386
1386
1387
1387
func (rs * rows ) Close () error {
@@ -1399,7 +1399,7 @@ func (rs *rows) Close() error {
1399
1399
}
1400
1400
1401
1401
func (rs * rows ) Columns () []string {
1402
- return rs .cols
1402
+ return rs .colNames
1403
1403
}
1404
1404
1405
1405
func (rs * rows ) Next (dest []driver.Value ) (err error ) {
@@ -1438,7 +1438,7 @@ func (rs *rows) Next(dest []driver.Value) (err error) {
1438
1438
dest [i ] = nil
1439
1439
continue
1440
1440
}
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 ])
1442
1442
}
1443
1443
return
1444
1444
default :
@@ -1500,32 +1500,32 @@ func (c *conn) processReadyForQuery(r *readBuf) {
1500
1500
c .txnStatus = transactionStatus (r .byte ())
1501
1501
}
1502
1502
1503
- func parseStatementRowDescribe (r * readBuf ) (cols []string , rowTyps []oid.Oid ) {
1503
+ func parseStatementRowDescribe (r * readBuf ) (colNames []string , colTyps []oid.Oid ) {
1504
1504
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 ()
1509
1509
r .next (6 )
1510
- rowTyps [i ] = r .oid ()
1510
+ colTyps [i ] = r .oid ()
1511
1511
r .next (6 )
1512
- // format code not known; always 0
1512
+ // format code not known when describing a statement ; always 0
1513
1513
r .next (2 )
1514
1514
}
1515
1515
return
1516
1516
}
1517
1517
1518
- func parseMeta (r * readBuf ) (cols []string , rowFmts []format , rowTyps []oid.Oid ) {
1518
+ func parsePortalRowDescribe (r * readBuf ) (colNames []string , colFmts []format , colTyps []oid.Oid ) {
1519
1519
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 ()
1525
1525
r .next (6 )
1526
- rowTyps [i ] = r .oid ()
1526
+ colTyps [i ] = r .oid ()
1527
1527
r .next (6 )
1528
- rowFmts [i ] = format (r .int16 ())
1528
+ colFmts [i ] = format (r .int16 ())
1529
1529
}
1530
1530
return
1531
1531
}
0 commit comments