sqlite: allow controlling number of reserved bytes#130
Conversation
This allows reading and changing the number of reserved bytes using sqlite3_file_control with SQLITE_FCNTL_RESERVE_BYTES opcode. Updates tailscale/corp#36342 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
4715251 to
ba6683c
Compare
oxtoacart
left a comment
There was a problem hiding this comment.
Generally LGTM, just one suggestion.
| DisableFunction(name string, numArgs int) error | ||
| // FileControlInt is sqlite3_file_control for opcodes that take an | ||
| // integer argument. | ||
| FileControlInt(dbName string, op FileControlOp, arg *int) error |
There was a problem hiding this comment.
dbName might deserve a type with enumerated const values for the pre-defined names main and temp.
There was a problem hiding this comment.
Hm, I am not quite following. It's a common argument for many functions here - do you think FileControlInt calls for a custom type specifically? I imagine the most common value for dbName will be empty string (which defaults to the main db).
There was a problem hiding this comment.
My bad, I hadn't noticed this pattern was already used elsewhere in the API.
|
|
||
| // SetReserveBytes sets the number of reserved bytes at the end of each | ||
| // database page, using sqlite3_file_control with SQLITE_FCNTL_RESERVE_BYTES opcode. | ||
| func SetReserveBytes(sqlconn SQLConn, dbName string, bytes int) error { |
There was a problem hiding this comment.
As our higher-level interface to the underlying sqlite3_file_control method, maybe this method could also call the VACUUM for us?
This allows reading and changing the number of reserved bytes using sqlite3_file_control with SQLITE_FCNTL_RESERVE_BYTES opcode.
Updates tailscale/corp#36342