Skip to documentation
SLOP

tiny.sql.CheckpointPlan

Reference tiny.sql CheckpointPlan

Defined in pager.

API (23)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

No direct callersNo direct callspagerCheckpointPlan
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/sql/src/pager.zig:378

zig
pub const CheckpointPlan = struct {    pub const storage_alignment: usize = @alignOf(CheckpointPage);    pub const Storage = []align(storage_alignment) u8;    pub const Limits = struct {        pages: usize,    };    pub const Capacity = struct {        pages: usize,        storage_bytes: usize,        pub const DeriveError = error{CapacityOverflow};        pub fn derive(limits: Limits) DeriveError!@This() {            return .{                .pages = limits.pages,                .storage_bytes = std.math.mul(usize, limits.pages, @sizeOf(CheckpointPage)) catch return error.CapacityOverflow,            };        }    };    pub const InitError = CheckpointPlan.Capacity.DeriveError || error{StorageTooShort};    pub const Exhaustion = error{        CheckpointPlanCapacityExceeded,        CheckpointPlanInUse,    };    pub const work_limits: alloc_phase.capacity.WorkLimits = .{        .transition_steps_max = 1,        .cleanup_steps_per_call_max = 0,        .cleanup_calls_at_capacity_max = 0,    };    pub const claim: alloc_phase.capacity.Declaration = .{        .source = .{            .id = "sql.checkpoint_plan",            .kind = .phase_static,            .limit_source = .caller,            .storage = .{                .covered = &.{                    .{                        .id = "reusable_maximum_latest_committed_wal_page_descript_860da2340194",                        .lifetime = .steady,                        .detail = "exclusive mutable loan for the reusable maximum latest committed WAL page descriptors for one prepared or synchronous checkpoint",                    },                },                .excluded = &.{                    "pager base images, WAL page bytes, frame and page indexes, and reader snapshots",                    "file handles, base-file writes, WAL rewrites, and operating-system cache state",                    "prepared checkpoint metadata, caller state, and trace instrumentation",                },            },            .capacity = .{                .inputs = &.{                    alloc_phase.capacity.bindInput(Limits, "pages", "pages"),                },                .type_selectors = &.{                    alloc_phase.capacity.bindType(CheckpointPage, "checkpointpage"),                },                .nodes = &.{                    .{ .input = 0 },                    .{ .scale = .{ .node = 0, .coefficient = .{ .size_of_concrete_type = 0 } } },                },                .assertions = &.{.{                    .scope = .closure_total,                    .measure = .retained,                    .relation = .exact,                    .expression = 1,                }},            },            .overload = .{                .kind = .reject_before_mutation,                .detail = "checked descriptor arithmetic and short caller storage reject before activation; begin rejects max plus one and concurrent use before clearing the reusable prefix",            },            .risks = .{                .transitive = .{                    .status = .witnessed,                    .detail = "WAL page selection and descriptor page views remain allocation-free across repeated prepared and durable checkpoints after plan initialization",                },                .foreign = .{                    .status = .excluded,                    .detail = "base-file writes consume borrowed immutable WAL page bytes and WAL rewrite effects occur outside the plan-owned descriptor claim",                },            },            .work = .{ .equation = "transition_steps <= transition_steps_max" },            .obligations = &.{                .{ .key = "sql_checkpoint_plan_capacity", .role = .capacity_model },                .{ .key = "sql_checkpoint_plan_storage_rejection", .role = .initialization_failure },                .{ .key = "sql_checkpoint_plan_sealed_overload", .role = .overload },                .{ .key = "sql_checkpoint_plan_work_bound", .role = .work_bound },                .{ .key = "sql_checkpoint_plan_sealed_transitive_risk", .role = .transitive_risk },                .{ .key = "sql_checkpoint_plan_semantics_transitive_risk", .role = .transitive_risk },                .{ .key = "sql_checkpoint_plan_semantics_foreign_risk", .role = .foreign_risk },            },        },        .bindings = .{            .owner = @This(),            .seal = .{                .family = alloc_phase.capacity.selector(@This().activate),                .premise = .{                    .class = .checked_semantic_fact,                    .authority = .checker,                },            },            .teardown = .{                .family = alloc_phase.capacity.selector(@This().deinit),                .premise = .{                    .class = .checked_semantic_fact,                    .authority = .checker,                },            },        },    };    phase: alloc_phase.capacity.Phase,    capacity: CheckpointPlan.Capacity,    storage: CheckpointPlan.Storage,    filled: usize = 0,    admitted: usize = 0,    in_use: bool = false,    pub fn init(storage: CheckpointPlan.Storage, limits: Limits) InitError!CheckpointPlan {        const capacity = try CheckpointPlan.Capacity.derive(limits);        if (storage.len < capacity.storage_bytes) return error.StorageTooShort;        return .{            .phase = .initialization,            .capacity = capacity,            .storage = storage[0..capacity.storage_bytes],        };    }    pub fn begin(self: *CheckpointPlan, required_pages: usize) error{        CheckpointPlanCapacityExceeded,        CheckpointPlanInUse,    }!void {        std.debug.assert(self.phase == .steady);        if (self.in_use) return error.CheckpointPlanInUse;        if (required_pages > self.capacity.pages) return error.CheckpointPlanCapacityExceeded;        self.filled = 0;        self.admitted = required_pages;        self.in_use = true;    }    pub fn append(self: *CheckpointPlan, checkpoint_page: CheckpointPage) error{CheckpointPlanCapacityExceeded}!void {        std.debug.assert(self.phase == .steady);        std.debug.assert(self.in_use);        if (self.filled >= self.admitted) return error.CheckpointPlanCapacityExceeded;        self.pageStorage()[self.filled] = checkpoint_page;        self.filled += 1;    }    pub fn activate(self: *CheckpointPlan) void {        std.debug.assert(self.phase == .initialization);        std.debug.assert(self.filled == 0);        std.debug.assert(!self.in_use);        self.phase = .steady;    }    pub fn pages(self: *const CheckpointPlan) []const CheckpointPage {        std.debug.assert(self.phase == .steady);        std.debug.assert(self.in_use);        std.debug.assert(self.filled == self.admitted);        return self.pageStorageConst()[0..self.filled];    }    pub fn release(self: *CheckpointPlan) void {        std.debug.assert(self.phase == .steady);        std.debug.assert(self.in_use);        self.filled = 0;        self.admitted = 0;        self.in_use = false;    }    pub fn deinit(self: *CheckpointPlan) CheckpointPlan.Storage {        std.debug.assert(self.phase != .teardown);        std.debug.assert(!self.in_use);        std.debug.assert(self.storage.len == self.capacity.storage_bytes);        self.phase = .teardown;        const storage = self.storage;        self.* = undefined;        return storage;    }    fn pageStorage(self: *CheckpointPlan) []CheckpointPage {        return std.mem.bytesAsSlice(CheckpointPage, self.storage);    }    fn pageStorageConst(self: *const CheckpointPlan) []const CheckpointPage {        return std.mem.bytesAsSlice(CheckpointPage, self.storage);    }};

Source: lib/sql/src/root.zig:308

zig
pub const CheckpointPlan = @import("pager.zig").CheckpointPlan;
Called byCallsNo direct callsCheckpointPlaninitprivate sourcelib.sql.src.pager.PagerWorkspace.Capacityderivetest sourcelib.sql.src.pagertest: checkpoint plan capacity matche...test sourcelib.sql.src.pagertest: checkpoint plan rejects short s...test sourcelib.sql.src.pagertest: checkpoint plan stays sealed th...CheckpointPlan.Capacityderive
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsPagerinittest sourcelib.sql.src.pagertest: checkpoint plan rejects short s...test sourcelib.sql.src.pagertest: checkpoint plan stays sealed th...CheckpointPlanactivate
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.sql.src.pagertest: checkpoint plan stays sealed th...private sourcelib.sql.src.pager.CheckpointPlanpageStorageCheckpointPlanappend
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.sql.src.pagertest: checkpoint plan stays sealed th...CheckpointPlanbegin
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsPagerdeinittest sourcelib.sql.src.pagertest: checkpoint plan rejects short s...test sourcelib.sql.src.pagertest: checkpoint plan stays sealed th...CheckpointPlandeinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsPagerinittest sourcelib.sql.src.pagertest: checkpoint plan rejects short s...test sourcelib.sql.src.pagertest: checkpoint plan stays sealed th...CheckpointPlan.CapacityderiveCheckpointPlaninit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallspager.PreparedCheckpointcheckpointPagepager.PreparedCheckpointcheckpointPageCounttest sourcelib.sql.src.pagertest: checkpoint plan stays sealed th...private sourcelib.sql.src.pager.CheckpointPlanpageStorageConstCheckpointPlanpages
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callspager.PreparedCheckpointdeinittest sourcelib.sql.src.pagertest: checkpoint plan stays sealed th...CheckpointPlanrelease
Static calls · unresolved targets: 0 · external targets: 0.

Audit

Definitions18
Public names36
Members12
Version26.7.0
Revisiondaab053ee433