Commit 21f63e41 authored by unknown's avatar unknown

Trivial postreview changes.


storage/maria/ma_blockrec.c:
  Layout fix.
storage/maria/ma_loghandler.c:
  Renamed struct variable 'class' to avoid problems with c++ compiler.
  Renamed translog_init_scanner to fit othere init functions naming pattern.
  translog_relative_LSN_encode can't return error for now.
  Other trivial postreview changes.
storage/maria/ma_loghandler_lsn.h:
  trivial postreview changes.
storage/maria/ma_recovery.c:
  Renamed translog_init_scanner to fit othere init functions naming pattern.
storage/maria/unittest/ma_loghandler_examples.c:
  Renamed struct variable 'class' to avoid problems with c++ compiler.
storage/maria/unittest/ma_test_loghandler-t.c:
  Renamed translog_init_scanner to fit othere init functions naming pattern.
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  Renamed translog_init_scanner to fit othere init functions naming pattern.
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  Renamed translog_init_scanner to fit othere init functions naming pattern.
parent 571ab016
...@@ -5006,7 +5006,7 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn, ...@@ -5006,7 +5006,7 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn,
DBUG_ENTER("_ma_apply_redo_insert_row_head_or_tail"); DBUG_ENTER("_ma_apply_redo_insert_row_head_or_tail");
page= page_korr(header); page= page_korr(header);
rownr= dirpos_korr(header+PAGE_STORE_SIZE); rownr= dirpos_korr(header + PAGE_STORE_SIZE);
DBUG_PRINT("enter", ("rowid: %lu page: %lu rownr: %u data_length: %u", DBUG_PRINT("enter", ("rowid: %lu page: %lu rownr: %u data_length: %u",
(ulong) ma_recordpos(page, rownr), (ulong) ma_recordpos(page, rownr),
......
...@@ -309,19 +309,19 @@ static void check_translog_description_table(int num) ...@@ -309,19 +309,19 @@ static void check_translog_description_table(int num)
DBUG_ASSERT(num > 0); DBUG_ASSERT(num > 0);
/* last is reserved for extending the table */ /* last is reserved for extending the table */
DBUG_ASSERT(num < LOGREC_NUMBER_OF_TYPES - 1); DBUG_ASSERT(num < LOGREC_NUMBER_OF_TYPES - 1);
DBUG_ASSERT(log_record_type_descriptor[0].class == LOGRECTYPE_NOT_ALLOWED); DBUG_ASSERT(log_record_type_descriptor[0].rclass == LOGRECTYPE_NOT_ALLOWED);
for (i= 0; i <= num; i++) for (i= 0; i <= num; i++)
{ {
DBUG_PRINT("info", DBUG_PRINT("info",
("record type: %d class: %d fixed: %u header: %u LSNs: %u " ("record type: %d class: %d fixed: %u header: %u LSNs: %u "
"name: %s", "name: %s",
i, log_record_type_descriptor[i].class, i, log_record_type_descriptor[i].rclass,
(uint)log_record_type_descriptor[i].fixed_length, (uint)log_record_type_descriptor[i].fixed_length,
(uint)log_record_type_descriptor[i].read_header_len, (uint)log_record_type_descriptor[i].read_header_len,
(uint)log_record_type_descriptor[i].compressed_LSN, (uint)log_record_type_descriptor[i].compressed_LSN,
log_record_type_descriptor[i].name)); log_record_type_descriptor[i].name));
switch (log_record_type_descriptor[i].class) { switch (log_record_type_descriptor[i].rclass) {
case LOGRECTYPE_NOT_ALLOWED: case LOGRECTYPE_NOT_ALLOWED:
DBUG_ASSERT(i == 0); DBUG_ASSERT(i == 0);
break; break;
...@@ -352,7 +352,8 @@ static void check_translog_description_table(int num) ...@@ -352,7 +352,8 @@ static void check_translog_description_table(int num)
} }
for (i= num + 1; i < LOGREC_NUMBER_OF_TYPES; i++) for (i= num + 1; i < LOGREC_NUMBER_OF_TYPES; i++)
{ {
DBUG_ASSERT(log_record_type_descriptor[i].class == LOGRECTYPE_NOT_ALLOWED); DBUG_ASSERT(log_record_type_descriptor[i].rclass ==
LOGRECTYPE_NOT_ALLOWED);
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -636,7 +637,7 @@ static void loghandler_init() ...@@ -636,7 +637,7 @@ static void loghandler_init()
for (i= LOGREC_INCOMPLETE_LOG + 1; for (i= LOGREC_INCOMPLETE_LOG + 1;
i < LOGREC_NUMBER_OF_TYPES; i < LOGREC_NUMBER_OF_TYPES;
i++) i++)
log_record_type_descriptor[i].class= LOGRECTYPE_NOT_ALLOWED; log_record_type_descriptor[i].rclass= LOGRECTYPE_NOT_ALLOWED;
DBUG_EXECUTE("info", DBUG_EXECUTE("info",
check_translog_description_table(LOGREC_INCOMPLETE_LOG);); check_translog_description_table(LOGREC_INCOMPLETE_LOG););
}; };
...@@ -2013,11 +2014,11 @@ static uint16 translog_get_total_chunk_length(uchar *page, uint16 offset) ...@@ -2013,11 +2014,11 @@ static uint16 translog_get_total_chunk_length(uchar *page, uint16 offset)
int i; int i;
/* 1 (pseudo)fixed record (also LSN) */ /* 1 (pseudo)fixed record (also LSN) */
DBUG_PRINT("info", ("TRANSLOG_CHUNK_FIXED")); DBUG_PRINT("info", ("TRANSLOG_CHUNK_FIXED"));
DBUG_ASSERT(log_record_type_descriptor[type].class == DBUG_ASSERT(log_record_type_descriptor[type].rclass ==
LOGRECTYPE_FIXEDLENGTH || LOGRECTYPE_FIXEDLENGTH ||
log_record_type_descriptor[type].class == log_record_type_descriptor[type].rclass ==
LOGRECTYPE_PSEUDOFIXEDLENGTH); LOGRECTYPE_PSEUDOFIXEDLENGTH);
if (log_record_type_descriptor[type].class == LOGRECTYPE_FIXEDLENGTH) if (log_record_type_descriptor[type].rclass == LOGRECTYPE_FIXEDLENGTH)
{ {
DBUG_PRINT("info", DBUG_PRINT("info",
("Fixed length: %u", ("Fixed length: %u",
...@@ -2531,7 +2532,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer, ...@@ -2531,7 +2532,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer,
translog_buffer_lock(curr_buffer); translog_buffer_lock(curr_buffer);
translog_buffer_unlock(buffer_unlock); translog_buffer_unlock(buffer_unlock);
buffer_unlock= curr_buffer; buffer_unlock= curr_buffer;
/* we can't make full circle */ /* we can't make a full circle */
DBUG_ASSERT(buffer_start != buffer_no); DBUG_ASSERT(buffer_start != buffer_no);
} }
} }
...@@ -2613,7 +2614,7 @@ static void translog_free_link(PAGECACHE_BLOCK_LINK *direct_link) ...@@ -2613,7 +2614,7 @@ static void translog_free_link(PAGECACHE_BLOCK_LINK *direct_link)
/* /*
Finds last page of the given log file Finds last full page of the given log file
SYNOPSIS SYNOPSIS
translog_get_last_page_addr() translog_get_last_page_addr()
...@@ -2657,15 +2658,12 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr, ...@@ -2657,15 +2658,12 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
} }
/* /**
Get number bytes for record length storing @brief Get number bytes for record length storing
SYNOPSIS @param length Record length which will be encoded
translog_variable_record_length_bytes()
length Record length wich will be codded
RETURN @return 1,3,4,5 - number of bytes to store given length
1,3,4,5 - number of bytes to store given length
*/ */
static uint translog_variable_record_length_bytes(translog_size_t length) static uint translog_variable_record_length_bytes(translog_size_t length)
...@@ -2681,28 +2679,23 @@ static uint translog_variable_record_length_bytes(translog_size_t length) ...@@ -2681,28 +2679,23 @@ static uint translog_variable_record_length_bytes(translog_size_t length)
/* /*
Get header of this chunk @brief Gets header of this chunk.
SYNOPSIS @param chunk The pointer to the chunk beginning
translog_get_chunk_header_length()
page The page where chunk placed
offset Offset of the chunk on this place
RETURN @retval # total length of the chunk
# total length of the chunk @retval 0 Error
0 Error
*/ */
static uint16 translog_get_chunk_header_length(uchar *page, uint16 offset) static uint16 translog_get_chunk_header_length(uchar *chunk)
{ {
DBUG_ENTER("translog_get_chunk_header_length"); DBUG_ENTER("translog_get_chunk_header_length");
page+= offset; switch (*chunk & TRANSLOG_CHUNK_TYPE) {
switch (*page & TRANSLOG_CHUNK_TYPE) {
case TRANSLOG_CHUNK_LSN: case TRANSLOG_CHUNK_LSN:
{ {
/* 0 chunk referred as LSN (head or tail) */ /* 0 chunk referred as LSN (head or tail) */
translog_size_t rec_len; translog_size_t rec_len;
uchar *start= page; uchar *start= chunk;
uchar *ptr= start + 1 + 2; uchar *ptr= start + 1 + 2;
uint16 chunk_len, header_len; uint16 chunk_len, header_len;
DBUG_PRINT("info", ("TRANSLOG_CHUNK_LSN")); DBUG_PRINT("info", ("TRANSLOG_CHUNK_LSN"));
...@@ -2743,7 +2736,8 @@ static uint16 translog_get_chunk_header_length(uchar *page, uint16 offset) ...@@ -2743,7 +2736,8 @@ static uint16 translog_get_chunk_header_length(uchar *page, uint16 offset)
/** /**
@brief Truncate the log to the given address @brief Truncate the log to the given address. Used during the startup if the
end of log if corrupted.
@param addr new horizon @param addr new horizon
...@@ -2855,9 +2849,9 @@ my_bool translog_init(const char *directory, ...@@ -2855,9 +2849,9 @@ my_bool translog_init(const char *directory,
MY_MUTEX_INIT_FAST) || MY_MUTEX_INIT_FAST) ||
pthread_mutex_init(&log_descriptor.log_flush_lock, pthread_mutex_init(&log_descriptor.log_flush_lock,
MY_MUTEX_INIT_FAST) || MY_MUTEX_INIT_FAST) ||
init_dynamic_array(&log_descriptor.unfinished_files, my_init_dynamic_array(&log_descriptor.unfinished_files,
sizeof(struct st_file_counter), sizeof(struct st_file_counter),
10, 10 CALLER_INFO)) 10, 10))
DBUG_RETURN(1); DBUG_RETURN(1);
log_descriptor.min_file_number= 0; log_descriptor.min_file_number= 0;
log_descriptor.last_lsn_checked= LSN_IMPOSSIBLE; log_descriptor.last_lsn_checked= LSN_IMPOSSIBLE;
...@@ -2900,7 +2894,7 @@ my_bool translog_init(const char *directory, ...@@ -2900,7 +2894,7 @@ my_bool translog_init(const char *directory,
log_descriptor.page_overhead= page_overhead[flags]; log_descriptor.page_overhead= page_overhead[flags];
log_descriptor.page_capacity_chunk_2= log_descriptor.page_capacity_chunk_2=
TRANSLOG_PAGE_SIZE - log_descriptor.page_overhead - 1; TRANSLOG_PAGE_SIZE - log_descriptor.page_overhead - 1;
DBUG_ASSERT(TRANSLOG_WRITE_BUFFER % TRANSLOG_PAGE_SIZE == 0); compile_time_assert(TRANSLOG_WRITE_BUFFER % TRANSLOG_PAGE_SIZE == 0);
log_descriptor.buffer_capacity_chunk_2= log_descriptor.buffer_capacity_chunk_2=
(TRANSLOG_WRITE_BUFFER / TRANSLOG_PAGE_SIZE) * (TRANSLOG_WRITE_BUFFER / TRANSLOG_PAGE_SIZE) *
log_descriptor.page_capacity_chunk_2; log_descriptor.page_capacity_chunk_2;
...@@ -2934,6 +2928,10 @@ my_bool translog_init(const char *directory, ...@@ -2934,6 +2928,10 @@ my_bool translog_init(const char *directory,
i, (ulong) log_descriptor.buffers + i)); i, (ulong) log_descriptor.buffers + i));
} }
/*
last_logno and last_checkpoint_lsn were set in
ma_control_file_create_or_open()
*/
logs_found= (last_logno != FILENO_IMPOSSIBLE); logs_found= (last_logno != FILENO_IMPOSSIBLE);
if (logs_found) if (logs_found)
...@@ -2958,7 +2956,7 @@ my_bool translog_init(const char *directory, ...@@ -2958,7 +2956,7 @@ my_bool translog_init(const char *directory,
DBUG_ASSERT(LSN_OFFSET(sure_page) % TRANSLOG_PAGE_SIZE != 0); DBUG_ASSERT(LSN_OFFSET(sure_page) % TRANSLOG_PAGE_SIZE != 0);
sure_page-= LSN_OFFSET(sure_page) % TRANSLOG_PAGE_SIZE; sure_page-= LSN_OFFSET(sure_page) % TRANSLOG_PAGE_SIZE;
} }
log_descriptor.horizon= last_page= MAKE_LSN(last_logno,0); log_descriptor.horizon= last_page= MAKE_LSN(last_logno, 0);
if (translog_get_last_page_addr(&last_page, &pageok)) if (translog_get_last_page_addr(&last_page, &pageok))
DBUG_RETURN(1); DBUG_RETURN(1);
if (LSN_OFFSET(last_page) == 0) if (LSN_OFFSET(last_page) == 0)
...@@ -3179,7 +3177,7 @@ my_bool translog_init(const char *directory, ...@@ -3179,7 +3177,7 @@ my_bool translog_init(const char *directory,
*/ */
page_addr= (log_descriptor.horizon - page_addr= (log_descriptor.horizon -
((log_descriptor.horizon - 1) % TRANSLOG_PAGE_SIZE + 1)); ((log_descriptor.horizon - 1) % TRANSLOG_PAGE_SIZE + 1));
if (translog_init_scanner(page_addr, 1, &scanner, 1)) if (translog_scanner_init(page_addr, 1, &scanner, 1))
DBUG_RETURN(1); DBUG_RETURN(1);
scanner.page_offset= page_overhead[scanner.page[TRANSLOG_PAGE_FLAGS]]; scanner.page_offset= page_overhead[scanner.page[TRANSLOG_PAGE_FLAGS]];
for (;;) for (;;)
...@@ -3251,7 +3249,7 @@ my_bool translog_init(const char *directory, ...@@ -3251,7 +3249,7 @@ my_bool translog_init(const char *directory,
page_addr-= TRANSLOG_PAGE_SIZE; page_addr-= TRANSLOG_PAGE_SIZE;
} }
translog_destroy_scanner(&scanner); translog_destroy_scanner(&scanner);
if (translog_init_scanner(page_addr, 1, &scanner, 1)) if (translog_scanner_init(page_addr, 1, &scanner, 1))
DBUG_RETURN(1); DBUG_RETURN(1);
scanner.page_offset= page_overhead[scanner.page[TRANSLOG_PAGE_FLAGS]]; scanner.page_offset= page_overhead[scanner.page[TRANSLOG_PAGE_FLAGS]];
} }
...@@ -3307,14 +3305,9 @@ my_bool translog_init(const char *directory, ...@@ -3307,14 +3305,9 @@ my_bool translog_init(const char *directory,
/* /*
Free transaction log file buffer @brief Free transaction log file buffer.
SYNOPSIS
translog_buffer_destroy()
buffer_no The buffer to free
NOTE @param buffer_no The buffer to free
This buffer should be locked
*/ */
static void translog_buffer_destroy(struct st_translog_buffer *buffer) static void translog_buffer_destroy(struct st_translog_buffer *buffer)
...@@ -3392,21 +3385,17 @@ void translog_destroy() ...@@ -3392,21 +3385,17 @@ void translog_destroy()
/* /*
Start new page @brief Starts new page.
SYNOPSIS @param horizon \ Position in file and buffer where we are
translog_page_next() @param cursor /
horizon \ Position in file and buffer where we are @param prev_buffer Buffer which should be flushed will be assigned here.
cursor / This is always set (to NULL if nothing to flush).
prev_buffer Buffer which should be flushed will be assigned
here if it is need. This is always set.
NOTE @note handler should be locked.
handler should be locked
RETURN @retval 0 OK
0 OK @retval 1 Error
1 Error
*/ */
static my_bool translog_page_next(TRANSLOG_ADDRESS *horizon, static my_bool translog_page_next(TRANSLOG_ADDRESS *horizon,
...@@ -3416,7 +3405,7 @@ static my_bool translog_page_next(TRANSLOG_ADDRESS *horizon, ...@@ -3416,7 +3405,7 @@ static my_bool translog_page_next(TRANSLOG_ADDRESS *horizon,
struct st_translog_buffer *buffer= cursor->buffer; struct st_translog_buffer *buffer= cursor->buffer;
DBUG_ENTER("translog_page_next"); DBUG_ENTER("translog_page_next");
if ((cursor->ptr +TRANSLOG_PAGE_SIZE > if ((cursor->ptr + TRANSLOG_PAGE_SIZE >
cursor->buffer->buffer + TRANSLOG_WRITE_BUFFER) || cursor->buffer->buffer + TRANSLOG_WRITE_BUFFER) ||
(LSN_OFFSET(*horizon) > (LSN_OFFSET(*horizon) >
log_descriptor.log_file_max_size - TRANSLOG_PAGE_SIZE)) log_descriptor.log_file_max_size - TRANSLOG_PAGE_SIZE))
...@@ -3482,7 +3471,7 @@ static my_bool translog_write_data_on_page(TRANSLOG_ADDRESS *horizon, ...@@ -3482,7 +3471,7 @@ static my_bool translog_write_data_on_page(TRANSLOG_ADDRESS *horizon,
(ulong) length, (uint) cursor->current_page_fill)); (ulong) length, (uint) cursor->current_page_fill));
DBUG_ASSERT(length > 0); DBUG_ASSERT(length > 0);
DBUG_ASSERT(length + cursor->current_page_fill <= TRANSLOG_PAGE_SIZE); DBUG_ASSERT(length + cursor->current_page_fill <= TRANSLOG_PAGE_SIZE);
DBUG_ASSERT(length + cursor->ptr <=cursor->buffer->buffer + DBUG_ASSERT(length + cursor->ptr <= cursor->buffer->buffer +
TRANSLOG_WRITE_BUFFER); TRANSLOG_WRITE_BUFFER);
memcpy(cursor->ptr, buffer, length); memcpy(cursor->ptr, buffer, length);
...@@ -4023,6 +4012,7 @@ translog_write_variable_record_1group(LSN *lsn, ...@@ -4023,6 +4012,7 @@ translog_write_variable_record_1group(LSN *lsn,
uint additional_chunk3_page= 0; uint additional_chunk3_page= 0;
uchar chunk0_header[1 + 2 + 5 + 2]; uchar chunk0_header[1 + 2 + 5 + 2];
DBUG_ENTER("translog_write_variable_record_1group"); DBUG_ENTER("translog_write_variable_record_1group");
translog_lock_assert_owner();
*lsn= horizon= log_descriptor.horizon; *lsn= horizon= log_descriptor.horizon;
if (translog_set_lsn_for_files(LSN_FILE_NO(*lsn), LSN_FILE_NO(*lsn), if (translog_set_lsn_for_files(LSN_FILE_NO(*lsn), LSN_FILE_NO(*lsn),
...@@ -4037,7 +4027,7 @@ translog_write_variable_record_1group(LSN *lsn, ...@@ -4037,7 +4027,7 @@ translog_write_variable_record_1group(LSN *lsn,
cursor= log_descriptor.bc; cursor= log_descriptor.bc;
cursor.chaser= 1; cursor.chaser= 1;
/* Advance pointer To be able unlock the loghandler */ /* Advance pointer to be able unlock the loghandler */
first_page= translog_get_current_page_rest(); first_page= translog_get_current_page_rest();
record_rest= parts->record_length - (first_page - header_length); record_rest= parts->record_length - (first_page - header_length);
full_pages= record_rest / log_descriptor.page_capacity_chunk_2; full_pages= record_rest / log_descriptor.page_capacity_chunk_2;
...@@ -4170,6 +4160,7 @@ translog_write_variable_record_1chunk(LSN *lsn, ...@@ -4170,6 +4160,7 @@ translog_write_variable_record_1chunk(LSN *lsn,
int rc; int rc;
uchar chunk0_header[1 + 2 + 5 + 2]; uchar chunk0_header[1 + 2 + 5 + 2];
DBUG_ENTER("translog_write_variable_record_1chunk"); DBUG_ENTER("translog_write_variable_record_1chunk");
translog_lock_assert_owner();
translog_write_variable_record_1group_header(parts, type, short_trid, translog_write_variable_record_1group_header(parts, type, short_trid,
header_length, chunk0_header); header_length, chunk0_header);
...@@ -4207,30 +4198,22 @@ translog_write_variable_record_1chunk(LSN *lsn, ...@@ -4207,30 +4198,22 @@ translog_write_variable_record_1chunk(LSN *lsn,
/* /*
Calculate and write LSN difference (compressed LSN) @brief Calculates and write LSN difference (compressed LSN).
SYNOPSIS
translog_put_LSN_diff()
base_lsn LSN from which we calculate difference
lsn LSN for codding
dst Result will be written to dst[-pack_length] .. dst[-1]
NOTE: @param base_lsn LSN from which we calculate difference
To store an LSN in a compact way we will use the following compression: @param lsn LSN for codding
@param dst Result will be written to dst[-pack_length] .. dst[-1]
If a log record has LSN1, and it contains the lSN2 as a back reference, @note To store an LSN in a compact way we will use the following compression:
If a log record has LSN1, and it contains the LSN2 as a back reference,
Instead of LSN2 we write LSN1-LSN2, encoded as: Instead of LSN2 we write LSN1-LSN2, encoded as:
two bits the number N (see below) two bits the number N (see below)
14 bits 14 bits
N bytes N bytes
That is, LSN is encoded in 2..5 bytes, and the number of bytes minus 2 That is, LSN is encoded in 2..5 bytes, and the number of bytes minus 2
is stored in the first two bits. is stored in the first two bits.
RETURN @retval # pointer on coded LSN
# pointer on coded LSN
NULL Error
*/ */
static uchar *translog_put_LSN_diff(LSN base_lsn, LSN lsn, uchar *dst) static uchar *translog_put_LSN_diff(LSN base_lsn, LSN lsn, uchar *dst)
...@@ -4405,24 +4388,18 @@ static uchar *translog_get_LSN_from_diff(LSN base_lsn, uchar *src, uchar *dst) ...@@ -4405,24 +4388,18 @@ static uchar *translog_get_LSN_from_diff(LSN base_lsn, uchar *src, uchar *dst)
} }
/* /**
Encode relative LSNs listed in the parameters @brief Encodes relative LSNs listed in the parameters.
SYNOPSIS
translog_relative_LSN_encode()
parts Parts list with encoded LSN(s)
base_lsn LSN which is base for encoding
lsns number of LSN(s) to encode
compressed_LSNs buffer which can be used for storing compressed LSN(s)
RETURN @param parts Parts list with encoded LSN(s)
0 OK @param base_lsn LSN which is base for encoding
1 Error @param lsns number of LSN(s) to encode
@param compressed_LSNs buffer which can be used for storing compressed LSN(s)
*/ */
static my_bool translog_relative_LSN_encode(struct st_translog_parts *parts, static void translog_relative_LSN_encode(struct st_translog_parts *parts,
LSN base_lsn, LSN base_lsn,
uint lsns, uchar *compressed_LSNs) uint lsns, uchar *compressed_LSNs)
{ {
LEX_STRING *part; LEX_STRING *part;
uint lsns_len= lsns * LSN_STORE_SIZE; uint lsns_len= lsns * LSN_STORE_SIZE;
...@@ -4487,8 +4464,7 @@ static my_bool translog_relative_LSN_encode(struct st_translog_parts *parts, ...@@ -4487,8 +4464,7 @@ static my_bool translog_relative_LSN_encode(struct st_translog_parts *parts,
src_ptr-= LSN_STORE_SIZE) src_ptr-= LSN_STORE_SIZE)
{ {
ref= lsn_korr(src_ptr); ref= lsn_korr(src_ptr);
if ((dst_ptr= translog_put_LSN_diff(base_lsn, ref, dst_ptr)) == NULL) dst_ptr= translog_put_LSN_diff(base_lsn, ref, dst_ptr);
DBUG_RETURN(1);
} }
part->length= (uint)((compressed_LSNs + part->length= (uint)((compressed_LSNs +
(MAX_NUMBER_OF_LSNS_PER_RECORD * (MAX_NUMBER_OF_LSNS_PER_RECORD *
...@@ -4500,7 +4476,7 @@ static my_bool translog_relative_LSN_encode(struct st_translog_parts *parts, ...@@ -4500,7 +4476,7 @@ static my_bool translog_relative_LSN_encode(struct st_translog_parts *parts,
parts->total_record_length-= economy; parts->total_record_length-= economy;
part->str= (char*)dst_ptr; part->str= (char*)dst_ptr;
} }
DBUG_RETURN(0); DBUG_VOID_RETURN;
} }
...@@ -4555,11 +4531,13 @@ translog_write_variable_record_mgroup(LSN *lsn, ...@@ -4555,11 +4531,13 @@ translog_write_variable_record_mgroup(LSN *lsn,
uint groups_per_page= (page_capacity - header_fixed_part) / (7 + 1); uint groups_per_page= (page_capacity - header_fixed_part) / (7 + 1);
uint file_of_the_first_group; uint file_of_the_first_group;
DBUG_ENTER("translog_write_variable_record_mgroup"); DBUG_ENTER("translog_write_variable_record_mgroup");
translog_lock_assert_owner();
chunk2_header[0]= TRANSLOG_CHUNK_NOHDR; chunk2_header[0]= TRANSLOG_CHUNK_NOHDR;
if (init_dynamic_array(&groups, sizeof(struct st_translog_group_descriptor), if (my_init_dynamic_array(&groups,
10, 10 CALLER_INFO)) sizeof(struct st_translog_group_descriptor),
10, 10))
{ {
translog_unlock(); translog_unlock();
UNRECOVERABLE_ERROR(("init array failed")); UNRECOVERABLE_ERROR(("init array failed"));
...@@ -5001,23 +4979,9 @@ static my_bool translog_write_variable_record(LSN *lsn, ...@@ -5001,23 +4979,9 @@ static my_bool translog_write_variable_record(LSN *lsn,
*/ */
if (log_record_type_descriptor[type].compressed_LSN > 0) if (log_record_type_descriptor[type].compressed_LSN > 0)
{ {
if (translog_relative_LSN_encode(parts, log_descriptor.horizon, translog_relative_LSN_encode(parts, log_descriptor.horizon,
log_record_type_descriptor[type]. log_record_type_descriptor[type].
compressed_LSN, compressed_LSNs)) compressed_LSN, compressed_LSNs);
{
translog_unlock();
if (buffer_to_flush != NULL)
{
/*
It is just try to finish log in nice way in case of error, so we
do not check result of the following functions, because we are
going return error state in any case
*/
translog_buffer_flush(buffer_to_flush);
translog_buffer_unlock(buffer_to_flush);
}
DBUG_RETURN(1);
}
/* recalculate header length after compression */ /* recalculate header length after compression */
header_length1= 1 + 2 + 2 + header_length1= 1 + 2 + 2 +
translog_variable_record_length_bytes(parts->record_length); translog_variable_record_length_bytes(parts->record_length);
...@@ -5090,11 +5054,11 @@ static my_bool translog_write_fixed_record(LSN *lsn, ...@@ -5090,11 +5054,11 @@ static my_bool translog_write_fixed_record(LSN *lsn,
LEX_STRING *part; LEX_STRING *part;
int rc; int rc;
DBUG_ENTER("translog_write_fixed_record"); DBUG_ENTER("translog_write_fixed_record");
DBUG_ASSERT((log_record_type_descriptor[type].class == DBUG_ASSERT((log_record_type_descriptor[type].rclass ==
LOGRECTYPE_FIXEDLENGTH && LOGRECTYPE_FIXEDLENGTH &&
parts->record_length == parts->record_length ==
log_record_type_descriptor[type].fixed_length) || log_record_type_descriptor[type].fixed_length) ||
(log_record_type_descriptor[type].class == (log_record_type_descriptor[type].rclass ==
LOGRECTYPE_PSEUDOFIXEDLENGTH && LOGRECTYPE_PSEUDOFIXEDLENGTH &&
parts->record_length == parts->record_length ==
log_record_type_descriptor[type].fixed_length)); log_record_type_descriptor[type].fixed_length));
...@@ -5139,16 +5103,13 @@ static my_bool translog_write_fixed_record(LSN *lsn, ...@@ -5139,16 +5103,13 @@ static my_bool translog_write_fixed_record(LSN *lsn,
} }
/* compress LSNs */ /* compress LSNs */
if (log_record_type_descriptor[type].class == LOGRECTYPE_PSEUDOFIXEDLENGTH) if (log_record_type_descriptor[type].rclass ==
LOGRECTYPE_PSEUDOFIXEDLENGTH)
{ {
DBUG_ASSERT(log_record_type_descriptor[type].compressed_LSN > 0); DBUG_ASSERT(log_record_type_descriptor[type].compressed_LSN > 0);
if (translog_relative_LSN_encode(parts, *lsn, translog_relative_LSN_encode(parts, *lsn,
log_record_type_descriptor[type]. log_record_type_descriptor[type].
compressed_LSN, compressed_LSNs)) compressed_LSN, compressed_LSNs);
{
rc= 1;
goto err;
}
} }
/* /*
...@@ -5280,7 +5241,7 @@ my_bool translog_write_record(LSN *lsn, ...@@ -5280,7 +5241,7 @@ my_bool translog_write_record(LSN *lsn,
parts.current= TRANSLOG_INTERNAL_PARTS; parts.current= TRANSLOG_INTERNAL_PARTS;
/* clear TRANSLOG_INTERNAL_PARTS */ /* clear TRANSLOG_INTERNAL_PARTS */
DBUG_ASSERT(TRANSLOG_INTERNAL_PARTS != 0); compile_time_assert(TRANSLOG_INTERNAL_PARTS != 0);
parts_data[0].str= 0; parts_data[0].str= 0;
parts_data[0].length= 0; parts_data[0].length= 0;
...@@ -5328,7 +5289,7 @@ my_bool translog_write_record(LSN *lsn, ...@@ -5328,7 +5289,7 @@ my_bool translog_write_record(LSN *lsn,
tbl_info, tbl_info,
hook_arg)))) hook_arg))))
{ {
switch (log_record_type_descriptor[type].class) { switch (log_record_type_descriptor[type].rclass) {
case LOGRECTYPE_VARIABLE_LENGTH: case LOGRECTYPE_VARIABLE_LENGTH:
rc= translog_write_variable_record(lsn, type, tbl_info, rc= translog_write_variable_record(lsn, type, tbl_info,
short_trid, &parts, trn, hook_arg); short_trid, &parts, trn, hook_arg);
...@@ -5405,7 +5366,7 @@ static int translog_fixed_length_header(uchar *page, ...@@ -5405,7 +5366,7 @@ static int translog_fixed_length_header(uchar *page,
buff->record_length= length; buff->record_length= length;
if (desc->class == LOGRECTYPE_PSEUDOFIXEDLENGTH) if (desc->rclass == LOGRECTYPE_PSEUDOFIXEDLENGTH)
{ {
DBUG_ASSERT(lsns > 0); DBUG_ASSERT(lsns > 0);
src= translog_relative_LSN_decode(buff->lsn, src, dst, lsns); src= translog_relative_LSN_decode(buff->lsn, src, dst, lsns);
...@@ -5489,8 +5450,7 @@ TRANSLOG_ADDRESS translog_get_horizon_no_lock() ...@@ -5489,8 +5450,7 @@ TRANSLOG_ADDRESS translog_get_horizon_no_lock()
1 Error 1 Error
*/ */
static my_bool translog_scanner_set_last_page(TRANSLOG_SCANNER_DATA static my_bool translog_scanner_set_last_page(TRANSLOG_SCANNER_DATA *scanner)
*scanner)
{ {
my_bool page_ok; my_bool page_ok;
if (LSN_FILE_NO(scanner->page_addr) == LSN_FILE_NO(scanner->horizon)) if (LSN_FILE_NO(scanner->page_addr) == LSN_FILE_NO(scanner->horizon))
...@@ -5550,13 +5510,13 @@ translog_scanner_get_page(TRANSLOG_SCANNER_DATA *scanner) ...@@ -5550,13 +5510,13 @@ translog_scanner_get_page(TRANSLOG_SCANNER_DATA *scanner)
@retval 1 Error @retval 1 Error
*/ */
my_bool translog_init_scanner(LSN lsn, my_bool translog_scanner_init(LSN lsn,
my_bool fixed_horizon, my_bool fixed_horizon,
TRANSLOG_SCANNER_DATA *scanner, TRANSLOG_SCANNER_DATA *scanner,
my_bool use_direct) my_bool use_direct)
{ {
TRANSLOG_VALIDATOR_DATA data; TRANSLOG_VALIDATOR_DATA data;
DBUG_ENTER("translog_init_scanner"); DBUG_ENTER("translog_scanner_init");
DBUG_PRINT("enter", ("Scanner: 0x%lx LSN: (0x%lu,0x%lx)", DBUG_PRINT("enter", ("Scanner: 0x%lx LSN: (0x%lu,0x%lx)",
(ulong) scanner, LSN_IN_PARTS(lsn))); (ulong) scanner, LSN_IN_PARTS(lsn)));
DBUG_ASSERT(translog_inited == 1); DBUG_ASSERT(translog_inited == 1);
...@@ -5646,16 +5606,13 @@ static my_bool translog_scanner_eol(TRANSLOG_SCANNER_DATA *scanner) ...@@ -5646,16 +5606,13 @@ static my_bool translog_scanner_eol(TRANSLOG_SCANNER_DATA *scanner)
} }
/* /**
Cheks End of the Page @brief Cheks End of the Page
SYNOPSIS @param scanner Information about current chunk during scanning
translog_scanner_eop()
scanner Information about current chunk during scanning
RETURN @retval 1 End of the Page
1 End of the Page @retval 0 OK
0 OK
*/ */
static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner) static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner)
...@@ -5666,17 +5623,14 @@ static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner) ...@@ -5666,17 +5623,14 @@ static my_bool translog_scanner_eop(TRANSLOG_SCANNER_DATA *scanner)
} }
/* /**
Checks End of the File (I.e. we are scanning last page, which do not @brief Checks End of the File (i.e. we are scanning last page, which do not
mean end of this page) mean end of this page)
SYNOPSIS @param scanner Information about current chunk during scanning
translog_scanner_eof()
scanner Information about current chunk during scanning
RETURN @retval 1 End of the File
1 End of the File @retval 0 OK
0 OK
*/ */
static my_bool translog_scanner_eof(TRANSLOG_SCANNER_DATA *scanner) static my_bool translog_scanner_eof(TRANSLOG_SCANNER_DATA *scanner)
...@@ -5884,7 +5838,7 @@ translog_variable_length_header(uchar *page, translog_size_t page_offset, ...@@ -5884,7 +5838,7 @@ translog_variable_length_header(uchar *page, translog_size_t page_offset,
{ {
DBUG_PRINT("info", ("use internal scanner for header reading")); DBUG_PRINT("info", ("use internal scanner for header reading"));
scanner= &internal_scanner; scanner= &internal_scanner;
if (translog_init_scanner(buff->lsn, 1, scanner, 0)) if (translog_scanner_init(buff->lsn, 1, scanner, 0))
DBUG_RETURN(RECHEADER_READ_ERROR); DBUG_RETURN(RECHEADER_READ_ERROR);
} }
if (translog_get_next_chunk(scanner)) if (translog_get_next_chunk(scanner))
...@@ -5917,7 +5871,7 @@ translog_variable_length_header(uchar *page, translog_size_t page_offset, ...@@ -5917,7 +5871,7 @@ translog_variable_length_header(uchar *page, translog_size_t page_offset,
translog_destroy_scanner(scanner); translog_destroy_scanner(scanner);
} }
base_lsn= buff->groups[0].addr; base_lsn= buff->groups[0].addr;
translog_init_scanner(base_lsn, 1, scanner, scanner == &internal_scanner); translog_scanner_init(base_lsn, 1, scanner, scanner == &internal_scanner);
/* first group chunk is always chunk type 2 */ /* first group chunk is always chunk type 2 */
page= scanner->page; page= scanner->page;
page_offset= scanner->page_offset; page_offset= scanner->page_offset;
...@@ -5992,7 +5946,7 @@ int translog_read_record_header_from_buffer(uchar *page, ...@@ -5992,7 +5946,7 @@ int translog_read_record_header_from_buffer(uchar *page,
(uint) buff->type, (uint)buff->short_trid, (uint) buff->type, (uint)buff->short_trid,
LSN_IN_PARTS(buff->lsn))); LSN_IN_PARTS(buff->lsn)));
/* Read required bytes from the header and call hook */ /* Read required bytes from the header and call hook */
switch (log_record_type_descriptor[buff->type].class) { switch (log_record_type_descriptor[buff->type].rclass) {
case LOGRECTYPE_VARIABLE_LENGTH: case LOGRECTYPE_VARIABLE_LENGTH:
res= translog_variable_length_header(page, page_offset, buff, res= translog_variable_length_header(page, page_offset, buff,
scanner); scanner);
...@@ -6184,8 +6138,7 @@ int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner, ...@@ -6184,8 +6138,7 @@ int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner,
1 Error 1 Error
*/ */
static my_bool translog_record_read_next_chunk(struct st_translog_reader_data static my_bool translog_record_read_next_chunk(TRANSLOG_READER_DATA *data)
*data)
{ {
translog_size_t new_current_offset= data->current_offset + data->chunk_size; translog_size_t new_current_offset= data->current_offset + data->chunk_size;
uint16 chunk_header_len, chunk_len; uint16 chunk_header_len, chunk_len;
...@@ -6207,7 +6160,7 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data ...@@ -6207,7 +6160,7 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data
data->current_chunk= 0; data->current_chunk= 0;
DBUG_PRINT("info", ("skip to group: #%u", data->current_group)); DBUG_PRINT("info", ("skip to group: #%u", data->current_group));
translog_destroy_scanner(&data->scanner); translog_destroy_scanner(&data->scanner);
translog_init_scanner(data->header.groups[data->current_group].addr, translog_scanner_init(data->header.groups[data->current_group].addr,
1, &data->scanner, 1); 1, &data->scanner, 1);
} }
else else
...@@ -6218,8 +6171,8 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data ...@@ -6218,8 +6171,8 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data
if (data->scanner.page == END_OF_LOG) if (data->scanner.page == END_OF_LOG)
{ {
/* /*
Actually it should not happened, but we wont quite nice in case of Actually it should not happened, but we want to quit nicely in case
cut log of a truncated log
*/ */
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -6236,7 +6189,7 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data ...@@ -6236,7 +6189,7 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data
DBUG_ASSERT(data->header.lsn == DBUG_ASSERT(data->header.lsn ==
data->scanner.page_addr + data->scanner.page_offset); data->scanner.page_addr + data->scanner.page_offset);
translog_destroy_scanner(&data->scanner); translog_destroy_scanner(&data->scanner);
translog_init_scanner(data->header.chunk0_data_addr, 1, &data->scanner, 1); translog_scanner_init(data->header.chunk0_data_addr, 1, &data->scanner, 1);
data->chunk_size= data->header.chunk0_data_len; data->chunk_size= data->header.chunk0_data_len;
data->body_offset= data->scanner.page_offset; data->body_offset= data->scanner.page_offset;
data->current_offset= new_current_offset; data->current_offset= new_current_offset;
...@@ -6251,7 +6204,7 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data ...@@ -6251,7 +6204,7 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data
} }
chunk_header_len= chunk_header_len=
translog_get_chunk_header_length(data->scanner.page, translog_get_chunk_header_length(data->scanner.page +
data->scanner.page_offset); data->scanner.page_offset);
chunk_len= translog_get_total_chunk_length(data->scanner.page, chunk_len= translog_get_total_chunk_length(data->scanner.page,
data->scanner.page_offset); data->scanner.page_offset);
...@@ -6282,11 +6235,11 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data ...@@ -6282,11 +6235,11 @@ static my_bool translog_record_read_next_chunk(struct st_translog_reader_data
*/ */
static my_bool translog_init_reader_data(LSN lsn, static my_bool translog_init_reader_data(LSN lsn,
struct st_translog_reader_data *data) TRANSLOG_READER_DATA *data)
{ {
int read_header; int read_header;
DBUG_ENTER("translog_init_reader_data"); DBUG_ENTER("translog_init_reader_data");
if (translog_init_scanner(lsn, 1, &data->scanner, 1) || if (translog_scanner_init(lsn, 1, &data->scanner, 1) ||
((read_header= ((read_header=
translog_read_record_header_scan(&data->scanner, &data->header, 1)) translog_read_record_header_scan(&data->scanner, &data->header, 1))
== RECHEADER_READ_ERROR)) == RECHEADER_READ_ERROR))
...@@ -6311,7 +6264,7 @@ static my_bool translog_init_reader_data(LSN lsn, ...@@ -6311,7 +6264,7 @@ static my_bool translog_init_reader_data(LSN lsn,
@brief Destroy reader data object @brief Destroy reader data object
*/ */
static void translog_destroy_reader_data(struct st_translog_reader_data *data) static void translog_destroy_reader_data(TRANSLOG_READER_DATA *data)
{ {
translog_destroy_scanner(&data->scanner); translog_destroy_scanner(&data->scanner);
} }
...@@ -6337,11 +6290,11 @@ translog_size_t translog_read_record(LSN lsn, ...@@ -6337,11 +6290,11 @@ translog_size_t translog_read_record(LSN lsn,
translog_size_t offset, translog_size_t offset,
translog_size_t length, translog_size_t length,
uchar *buffer, uchar *buffer,
struct st_translog_reader_data *data) TRANSLOG_READER_DATA *data)
{ {
translog_size_t requested_length= length; translog_size_t requested_length= length;
translog_size_t end= offset + length; translog_size_t end= offset + length;
struct st_translog_reader_data internal_data; TRANSLOG_READER_DATA internal_data;
DBUG_ENTER("translog_read_record"); DBUG_ENTER("translog_read_record");
DBUG_ASSERT(translog_inited == 1); DBUG_ASSERT(translog_inited == 1);
...@@ -6605,7 +6558,7 @@ static void translog_force_current_buffer_to_finish() ...@@ -6605,7 +6558,7 @@ static void translog_force_current_buffer_to_finish()
@todo: remove serialization and make group commit. @todo: remove serialization and make group commit.
*/ */
my_bool translog_flush(LSN lsn) my_bool translog_flush(TRANSLOG_ADDRESS lsn)
{ {
LSN old_flushed, sent_to_disk; LSN old_flushed, sent_to_disk;
TRANSLOG_ADDRESS flush_horizon; TRANSLOG_ADDRESS flush_horizon;
...@@ -6941,7 +6894,7 @@ LSN translog_next_LSN(TRANSLOG_ADDRESS addr, TRANSLOG_ADDRESS horizon) ...@@ -6941,7 +6894,7 @@ LSN translog_next_LSN(TRANSLOG_ADDRESS addr, TRANSLOG_ADDRESS horizon)
if (addr == horizon) if (addr == horizon)
DBUG_RETURN(LSN_IMPOSSIBLE); DBUG_RETURN(LSN_IMPOSSIBLE);
translog_init_scanner(addr, 0, &scanner, 1); translog_scanner_init(addr, 0, &scanner, 1);
/* /*
addr can point not to a chunk beginning but page end so next addr can point not to a chunk beginning but page end so next
page beginning. page beginning.
......
...@@ -76,29 +76,23 @@ struct st_maria_handler; ...@@ -76,29 +76,23 @@ struct st_maria_handler;
#define ha_checksum_store(T,A) int4store(T,A) #define ha_checksum_store(T,A) int4store(T,A)
#define fileid_korr(P) uint2korr(P) #define fileid_korr(P) uint2korr(P)
#define page_korr(P) uint5korr(P) #define page_korr(P) uint5korr(P)
#define dirpos_korr(P) ((P)[0]) #define dirpos_korr(P) (*(uchar *) (P))
#define pagerange_korr(P) uint2korr(P) #define pagerange_korr(P) uint2korr(P)
#define clr_type_korr(P) ((P)[0]) #define clr_type_korr(P) (*(uchar *) (P))
#define key_nr_korr(P) ((P)[0]) #define key_nr_korr(P) ((P)[0])
#define ha_checksum_korr(P) uint4korr(P) #define ha_checksum_korr(P) uint4korr(P)
/* /*
Length of disk drive sector size (we assume that writing it Length of disk drive sector size (we assume that writing it
to disk is atomic operation) to disk is an atomic operation)
*/ */
#define DISK_DRIVE_SECTOR_SIZE 512 #define DISK_DRIVE_SECTOR_SIZE 512
/*
Number of empty entries we need to have in LEX_STRING for
translog_write_record()
*/
#define LOG_INTERNAL_PARTS 1
/* position reserved in an array of parts of a log record */ /* position reserved in an array of parts of a log record */
#define TRANSLOG_INTERNAL_PARTS 2 #define TRANSLOG_INTERNAL_PARTS 2
/* types of records in the transaction log */ /* types of records in the transaction log */
/* Todo: Set numbers for these when we have all entries figured out */ /* TODO: Set numbers for these when we have all entries figured out */
enum translog_record_type enum translog_record_type
{ {
...@@ -228,7 +222,7 @@ typedef struct st_translog_scanner_data ...@@ -228,7 +222,7 @@ typedef struct st_translog_scanner_data
} TRANSLOG_SCANNER_DATA; } TRANSLOG_SCANNER_DATA;
struct st_translog_reader_data typedef struct st_translog_reader_data
{ {
TRANSLOG_HEADER_BUFFER header; /* Header */ TRANSLOG_HEADER_BUFFER header; /* Header */
TRANSLOG_SCANNER_DATA scanner; /* chunks scanner */ TRANSLOG_SCANNER_DATA scanner; /* chunks scanner */
...@@ -241,9 +235,8 @@ struct st_translog_reader_data ...@@ -241,9 +235,8 @@ struct st_translog_reader_data
uint current_group; /* current group */ uint current_group; /* current group */
uint current_chunk; /* current chunk in the group */ uint current_chunk; /* current chunk in the group */
my_bool eor; /* end of the record */ my_bool eor; /* end of the record */
}; } TRANSLOG_READER_DATA;
struct st_transaction;
C_MODE_START C_MODE_START
/* Records types for unittests */ /* Records types for unittests */
...@@ -259,8 +252,7 @@ extern my_bool translog_init(const char *directory, uint32 log_file_max_size, ...@@ -259,8 +252,7 @@ extern my_bool translog_init(const char *directory, uint32 log_file_max_size,
PAGECACHE *pagecache, uint flags); PAGECACHE *pagecache, uint flags);
extern my_bool extern my_bool
translog_write_record(LSN *lsn, enum translog_record_type type, translog_write_record(LSN *lsn, enum translog_record_type type, TRN *trn,
struct st_transaction *trn,
MARIA_HA *tbl_info, MARIA_HA *tbl_info,
translog_size_t rec_len, uint part_no, translog_size_t rec_len, uint part_no,
LEX_STRING *parts_data, uchar *store_share_id, LEX_STRING *parts_data, uchar *store_share_id,
...@@ -279,9 +271,9 @@ extern translog_size_t translog_read_record(LSN lsn, ...@@ -279,9 +271,9 @@ extern translog_size_t translog_read_record(LSN lsn,
struct st_translog_reader_data struct st_translog_reader_data
*data); *data);
extern my_bool translog_flush(LSN lsn); extern my_bool translog_flush(TRANSLOG_ADDRESS lsn);
extern my_bool translog_init_scanner(LSN lsn, extern my_bool translog_scanner_init(LSN lsn,
my_bool fixed_horizon, my_bool fixed_horizon,
struct st_translog_scanner_data *scanner, struct st_translog_scanner_data *scanner,
my_bool use_direct_link); my_bool use_direct_link);
...@@ -298,7 +290,7 @@ extern void translog_lock_assert_owner(); ...@@ -298,7 +290,7 @@ extern void translog_lock_assert_owner();
extern TRANSLOG_ADDRESS translog_get_horizon(); extern TRANSLOG_ADDRESS translog_get_horizon();
extern TRANSLOG_ADDRESS translog_get_horizon_no_lock(); extern TRANSLOG_ADDRESS translog_get_horizon_no_lock();
extern int translog_assign_id_to_share(struct st_maria_handler *tbl_info, extern int translog_assign_id_to_share(struct st_maria_handler *tbl_info,
struct st_transaction *trn); TRN *trn);
extern void translog_deassign_id_from_share(struct st_maria_share *share); extern void translog_deassign_id_from_share(struct st_maria_share *share);
extern void extern void
translog_assign_id_to_share_from_recovery(struct st_maria_share *share, translog_assign_id_to_share_from_recovery(struct st_maria_share *share,
...@@ -355,21 +347,17 @@ enum record_class ...@@ -355,21 +347,17 @@ enum record_class
LOGRECTYPE_FIXEDLENGTH LOGRECTYPE_FIXEDLENGTH
}; };
/* C++ can't bear that a variable's name is "class" */
#ifndef __cplusplus
enum enum_record_in_group { enum enum_record_in_group {
LOGREC_NOT_LAST_IN_GROUP= 0, LOGREC_LAST_IN_GROUP, LOGREC_IS_GROUP_ITSELF LOGREC_NOT_LAST_IN_GROUP= 0, LOGREC_LAST_IN_GROUP, LOGREC_IS_GROUP_ITSELF
}; };
/* /*
Descriptor of log record type Descriptor of log record type
Note: Don't reorder because of constructs later...
*/ */
typedef struct st_log_record_type_descriptor typedef struct st_log_record_type_descriptor
{ {
/* internal class of the record */ /* internal class of the record */
enum record_class class; enum record_class rclass;
/* /*
length for fixed-size record, pseudo-fixed record length for fixed-size record, pseudo-fixed record
length with uncompressed LSNs length with uncompressed LSNs
...@@ -399,7 +387,6 @@ typedef struct st_log_record_type_descriptor ...@@ -399,7 +387,6 @@ typedef struct st_log_record_type_descriptor
} LOG_DESC; } LOG_DESC;
extern LOG_DESC log_record_type_descriptor[LOGREC_NUMBER_OF_TYPES]; extern LOG_DESC log_record_type_descriptor[LOGREC_NUMBER_OF_TYPES];
#endif
typedef enum typedef enum
{ {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
Transaction log record address: Transaction log record address:
file_no << 32 | offset file_no << 32 | offset
file_no is only 3 bytes so we can use signed integer to make file_no is only 3 bytes so we can use signed integer to make
comparison more simple. comparison simpler.
*/ */
typedef int64 TRANSLOG_ADDRESS; typedef int64 TRANSLOG_ADDRESS;
...@@ -67,11 +67,11 @@ typedef TRANSLOG_ADDRESS LSN; ...@@ -67,11 +67,11 @@ typedef TRANSLOG_ADDRESS LSN;
#define lsn_store(dst, lsn) \ #define lsn_store(dst, lsn) \
do { \ do { \
int3store((dst), LSN_FILE_NO(lsn)); \ int3store((dst), LSN_FILE_NO(lsn)); \
int4store((dst) + 3, LSN_OFFSET(lsn)); \ int4store((char*)(dst) + 3, LSN_OFFSET(lsn)); \
} while (0) } while (0)
/* Unpacks LSN from the buffer (P) */ /* Unpacks LSN from the buffer (P) */
#define lsn_korr(P) MAKE_LSN(uint3korr(P), uint4korr((P) + 3)) #define lsn_korr(P) MAKE_LSN(uint3korr(P), uint4korr((char*)(P) + 3))
/* what we need to add to LSN to increase it on one file */ /* what we need to add to LSN to increase it on one file */
#define LSN_ONE_FILE ((int64)0x100000000LL) #define LSN_ONE_FILE ((int64)0x100000000LL)
...@@ -98,7 +98,7 @@ typedef LSN LSN_WITH_FLAGS; ...@@ -98,7 +98,7 @@ typedef LSN LSN_WITH_FLAGS;
/** /**
@brief the maximum valid LSN. @brief the maximum valid LSN.
Unlike ULONGLONG_MAX, it can be safely used in comparison with valid LSNs Unlike ULONGLONG_MAX, it can be safely used in comparison with valid LSNs
(ULONGLONG_MAX is too big for correctness of cmp_translog_address()). (ULONGLONG_MAX is too big for correctness of cmp_translog_addr()).
*/ */
#define LSN_MAX (LSN)ULL(0x00FFFFFFFFFFFFFF) #define LSN_MAX (LSN)ULL(0x00FFFFFFFFFFFFFF)
......
...@@ -2141,7 +2141,7 @@ static int run_redo_phase(LSN lsn, enum maria_apply_log_way apply) ...@@ -2141,7 +2141,7 @@ static int run_redo_phase(LSN lsn, enum maria_apply_log_way apply)
eprint(tracef, "Failed to read header of the first record.\n"); eprint(tracef, "Failed to read header of the first record.\n");
return 1; return 1;
} }
if (translog_init_scanner(lsn, 1, &scanner, 1)) if (translog_scanner_init(lsn, 1, &scanner, 1))
{ {
tprint(tracef, "Scanner init failed\n"); tprint(tracef, "Scanner init failed\n");
return 1; return 1;
...@@ -2189,7 +2189,7 @@ static int run_redo_phase(LSN lsn, enum maria_apply_log_way apply) ...@@ -2189,7 +2189,7 @@ static int run_redo_phase(LSN lsn, enum maria_apply_log_way apply)
tprint(tracef, "Cannot find record where it should be\n"); tprint(tracef, "Cannot find record where it should be\n");
goto err; goto err;
} }
if (translog_init_scanner(rec2.lsn, 1, &scanner2, 1)) if (translog_scanner_init(rec2.lsn, 1, &scanner2, 1))
{ {
tprint(tracef, "Scanner2 init failed\n"); tprint(tracef, "Scanner2 init failed\n");
goto err; goto err;
......
...@@ -45,7 +45,7 @@ void example_loghandler_init() ...@@ -45,7 +45,7 @@ void example_loghandler_init()
for (i= LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE + 1; for (i= LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE + 1;
i < LOGREC_NUMBER_OF_TYPES; i < LOGREC_NUMBER_OF_TYPES;
i++) i++)
log_record_type_descriptor[i].class= LOGRECTYPE_NOT_ALLOWED; log_record_type_descriptor[i].rclass= LOGRECTYPE_NOT_ALLOWED;
} }
......
...@@ -374,7 +374,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -374,7 +374,7 @@ int main(int argc __attribute__((unused)), char *argv[])
read_ok(&rec); read_ok(&rec);
translog_free_record_header(&rec); translog_free_record_header(&rec);
lsn= first_lsn; lsn= first_lsn;
if (translog_init_scanner(first_lsn, 1, &scanner, 0)) if (translog_scanner_init(first_lsn, 1, &scanner, 0))
{ {
fprintf(stderr, "scanner init failed\n"); fprintf(stderr, "scanner init failed\n");
goto err; goto err;
......
...@@ -377,7 +377,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -377,7 +377,7 @@ int main(int argc __attribute__((unused)), char *argv[])
ok(1, "read record"); ok(1, "read record");
translog_free_record_header(&rec); translog_free_record_header(&rec);
lsn= first_lsn; lsn= first_lsn;
if (translog_init_scanner(first_lsn, 1, &scanner, 0)) if (translog_scanner_init(first_lsn, 1, &scanner, 0))
{ {
fprintf(stderr, "scanner init failed\n"); fprintf(stderr, "scanner init failed\n");
goto err; goto err;
......
...@@ -374,7 +374,7 @@ int main(int argc __attribute__((unused)), ...@@ -374,7 +374,7 @@ int main(int argc __attribute__((unused)),
bzero(indeces, sizeof(indeces)); bzero(indeces, sizeof(indeces));
if (translog_init_scanner(first_lsn, 1, &scanner, 0)) if (translog_scanner_init(first_lsn, 1, &scanner, 0))
{ {
fprintf(stderr, "scanner init failed\n"); fprintf(stderr, "scanner init failed\n");
goto err; goto err;
......
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