mco_translog_iterate

This function reads a specified log file or pipe and iterates its content by 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 name of pipe overflow file. Note! It may be 0 if a pipe without an overflow file is used.
db Handle of connection to original database to which the pipe is connected. Note: 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.
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 function malloc() complies with this requirement.
mem_size Size of 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 its content 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 then 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 IO 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

Pipe is already opened by another call of mco_trans_iterate().

MCO_E_TL_PIPE_TERM

Logging was terminated during the previous call of mco_trans_iterate() but still not reinitialized by writer. This error code treats the necessity to inform the user about any possibility to brake transferred data consistency, and prevent any transaction commit which can't be transferred to secondary database. This is the reason why logging has to be re-started and transaction has to be re-committed after every failure.

Consequently error code MCO_E_TL_PIPE_TERM is not implemented in dynamic pipes that are not checking for data consistency (the reader can attach a pipe and detach it 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. Then reading is started and 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