Commit 8a7a943
committed
sqlite: support sql.RawBytes (return []byte in driver.Value)
The https://pkg.go.dev/database/sql/driver#Value type can be either
string or []byte, but []byte permits database/sql scanning into
*sql.RawBytes without allocating. We were previously returning strings
all the time if that's what SQLite thought it was. (But Go doesn't
distinguish between "TEXT" and "BLOB" ... either are just some bytes)
This effectively moves any allocation (from []byte to string or []byte
to clone of []byte) later, letting it be managed by database/sql.
│ before │ after │
│ sec/op │ sec/op vs base │
QueryRows100MixedTypes-8 37.61µ ± 1% 36.60µ ± 0% -2.67% (p=0.000 n=10)
│ before │ after │
│ B/op │ B/op vs base │
QueryRows100MixedTypes-8 4.281Ki ± 0% 2.719Ki ± 0% -36.50% (p=0.000 n=10)
│ before │ after │
│ allocs/op │ allocs/op vs base │
QueryRows100MixedTypes-8 207.0 ± 0% 107.0 ± 0% -48.31% (p=0.000 n=10)
Signed-off-by: Brad Fitzpatrick <[email protected]>1 parent 0461cba commit 8a7a943
3 files changed
+6
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
| 381 | + | |
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
742 | | - | |
743 | | - | |
744 | | - | |
| 742 | + | |
745 | 743 | | |
746 | 744 | | |
747 | 745 | | |
| |||
0 commit comments