Skip to content

sqlite: allow controlling number of reserved bytes#130

Merged
knyar merged 1 commit intomainfrom
knyar/filecontrol
Feb 10, 2026
Merged

sqlite: allow controlling number of reserved bytes#130
knyar merged 1 commit intomainfrom
knyar/filecontrol

Conversation

@knyar
Copy link
Contributor

@knyar knyar commented Feb 9, 2026

This allows reading and changing the number of reserved bytes using sqlite3_file_control with SQLITE_FCNTL_RESERVE_BYTES opcode.

Updates tailscale/corp#36342

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>
@knyar knyar requested a review from oxtoacart February 9, 2026 20:04
@knyar knyar force-pushed the knyar/filecontrol branch from 4715251 to ba6683c Compare February 9, 2026 20:21
Copy link
Contributor

@oxtoacart oxtoacart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbName might deserve a type with enumerated const values for the pre-defined names main and temp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I hadn't noticed this pattern was already used elsewhere in the API.

@knyar knyar merged commit 558b1f9 into main Feb 10, 2026
2 checks passed

// 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 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As our higher-level interface to the underlying sqlite3_file_control method, maybe this method could also call the VACUUM for us?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants