Commit 70ca1bee authored by marko's avatar marko

branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.

This will help trim the dependencies of InnoDB Hot Backup.

recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined.  Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.

struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.

Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
parent bef98e34
......@@ -514,7 +514,9 @@ extern log_t* log_sys;
/* Values used as flags */
#define LOG_FLUSH 7652559
#define LOG_CHECKPOINT 78656949
#define LOG_ARCHIVE 11122331
#ifdef UNIV_LOG_ARCHIVE
# define LOG_ARCHIVE 11122331
#endif /* UNIV_LOG_ARCHIVE */
#define LOG_RECOVER 98887331
/* The counting of lsn's starts from this value: this must be non-zero */
......
......@@ -91,16 +91,25 @@ recv_recovery_from_checkpoint_finish should be called later to complete
the recovery and free the resources used in it. */
UNIV_INTERN
ulint
recv_recovery_from_checkpoint_start(
/*================================*/
recv_recovery_from_checkpoint_start_func(
/*=====================================*/
/* out: error code or DB_SUCCESS */
#ifdef UNIV_LOG_ARCHIVE
ulint type, /* in: LOG_CHECKPOINT or LOG_ARCHIVE */
ib_uint64_t limit_lsn, /* in: recover up to this lsn
if possible */
#endif /* UNIV_LOG_ARCHIVE */
ib_uint64_t min_flushed_lsn,/* in: min flushed lsn from
data files */
ib_uint64_t max_flushed_lsn);/* in: max flushed lsn from
data files */
#ifdef UNIV_LOG_ARCHIVE
# define recv_recovery_from_checkpoint_start(type,lim,min,max) \
recv_recovery_from_checkpoint_start_func(type,lim,min,max)
#else /* UNIV_LOG_ARCHIVE */
# define recv_recovery_from_checkpoint_start(type,lim,min,max) \
recv_recovery_from_checkpoint_start_func(min,max)
#endif /* UNIV_LOG_ARCHIVE */
/************************************************************
Completes recovery from a checkpoint. */
UNIV_INTERN
......@@ -321,9 +330,11 @@ struct recv_sys_struct{
scan find a corrupt log block, or a corrupt
log record, or there is a log parsing
buffer overflow */
#ifdef UNIV_LOG_ARCHIVE
log_group_t* archive_group;
/* in archive recovery: the log group whose
archive is read */
#endif /* !UNIV_LOG_ARCHIVE */
mem_heap_t* heap; /* memory heap of log records and file
addresses*/
hash_table_t* addr_hash;/* hash table of file addresses of pages */
......
......@@ -2542,12 +2542,14 @@ recv_recovery_from_checkpoint_finish should be called later to complete
the recovery and free the resources used in it. */
UNIV_INTERN
ulint
recv_recovery_from_checkpoint_start(
/*================================*/
recv_recovery_from_checkpoint_start_func(
/*=====================================*/
/* out: error code or DB_SUCCESS */
#ifdef UNIV_LOG_ARCHIVE
ulint type, /* in: LOG_CHECKPOINT or LOG_ARCHIVE */
ib_uint64_t limit_lsn, /* in: recover up to this lsn
if possible */
#endif /* UNIV_LOG_ARCHIVE */
ib_uint64_t min_flushed_lsn,/* in: min flushed lsn from
data files */
ib_uint64_t max_flushed_lsn)/* in: max flushed lsn from
......@@ -2563,14 +2565,20 @@ recv_recovery_from_checkpoint_start(
ib_uint64_t group_scanned_lsn;
ib_uint64_t contiguous_lsn;
ib_uint64_t archived_lsn;
ulint capacity;
byte* buf;
byte log_hdr_buf[LOG_FILE_HDR_SIZE];
ulint err;
#ifdef UNIV_LOG_ARCHIVE
ut_ad(type != LOG_CHECKPOINT || limit_lsn == IB_ULONGLONG_MAX);
# define TYPE_CHECKPOINT (type == LOG_CHECKPOINT)
# define LIMIT_LSN limit_lsn
#else /* UNIV_LOG_ARCHIVE */
# define TYPE_CHECKPOINT 1
# define LIMIT_LSN IB_ULONGLONG_MAX
#endif /* UNIV_LOG_ARCHIVE */
if (type == LOG_CHECKPOINT) {
if (TYPE_CHECKPOINT) {
recv_sys_create();
recv_sys_init(FALSE, buf_pool_get_curr_size());
}
......@@ -2586,7 +2594,7 @@ recv_recovery_from_checkpoint_start(
recv_recovery_on = TRUE;
recv_sys->limit_lsn = limit_lsn;
recv_sys->limit_lsn = LIMIT_LSN;
mutex_enter(&(log_sys->mutex));
......@@ -2653,7 +2661,7 @@ recv_recovery_from_checkpoint_start(
}
#endif /* UNIV_LOG_ARCHIVE */
if (type == LOG_CHECKPOINT) {
if (TYPE_CHECKPOINT) {
/* Start reading the log groups from the checkpoint lsn up. The
variable contiguous_lsn contains an lsn up to which the log is
known to be contiguously written to all log groups. */
......@@ -2668,7 +2676,12 @@ recv_recovery_from_checkpoint_start(
contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
OS_FILE_LOG_BLOCK_SIZE);
if (type == LOG_ARCHIVE) {
if (TYPE_CHECKPOINT) {
up_to_date_group = max_cp_group;
#ifdef UNIV_LOG_ARCHIVE
} else {
ulint capacity;
/* Try to recover the remaining part from logs: first from
the logs of the archived group */
......@@ -2701,20 +2714,21 @@ recv_recovery_from_checkpoint_start(
group->scanned_lsn = group_scanned_lsn;
up_to_date_group = group;
} else {
up_to_date_group = max_cp_group;
#endif /* UNIV_LOG_ARCHIVE */
}
ut_ad(RECV_SCAN_SIZE <= log_sys->buf_size);
group = UT_LIST_GET_FIRST(log_sys->log_groups);
#ifdef UNIV_LOG_ARCHIVE
if ((type == LOG_ARCHIVE) && (group == recv_sys->archive_group)) {
group = UT_LIST_GET_NEXT(log_groups, group);
}
#endif /* UNIV_LOG_ARCHIVE */
/* Set the flag to publish that we are doing startup scan. */
recv_log_scan_is_startup_type = (type == LOG_CHECKPOINT);
recv_log_scan_is_startup_type = TYPE_CHECKPOINT;
while (group) {
old_scanned_lsn = recv_sys->scanned_lsn;
......@@ -2728,17 +2742,19 @@ recv_recovery_from_checkpoint_start(
up_to_date_group = group;
}
#ifdef UNIV_LOG_ARCHIVE
if ((type == LOG_ARCHIVE)
&& (group == recv_sys->archive_group)) {
group = UT_LIST_GET_NEXT(log_groups, group);
}
#endif /* UNIV_LOG_ARCHIVE */
group = UT_LIST_GET_NEXT(log_groups, group);
}
/* Done with startup scan. Clear the flag. */
recv_log_scan_is_startup_type = FALSE;
if (type == LOG_CHECKPOINT) {
if (TYPE_CHECKPOINT) {
/* NOTE: we always do a 'recovery' at startup, but only if
there is something wrong we will print a message to the
user about recovery: */
......@@ -2816,7 +2832,7 @@ recv_recovery_from_checkpoint_start(
mutex_exit(&(log_sys->mutex));
if (recv_sys->recovered_lsn >= limit_lsn) {
if (recv_sys->recovered_lsn >= LIMIT_LSN) {
return(DB_SUCCESS);
}
......@@ -2879,6 +2895,9 @@ recv_recovery_from_checkpoint_start(
records in the hash table can be run in background. */
return(DB_SUCCESS);
#undef TYPE_CHECKPOINT
#undef LIMIT_LSN
}
/************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment