mco_restore_chunk

Internal callback function. This function is used internally by the eXtremeDB restore subsystem to read data chunks from a backup file. It is passed as a callback during restore or verify operations and should not be called directly by applications.

For an overview see page Incremental Online Backup in C

Prototype

    MCO_RET mco_restore_chunk(
        /*OUT*/ mco_uint4 *chunk_id,
        /*OUT*/ char **pchunk,
        /*OUT*/ mco_uint4 *pchunk_size,
        /*IN*/  void *param
    );

Arguments

chunk_id
Pointer to a variable that will receive the identifier of the next chunk (e.g., MCO_BACKUP_CHUNK_PAGE_MEMORY, MCO_BACKUP_CHUNK_DICT, MCO_BACKUP_CHUNK_STOP).
pchunk
Pointer to a variable that will receive the address of the chunk data within an internal buffer. The data is valid only until the next call to this function.
pchunk_size
Pointer to a variable that will receive the size of the chunk in bytes.
param
Opaque pointer to a mco_backup_ctx_t context structure, cast to void*. Contains the backup file handle, decryption context, CRC state, and I/O buffers.

Description

This internal function reads the next data chunk from a backup file during restore or verification. It handles the following tasks:

The function is designed to be called repeatedly by the core restore engine (e.g., from mco_restore()) until the MCO_BACKUP_CHUNK_STOP marker is encountered.

It manages internal buffering transparently: when the current block is exhausted, it reads and processes the next block from the file, including decryption and decompression if needed.

Direct use of this function may result in corrupted database state or I/O errors. Applications should use high-level APIs such as mco_backup_restore() or mco_backup_verify() instead.

See Incremental Backup and Restore for more details.

Return Codes

MCO_S_OK
Chunk successfully read and output parameters filled.
MCO_E_DISK_READ
Failed to read data from the backup file.
MCO_E_DISK_CRC_MISMATCH
CRC validation failed (indicating file corruption or tampering).
Other error codes
May include memory allocation failures during buffer reallocation.

Files

Header file:
mco.h
Source file:
mcoabst.c
Library:
libmcolib.a