@@ -298,13 +298,17 @@ func (rows *Rows) Scan(dest ...interface{}) (err error) {
|
||||
if err != nil {
|
||||
rows.Fatal(scanArgError{col: i, err: err})
|
||||
}
|
||||
} else if vr.Type().DataType == JsonOid || vr.Type().DataType == JsonbOid {
|
||||
} else if vr.Type().DataType == JsonOid {
|
||||
// Because the argument passed to decodeJSON will escape the heap.
|
||||
// This allows d to be stack allocated and only copied to the heap when
|
||||
// we actually are decoding JSON. This saves one memory allocation per
|
||||
// row.
|
||||
d2 := d
|
||||
decodeJSON(vr, &d2)
|
||||
} else if vr.Type().DataType == JsonbOid {
|
||||
// Same trick as above for getting stack allocation
|
||||
d2 := d
|
||||
decodeJSONB(vr, &d2)
|
||||
} else {
|
||||
if err := Decode(vr, d); err != nil {
|
||||
rows.Fatal(scanArgError{col: i, err: err})
|
||||
@@ -393,7 +397,7 @@ func (rows *Rows) Values() ([]interface{}, error) {
|
||||
values = append(values, d)
|
||||
case JsonbOid:
|
||||
var d interface{}
|
||||
decodeJSON(vr, &d)
|
||||
decodeJSONB(vr, &d)
|
||||
values = append(values, d)
|
||||
default:
|
||||
rows.Fatal(errors.New("Values cannot handle binary format non-intrinsic types"))
|
||||
|
||||
Reference in New Issue
Block a user