Try wrapping scan target before sql.Scanner

This allows wrappers to directly avoid the slow sql.Scanner interface.
query-exec-mode
Jack Christensen 2022-01-22 18:40:46 -06:00
parent 5ed95dcd1c
commit 0ddf9e3b4b
1 changed files with 10 additions and 8 deletions

View File

@ -906,14 +906,6 @@ func (ci *ConnInfo) PlanScan(oid uint32, formatCode int16, target interface{}) S
if plan := dt.Codec.PlanScan(ci, oid, formatCode, target, false); plan != nil {
return plan
}
if _, ok := target.(*interface{}); ok {
return &pointerEmptyInterfaceScanPlan{codec: dt.Codec, ci: ci, oid: oid, formatCode: formatCode}
}
if _, ok := target.(sql.Scanner); ok {
return &scanPlanCodecSQLScanner{c: dt.Codec, ci: ci, oid: oid, formatCode: formatCode}
}
}
for _, f := range ci.TryWrapScanPlanFuncs {
@ -927,6 +919,16 @@ func (ci *ConnInfo) PlanScan(oid uint32, formatCode int16, target interface{}) S
}
}
if dt != nil {
if _, ok := target.(*interface{}); ok {
return &pointerEmptyInterfaceScanPlan{codec: dt.Codec, ci: ci, oid: oid, formatCode: formatCode}
}
if _, ok := target.(sql.Scanner); ok {
return &scanPlanCodecSQLScanner{c: dt.Codec, ci: ci, oid: oid, formatCode: formatCode}
}
}
if _, ok := target.(sql.Scanner); ok {
return &scanPlanSQLScanner{formatCode: formatCode}
}