Use simplified pgtype ScanPlan

pull/745/head
Jack Christensen 2020-05-10 14:09:26 -05:00
parent 38dd42de4b
commit 94ba730bb1
1 changed files with 6 additions and 7 deletions

13
rows.go
View File

@ -111,7 +111,6 @@ type connRows struct {
multiResultReader *pgconn.MultiResultReader
scanPlans []pgtype.ScanPlan
dstValues []interface{}
}
func (rows *connRows) FieldDescriptions() []pgproto3.FieldDescription {
@ -204,7 +203,12 @@ func (rows *connRows) Scan(dest ...interface{}) error {
if rows.scanPlans == nil {
rows.scanPlans = make([]pgtype.ScanPlan, len(values))
rows.dstValues = make([]interface{}, len(values))
for i, dst := range dest {
if dst == nil {
continue
}
rows.scanPlans[i] = ci.PlanScan(fieldDescriptions[i].DataTypeOID, fieldDescriptions[i].Format, values[i], dest[i])
}
}
for i, dst := range dest {
@ -212,11 +216,6 @@ func (rows *connRows) Scan(dest ...interface{}) error {
continue
}
if dst != rows.dstValues[i] {
rows.scanPlans[i] = ci.PlanScan(fieldDescriptions[i].DataTypeOID, fieldDescriptions[i].Format, values[i], dest[i])
rows.dstValues[i] = dst
}
err := rows.scanPlans[i].Scan(ci, fieldDescriptions[i].DataTypeOID, fieldDescriptions[i].Format, values[i], dst)
if err != nil {
err = scanArgError{col: i, err: err}