mco_translog_play

This function reads a specified log file or pipe and, if the log file is “compatible”, iterates its contents by calling the user-defined callback and also fires registered events.

For an overview see page TL Applications

Prototype

    MCO_RET mco_translog_play(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,
        mco_translog_register_event_handlers_t register_callback,
        void *regevent_user_ctx);

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
Connection handle 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 objects stored in the log. Note: It may be NULL if only event handling is desired.
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.
register_callback
User-defined callback function that registers event handlers. Note: It may be NULL if only object iteration is desired.
regevent_user_ctx
Void pointer to user data that will be passed to the user-defined callback that registers event handlers.

Description

This function is a copy of the function mco_translog_iterate(), but also allows registration of a user-defined callback that, in turn, registers event handlers. The function mco_translog_play() reads a specified log file or pipe, iterates its contents by calling the user-defined callback, and fires the appropriate events. (Note that an equivalent to mco_translog_play() is not available through the JNI or C# API.)

Return Codes

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

As with mco_translog_iterate(), if the user-defined callback returns any value other than MCO_S_OK, this function aborts and returns that 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 by another call to mco_translog_iterate().
MCO_E_TL_PIPE_TERM
Logging was terminated during the previous call to mco_translog_iterate() but was not reinitialized by the writer.
MCO_E_TL_PIPE_LOST
All connections to a pipe were closed and its data was lost before this function was called.
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