Avoid some copies.

This commit is contained in:
Nuno Cruces
2023-03-20 02:16:42 +00:00
parent e4efb20c71
commit 71e1e5a8ee
3 changed files with 38 additions and 21 deletions

View File

@@ -386,8 +386,7 @@ func (r rows) Next(dest []driver.Value) error {
case sqlite3.TEXT:
dest[i] = maybeTime(r.stmt.ColumnText(i))
case sqlite3.BLOB:
buf, _ := dest[i].([]byte)
dest[i] = r.stmt.ColumnBlob(i, buf)
dest[i] = r.stmt.ColumnRawBlob(i)
case sqlite3.NULL:
if buf, ok := dest[i].([]byte); ok {
dest[i] = buf[0:0]

View File

@@ -308,7 +308,7 @@ func Test_QueryRow_blob_null(t *testing.T) {
want := [][]byte{nil, {0xca, 0xfe}, {0xba, 0xbe}, nil}
for i := 0; rows.Next(); i++ {
var buf []byte
var buf sql.RawBytes
err = rows.Scan(&buf)
if err != nil {
t.Fatal(err)