mco_translog_iterate

This function reads a specified log file or pipe and iterates over its contents using a user-defined callback.

For an overview see page TL Applications

Prototype

    MCO_RET mco_translog_iterate (char const *file_path,
                                mco_db_h db,
                                mco_trans_iterator_callback_t iteration_proc,
                                void *user_ctx,
                                mco_dictionary_h dict,
                                void *mem_ptr,
                                mco_size_t mem_size);

Arguments

file_path
The path and filename of the log file or the name of the pipe overflow file. Note: It may be 0 if a pipe without an overflow file is used.
db
Handle of the connection to the original database to which the pipe is connected. Note: It may be NULL if the function works with a simple log file.
iteration_proc
User-defined callback function that iterates over objects stored in the log.
user_ctx
Void pointer to user data that will be passed to the user-defined iteration callback.
dict
Dictionary of the database whose transactions are being logged.
mem_ptr
Pointer to a temporary data buffer to perform iterations if conventional memory is used, or 0 if shared memory is used. Note: The pointer must be aligned to 8 bytes. Using the function malloc() complies with this requirement.
mem_size
Size of the temporary data buffer. It should be at least twice the size of the largest stored transaction.

Description

This function reads a specified log file or pipe and, if the log file is compatible, iterates over its contents by calling the user-defined callback.

Return Codes

MCO_S_OK
The log file was read successfully.
User-defined code other than MCO_S_OK

If the user-defined callback returns any value other than MCO_S_OK, the function mco_translog_iterate() aborts and returns this code as its own return code. This is the correct way to break the iteration loop if an error condition occurs inside the user-defined iteration callback.

MCO_E_TL_INVAL
Arguments are wrong or incompatible.
MCO_E_TL_NOT_ITERABLE
The log was created without the flag MCO_TRANSLOG_ITERABLE.
MCO_E_TL_LOG_NOT_OPENED
The log file could not be opened.
MCO_E_TL_IO_ERROR
Disk I/O error.
MCO_E_VERS_MISMATCH
The log file is incompatible with the runtime settings or the database version.
MCO_E_TL_INVFORMAT
The log file or pipe data is corrupted.
MCO_S_TL_INVDATA
The log file or pipe was not read completely, but some transactions were found, or no end-of-file was found.
MCO_E_TL_PIPE_USED
The pipe is already open in another call to mco_translog_iterate().
MCO_E_TL_PIPE_TERM

Logging was terminated during the previous call to mco_translog_iterate() but has not yet been reinitialized by the writer. This error code indicates a possible loss of consistency in the transferred data and prevents any transaction commit that cannot be transferred to the secondary database. Logging must therefore be restarted and the transaction recommitted after every failure.

Consequently, the error code MCO_E_TL_PIPE_TERM is not implemented in dynamic pipes, which do not check for data consistency (the reader can attach to and detach from a pipe at any arbitrary moment).

MCO_E_TL_PIPE_LOST
All connections to a pipe were closed and its data was lost before this function was called. Once reading has started, the pipe cannot be lost.
MCO_E_NOMEM
Insufficient memory to complete the operation. Increase the value of mem_size.

Files

Header file:
mcolog.h
Source file:
mcolog.c
Library:
libmcolog.a