2
0

pgtype DecodeText and DecodeBinary do not copy

They now take ownership of the src argument.

Needed to change Scan to make a copy of []byte arguments as lib/pq apparently
gives Scan a shared memory buffer.
This commit is contained in:
Jack Christensen
2017-04-29 12:23:51 -05:00
parent e8eaad520b
commit 932caef600
57 changed files with 188 additions and 93 deletions
+3 -1
View File
@@ -308,7 +308,9 @@ func (dst *Float4Array) Scan(src interface{}) error {
case string:
return dst.DecodeText(nil, []byte(src))
case []byte:
return dst.DecodeText(nil, src)
srcCopy := make([]byte, len(src))
copy(srcCopy, src)
return dst.DecodeText(nil, srcCopy)
}
return fmt.Errorf("cannot scan %T", src)