pub struct AutoincrementLedger { /* private fields */ }Expand description
Ledger for autoincrement values, used by tables with autoincrement columns.
Implementations§
Source§impl AutoincrementLedger
impl AutoincrementLedger
Sourcepub fn init<TS>(page: Page, mm: &mut impl MemoryAccess) -> MemoryResult<Self>where
TS: TableSchema,
pub fn init<TS>(page: Page, mm: &mut impl MemoryAccess) -> MemoryResult<Self>where
TS: TableSchema,
Initialize the AutoincrementLedger for the given table schema, and write it to the given page.
Each autoincrement column in the table schema will be initialized in the registry with the appropriate zero value.
§Errors
Returns MemoryError::ConstraintViolation if the autoincrement
columns do not fit the registry encoding (see Self::validate), or
any error raised while writing the registry page.
Sourcepub fn init_from_snapshot(
page: Page,
snapshot: &TableSchemaSnapshot,
mm: &mut impl MemoryAccess,
) -> MemoryResult<Self>
pub fn init_from_snapshot( page: Page, snapshot: &TableSchemaSnapshot, mm: &mut impl MemoryAccess, ) -> MemoryResult<Self>
Initialize the AutoincrementLedger for the table described by
snapshot, and write it to the given page.
Snapshot counterpart of Self::init, used when a table is created
from a stored TableSchemaSnapshot rather than a compiled
TableSchema.
§Errors
Returns MemoryError::ConstraintViolation if an autoincrement
column is not an integer or does not fit the registry encoding (see
Self::validate_snapshot), or any error raised while writing the
registry page.
Sourcepub fn validate<TS>() -> MemoryResult<()>where
TS: TableSchema,
pub fn validate<TS>() -> MemoryResult<()>where
TS: TableSchema,
Checks that the autoincrement columns of TS fit the registry
encoding, so Self::init cannot persist truncated metadata.
Callers should run this before allocating any page for the table.
§Errors
Returns MemoryError::ConstraintViolation if there are more than
255 autoincrement columns or a column name is longer than 255 bytes.
Sourcepub fn validate_snapshot(snapshot: &TableSchemaSnapshot) -> MemoryResult<()>
pub fn validate_snapshot(snapshot: &TableSchemaSnapshot) -> MemoryResult<()>
Checks that every autoincrement column of snapshot has an integer
type and fits the registry encoding, so Self::init_from_snapshot
cannot fail on it.
Callers should run this before allocating any page for the table.
§Errors
Returns MemoryError::ConstraintViolation if an autoincrement
column is not an integer, there are more than 255 autoincrement
columns, or a column name is longer than 255 bytes.
Sourcepub fn load(page: Page, mm: &mut impl MemoryAccess) -> MemoryResult<Self>
pub fn load(page: Page, mm: &mut impl MemoryAccess) -> MemoryResult<Self>
Load the AutoincrementLedger from the given page.