Commit 198a1b6f authored by unknown's avatar unknown

WL#3072 - Maria recovery.

* Recovery of the table's live checksum (CREATE TABLE ... CHECKSUM=1)
is achieved in this patch. The table's live checksum
(info->s->state.state.checksum) is updated in inwrite_rec_hook's
under the log mutex when writing UNDO_ROW_INSERT|UPDATE|DELETE
and REDO_DELETE_ALL. The checksum variation caused by the operation
is stored in these UNDOs, so that the REDO phase, when it sees such
UNDOs, can update the live checksum if it is older (state.is_of_lsn is
lower) than the record. It is also used, as a nice add-on with no
cost, to do less row checksum computation during the UNDO phase
(as we have it in the record already).
Doing this work, it became pressing to move in-write hooks
(write_hook_for_redo() et al) to ma_blockrec.c.
The 'parts' argument of inwrite_rec_hook is unpredictable (it comes
mangled at this stage, for example by LSN compression) so it is
replaced by a 'void* hook_arg', which is used to pass down information,
currently only to write_hook_for_clr_end() (previous undo_lsn and
type of undone record).
* If from ha_maria, we print to stderr how many seconds (with one
fractional digit) the REDO phase took, same for UNDO phase and for
final table close. Just to give an indication for debugging and maybe
also for Support.


storage/maria/ha_maria.cc:
  question for Monty
storage/maria/ma_blockrec.c:
  * log in-write hooks (write_hook_for_redo() etc) move from
  ma_loghandler.c to here; this is natural: the hooks are coupled
  to their callers (functions in ma_blockrec.c).
  * translog_write_record() now has a new argument "hook_arg";
  using it to pass down to write_hook_for_clr_end() the transaction's
  previous_undo_lsn and the type of the being undone record, and also
  to pass down to all UNDOs the live checksum variation caused by the
  operation.
  * If table has live checksum, store in UNDO_ROW_INSERT|UPDATE|DELETE
  and in CLR_END the checksum variation ("delta") caused by the
  operation. For example if a DELETE caused the table's live checksum
  to change from 123 to 456, we store in the UNDO_ROW_DELETE, in 4 bytes,
  the value 333 (456-123).
  * Instead of hard-coded "1" as length of the place where we store
  the undone record's type in CLR_END, use a symbol CLR_TYPE_STORE_SIZE;
  use macros clr_type_store and clr_type_korr.
  * write_block_record() has a new parameter 'old_record_checksum'
  which is the pre-computed checksum of old_record; that value is used
  to update the table's live checksum when writing UNDO_ROW_UPDATE|CLR_END.
  * In allocate_write_block_record(), if we are executing UNDO_ROW_DELETE
  the row's checksum is already computed.
  * _ma_update_block_record2() now expect the new row's checksum into
  cur_row.checksum (was already true) and the old row's checksum into
  new_row.checksum (that's new). Its two callers, maria_update() and
  _ma_apply_undo_row_update(), honour this.
  * When executing an UNDO_ROW_INSERT|UPDATE|DELETE in UNDO phase, pick
  up the checksum delta from the log record. It is then used to update
  the table's live checksum when writing CLR_END, and saves us a
  computation of record.
storage/maria/ma_blockrec.h:
  in-write hooks move from ma_loghandler.c
storage/maria/ma_check.c:
  more straightforward size of buffer
storage/maria/ma_checkpoint.c:
  <= is enough
storage/maria/ma_commit.c:
  new prototype of translog_write_record()
storage/maria/ma_create.c:
  new prototype of translog_write_record()
storage/maria/ma_delete.c:
  The row's checksum must be computed before calling(*delete_record)(),
  not after, because it must be known inside _ma_delete_block_record()
  (to update the table's live checksum when writing UNDO_ROW_DELETE).
  If deleting from a transactional table, live checksum was already updated
  when writing UNDO_ROW_DELETE.
storage/maria/ma_delete_all.c:
  @todo is now done (in ma_loghandler.c)
storage/maria/ma_delete_table.c:
  new prototype of translog_write_record()
storage/maria/ma_loghandler.c:
  * in-write hooks move to ma_blockrec.c.
  * translog_write_record() gets a new argument 'hook_arg' which is
  passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
  for those hooks, because when those hooks are called, 'parts' has
  possibly been mangled (like with LSN compression) and is so
  unpredictable.
  * fix for compiler warning (unused buffer_start when compiling without
  debug support)
  * Because checksum delta is stored into UNDO_ROW_INSERT|UPDATE|DELETE
  and CLR_END, but only if the table has live checksum, these records
  are not PSEUDOFIXEDLENGTH anymore, they are now VARIABLE_LENGTH (their
  length is X if no live checksum and X+4 otherwise).
  * add an inwrite_rec_hook for UNDO_ROW_UPDATE, which updates the
  table's live checksum. Update it also in hooks of UNDO_ROW_INSERT|
  DELETE and REDO_DELETE_ALL and CLR_END.
  * Bugfix: when reading a record in translog_read_record(), it happened
  that "length" became negative, because the function assumed that
  the record extended beyond the page's end, whereas it may be shorter.
storage/maria/ma_loghandler.h:
  * Instead of hard-coded "1" and "4", use symbols and macros
  to store/retrieve the type of record which the CLR_END corresponds
  to, and the checksum variation caused by the operation which logs the
  record
  * translog_write_record() gets a new argument 'hook_arg' which is
  passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
  for those hooks, because when those hooks are called, 'parts' has
  possibly been mangled (like with LSN compression) and is so
  unpredictable.
storage/maria/ma_open.c:
  fix for "empty body in if() statement" (when compiling without safemutex)
storage/maria/ma_pagecache.c:
  <= is enough
storage/maria/ma_recovery.c:
  * print the time that each recovery phase (REDO/UNDO/flush) took;
  this is enabled only when recovering from ha_maria. Is it printed
  n seconds with a fractional part of one digit (like 123.4 seconds).
  * In the REDO phase, update the table's live checksum by using
  the checksum delta stored in UNDO_ROW_INSERT|DELETE|UPDATE and CLR_END.
  Update it too when seeing REDO_DELETE_ALL.
  * In the UNDO phase, when executing UNDO_ROW_INSERT, if the table does
  not have live checksum then reading the record's header (as done by
  the master loop of run_undo_phase()) is enough; otherwise we
  do a translog_read_record() to have the checksum delta ready
  for _ma_apply_undo_row_insert().
  * When at the end of the REDO phase we notice that there is an unfinished
  group of REDOs, don't assert in debug binaries, as I verified that it
  can happen in real life (with kill -9)
  * removing ' in #error as it confuses gcc3
storage/maria/ma_rename.c:
  new prototype of translog_write_record()
storage/maria/ma_test_recovery.expected:
  Change in output of ma_test_recovery: now all live checksums of
  original tables equal those of tables recreated by the REDO phase
  and those of tables fixed by the UNDO phase. I.e. recovery of
  the live checksum looks like working (which was after all the only
  goal of this changeset).
  I checked by hand that it's not just all live checksums which are
  now 0 and that's why they match. They are the old values like
  3757530372. maria.test has hard-coded checksum values in its result
  file so checks this too.
storage/maria/ma_update.c:
  * It's useless to put up HA_STATE_CHANGED in 'key_changed',
  as we put up HA_STATE_CHANGED in info->update anyway.
  * We need to compute the old and new rows' checksum before calling
  (*update_record)(), as checksum delta must be known when logging
  UNDO_ROW_UPDATE which is done by _ma_update_block_record(). Note that
  some functions change the 'newrec' record (at least _ma_check_unique()
  does) so we cannot move the checksum computation too early in the
  function.
storage/maria/ma_write.c:
  If inserting into a transactional table, live's checksum was
  already updated when writing UNDO_ROW_INSERT. The multiplication
  is a trick to save an if().
storage/maria/unittest/ma_test_loghandler-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_purge-t.c:
  new prototype of translog_write_record()
storage/myisam/sort.c:
  fix for compiler warnings in pushbuild (write_merge_key* functions
  didn't have their declaration match MARIA_HA::write_key).
parent da6db764
...@@ -2185,6 +2185,9 @@ int ha_maria::create(const char *name, register TABLE *table_arg, ...@@ -2185,6 +2185,9 @@ int ha_maria::create(const char *name, register TABLE *table_arg,
error; error;
? ?
Why fool the user? Why fool the user?
Shouldn't this test be pushed down to maria_create()? Because currently,
ma_test1 -T crashes: it creates a table with DYNAMIC_RECORD but has
born_transactional==1, which confuses some recovery-related code.
*/ */
#endif #endif
create_info.transactional= (row_type == BLOCK_RECORD && create_info.transactional= (row_type == BLOCK_RECORD &&
......
This diff is collapsed.
...@@ -193,3 +193,28 @@ my_bool _ma_apply_undo_row_delete(MARIA_HA *info, LSN undo_lsn, ...@@ -193,3 +193,28 @@ my_bool _ma_apply_undo_row_delete(MARIA_HA *info, LSN undo_lsn,
const uchar *header, size_t length); const uchar *header, size_t length);
my_bool _ma_apply_undo_row_update(MARIA_HA *info, LSN undo_lsn, my_bool _ma_apply_undo_row_update(MARIA_HA *info, LSN undo_lsn,
const uchar *header, size_t length); const uchar *header, size_t length);
my_bool write_hook_for_redo(enum translog_record_type type,
TRN *trn, MARIA_HA *tbl_info, LSN *lsn,
void *hook_arg);
my_bool write_hook_for_undo(enum translog_record_type type,
TRN *trn, MARIA_HA *tbl_info, LSN *lsn,
void *hook_arg);
my_bool write_hook_for_redo_delete_all(enum translog_record_type type,
TRN *trn, MARIA_HA *tbl_info,
LSN *lsn, void *hook_arg);
my_bool write_hook_for_undo_row_insert(enum translog_record_type type,
TRN *trn, MARIA_HA *tbl_info,
LSN *lsn, void *hook_arg);
my_bool write_hook_for_undo_row_delete(enum translog_record_type type,
TRN *trn, MARIA_HA *tbl_info,
LSN *lsn, void *hook_arg);
my_bool write_hook_for_undo_row_update(enum translog_record_type type,
TRN *trn, MARIA_HA *tbl_info,
LSN *lsn, void *hook_arg);
my_bool write_hook_for_clr_end(enum translog_record_type type,
TRN *trn, MARIA_HA *tbl_info, LSN *lsn,
void *hook_arg);
my_bool write_hook_for_file_id(enum translog_record_type type,
TRN *trn, MARIA_HA *tbl_info, LSN *lsn,
void *hook_arg);
...@@ -5602,11 +5602,10 @@ static int write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info) ...@@ -5602,11 +5602,10 @@ static int write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info)
record). record).
*/ */
LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 1];
uchar log_data[LSN_STORE_SIZE]; uchar log_data[FILEID_STORE_SIZE + 4];
LSN lsn; LSN lsn;
compile_time_assert(LSN_STORE_SIZE >= (FILEID_STORE_SIZE + 4));
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data;
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= FILEID_STORE_SIZE + 4; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
/* /*
testflag gives an idea of what REPAIR did (in particular T_QUICK testflag gives an idea of what REPAIR did (in particular T_QUICK
or not: did it touch the data file or not?). or not: did it touch the data file or not?).
...@@ -5614,10 +5613,9 @@ static int write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info) ...@@ -5614,10 +5613,9 @@ static int write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info)
int4store(log_data + FILEID_STORE_SIZE, param->testflag); int4store(log_data + FILEID_STORE_SIZE, param->testflag);
if (unlikely(translog_write_record(&lsn, LOGREC_REDO_REPAIR_TABLE, if (unlikely(translog_write_record(&lsn, LOGREC_REDO_REPAIR_TABLE,
&dummy_transaction_object, info, &dummy_transaction_object, info,
log_array[TRANSLOG_INTERNAL_PARTS + sizeof(log_data),
0].length,
sizeof(log_array)/sizeof(log_array[0]), sizeof(log_array)/sizeof(log_array[0]),
log_array, log_data) || log_array, log_data, NULL) ||
translog_flush(lsn))) translog_flush(lsn)))
return 1; return 1;
/* /*
......
...@@ -266,7 +266,7 @@ static int really_execute_checkpoint(void) ...@@ -266,7 +266,7 @@ static int really_execute_checkpoint(void)
&dummy_transaction_object, NULL, &dummy_transaction_object, NULL,
total_rec_length, total_rec_length,
sizeof(log_array)/sizeof(log_array[0]), sizeof(log_array)/sizeof(log_array[0]),
log_array, NULL) || log_array, NULL, NULL) ||
translog_flush(lsn))) translog_flush(lsn)))
goto err; goto err;
...@@ -652,7 +652,7 @@ pthread_handler_t ma_checkpoint_background(void *arg __attribute__((unused))) ...@@ -652,7 +652,7 @@ pthread_handler_t ma_checkpoint_background(void *arg __attribute__((unused)))
break; break;
#if 0 /* good for testing, to do a lot of checkpoints, finds a lot of bugs */ #if 0 /* good for testing, to do a lot of checkpoints, finds a lot of bugs */
pthread_mutex_unlock(&LOCK_checkpoint); pthread_mutex_unlock(&LOCK_checkpoint);
my_sleep(100000); // a tenth of a second my_sleep(100000); /* a tenth of a second */
pthread_mutex_lock(&LOCK_checkpoint); pthread_mutex_lock(&LOCK_checkpoint);
#else #else
/* To have a killable sleep, we use timedwait like our SQL GET_LOCK() */ /* To have a killable sleep, we use timedwait like our SQL GET_LOCK() */
...@@ -893,7 +893,7 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon) ...@@ -893,7 +893,7 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
filter_param.pages_covered_by_bitmap= share->bitmap.pages_covered; filter_param.pages_covered_by_bitmap= share->bitmap.pages_covered;
/* OS file descriptors are ints which we stored in 4 bytes */ /* OS file descriptors are ints which we stored in 4 bytes */
compile_time_assert(sizeof(int) == 4); compile_time_assert(sizeof(int) <= 4);
pthread_mutex_lock(&share->intern_lock); pthread_mutex_lock(&share->intern_lock);
/* /*
Tables in a normal state have their two file descriptors open. Tables in a normal state have their two file descriptors open.
......
...@@ -64,7 +64,7 @@ int ma_commit(TRN *trn) ...@@ -64,7 +64,7 @@ int ma_commit(TRN *trn)
res= (translog_write_record(&commit_lsn, LOGREC_COMMIT, res= (translog_write_record(&commit_lsn, LOGREC_COMMIT,
trn, NULL, 0, trn, NULL, 0,
sizeof(log_array)/sizeof(log_array[0]), sizeof(log_array)/sizeof(log_array[0]),
log_array, NULL) || log_array, NULL, NULL) ||
translog_flush(commit_lsn) || translog_flush(commit_lsn) ||
trnman_commit_trn(trn)); trnman_commit_trn(trn));
/* /*
......
...@@ -997,7 +997,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -997,7 +997,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
&dummy_transaction_object, NULL, &dummy_transaction_object, NULL,
total_rec_length, total_rec_length,
sizeof(log_array)/sizeof(log_array[0]), sizeof(log_array)/sizeof(log_array[0]),
log_array, NULL) || log_array, NULL, NULL) ||
translog_flush(lsn))) translog_flush(lsn)))
goto err; goto err;
/* /*
......
...@@ -44,10 +44,10 @@ int maria_delete(MARIA_HA *info,const uchar *record) ...@@ -44,10 +44,10 @@ int maria_delete(MARIA_HA *info,const uchar *record)
/* Test if record is in datafile */ /* Test if record is in datafile */
DBUG_EXECUTE_IF("maria_pretend_crashed_table_on_usage", DBUG_EXECUTE_IF("maria_pretend_crashed_table_on_usage",
maria_print_error(info->s, HA_ERR_CRASHED); maria_print_error(share, HA_ERR_CRASHED);
DBUG_RETURN(my_errno= HA_ERR_CRASHED);); DBUG_RETURN(my_errno= HA_ERR_CRASHED););
DBUG_EXECUTE_IF("my_error_test_undefined_error", DBUG_EXECUTE_IF("my_error_test_undefined_error",
maria_print_error(info->s, INT_MAX); maria_print_error(share, INT_MAX);
DBUG_RETURN(my_errno= INT_MAX);); DBUG_RETURN(my_errno= INT_MAX););
if (!(info->update & HA_STATE_AKTIV)) if (!(info->update & HA_STATE_AKTIV))
{ {
...@@ -70,17 +70,17 @@ int maria_delete(MARIA_HA *info,const uchar *record) ...@@ -70,17 +70,17 @@ int maria_delete(MARIA_HA *info,const uchar *record)
old_key= info->lastkey2; old_key= info->lastkey2;
for (i=0 ; i < share->base.keys ; i++ ) for (i=0 ; i < share->base.keys ; i++ )
{ {
if (maria_is_key_active(info->s->state.key_map, i)) if (maria_is_key_active(share->state.key_map, i))
{ {
info->s->keyinfo[i].version++; share->keyinfo[i].version++;
if (info->s->keyinfo[i].flag & HA_FULLTEXT ) if (share->keyinfo[i].flag & HA_FULLTEXT )
{ {
if (_ma_ft_del(info,i,(char*) old_key,record,info->cur_row.lastpos)) if (_ma_ft_del(info,i,(char*) old_key,record,info->cur_row.lastpos))
goto err; goto err;
} }
else else
{ {
if (info->s->keyinfo[i].ck_delete(info,i,old_key, if (share->keyinfo[i].ck_delete(info,i,old_key,
_ma_make_key(info,i,old_key,record,info->cur_row.lastpos))) _ma_make_key(info,i,old_key,record,info->cur_row.lastpos)))
goto err; goto err;
} }
...@@ -89,19 +89,20 @@ int maria_delete(MARIA_HA *info,const uchar *record) ...@@ -89,19 +89,20 @@ int maria_delete(MARIA_HA *info,const uchar *record)
} }
} }
if ((*share->delete_record)(info, record)) if (share->calc_checksum)
goto err; /* Remove record from database */ {
/* /*
We can't use the row based checksum as this doesn't have enough We can't use the row based checksum as this doesn't have enough
precision. precision.
*/ */
if (info->s->calc_checksum) info->cur_row.checksum= (*share->calc_checksum)(info, record);
{
info->cur_row.checksum= (*info->s->calc_checksum)(info,record);
info->state->checksum-= info->cur_row.checksum;
} }
if ((*share->delete_record)(info, record))
goto err; /* Remove record from database */
info->state->checksum+= - !share->now_transactional *
info->cur_row.checksum;
info->update= HA_STATE_CHANGED+HA_STATE_DELETED+HA_STATE_ROW_CHANGED; info->update= HA_STATE_CHANGED+HA_STATE_DELETED+HA_STATE_ROW_CHANGED;
info->state->records-= !share->now_transactional; info->state->records-= !share->now_transactional;
share->state.changed|= STATE_NOT_OPTIMIZED_ROWS; share->state.changed|= STATE_NOT_OPTIMIZED_ROWS;
...@@ -111,8 +112,8 @@ int maria_delete(MARIA_HA *info,const uchar *record) ...@@ -111,8 +112,8 @@ int maria_delete(MARIA_HA *info,const uchar *record)
allow_break(); /* Allow SIGHUP & SIGINT */ allow_break(); /* Allow SIGHUP & SIGINT */
if (info->invalidator != 0) if (info->invalidator != 0)
{ {
DBUG_PRINT("info", ("invalidator... '%s' (delete)", info->s->open_file_name)); DBUG_PRINT("info", ("invalidator... '%s' (delete)", share->open_file_name));
(*info->invalidator)(info->s->open_file_name); (*info->invalidator)(share->open_file_name);
info->invalidator=0; info->invalidator=0;
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -122,7 +123,7 @@ int maria_delete(MARIA_HA *info,const uchar *record) ...@@ -122,7 +123,7 @@ int maria_delete(MARIA_HA *info,const uchar *record)
mi_sizestore(lastpos, info->cur_row.lastpos); mi_sizestore(lastpos, info->cur_row.lastpos);
if (save_errno != HA_ERR_RECORD_CHANGED) if (save_errno != HA_ERR_RECORD_CHANGED)
{ {
maria_print_error(info->s, HA_ERR_CRASHED); maria_print_error(share, HA_ERR_CRASHED);
maria_mark_crashed(info); /* mark table crashed */ maria_mark_crashed(info); /* mark table crashed */
} }
VOID(_ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE)); VOID(_ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
...@@ -131,7 +132,7 @@ int maria_delete(MARIA_HA *info,const uchar *record) ...@@ -131,7 +132,7 @@ int maria_delete(MARIA_HA *info,const uchar *record)
my_errno=save_errno; my_errno=save_errno;
if (save_errno == HA_ERR_KEY_NOT_FOUND) if (save_errno == HA_ERR_KEY_NOT_FOUND)
{ {
maria_print_error(info->s, HA_ERR_CRASHED); maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED; my_errno=HA_ERR_CRASHED;
} }
......
...@@ -64,14 +64,15 @@ int maria_delete_all_rows(MARIA_HA *info) ...@@ -64,14 +64,15 @@ int maria_delete_all_rows(MARIA_HA *info)
if (unlikely(translog_write_record(&lsn, LOGREC_REDO_DELETE_ALL, if (unlikely(translog_write_record(&lsn, LOGREC_REDO_DELETE_ALL,
info->trn, info, 0, info->trn, info, 0,
sizeof(log_array)/sizeof(log_array[0]), sizeof(log_array)/sizeof(log_array[0]),
log_array, log_data) || log_array, log_data, NULL) ||
translog_flush(lsn))) translog_flush(lsn)))
goto err; goto err;
} }
/* /*
For recovery it matters that this is called after writing the log record, For recovery it matters that this is called after writing the log record,
so that resetting state.records actually happens under log's mutex. so that resetting state.records and state.checksum actually happens under
log's mutex.
*/ */
_ma_reset_status(info); _ma_reset_status(info);
...@@ -147,10 +148,6 @@ void _ma_reset_status(MARIA_HA *info) ...@@ -147,10 +148,6 @@ void _ma_reset_status(MARIA_HA *info)
info->state->key_file_length= share->base.keystart; info->state->key_file_length= share->base.keystart;
info->state->data_file_length= 0; info->state->data_file_length= 0;
info->state->empty= info->state->key_empty= 0; info->state->empty= info->state->key_empty= 0;
/**
@todo RECOVERY BUG
the line below must happen under log's mutex when writing the REDO
*/
info->state->checksum= 0; info->state->checksum= 0;
/* Drop the delete key chain. */ /* Drop the delete key chain. */
......
...@@ -92,7 +92,7 @@ int maria_delete_table(const char *name) ...@@ -92,7 +92,7 @@ int maria_delete_table(const char *name)
log_array[TRANSLOG_INTERNAL_PARTS + log_array[TRANSLOG_INTERNAL_PARTS +
0].length, 0].length,
sizeof(log_array)/sizeof(log_array[0]), sizeof(log_array)/sizeof(log_array[0]),
log_array, NULL) || log_array, NULL, NULL) ||
translog_flush(lsn))) translog_flush(lsn)))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
......
This diff is collapsed.
...@@ -48,6 +48,7 @@ typedef uint16 SHORT_TRANSACTION_ID; ...@@ -48,6 +48,7 @@ typedef uint16 SHORT_TRANSACTION_ID;
struct st_maria_info; struct st_maria_info;
/* Changing one of the "SIZE" below will break backward-compatibility! */
/* Length of CRC at end of pages */ /* Length of CRC at end of pages */
#define CRC_LENGTH 4 #define CRC_LENGTH 4
/* Size of file id in logs */ /* Size of file id in logs */
...@@ -57,16 +58,23 @@ struct st_maria_info; ...@@ -57,16 +58,23 @@ struct st_maria_info;
/* Size of page ranges in log */ /* Size of page ranges in log */
#define PAGERANGE_STORE_SIZE ROW_EXTENT_COUNT_SIZE #define PAGERANGE_STORE_SIZE ROW_EXTENT_COUNT_SIZE
#define DIRPOS_STORE_SIZE 1 #define DIRPOS_STORE_SIZE 1
#define CLR_TYPE_STORE_SIZE 1
/* If table has live checksum we store its changes in UNDOs */
#define HA_CHECKSUM_STORE_SIZE 4
/* Store methods to match the above sizes */ /* Store methods to match the above sizes */
#define fileid_store(T,A) int2store(T,A) #define fileid_store(T,A) int2store(T,A)
#define page_store(T,A) int5store(T,A) #define page_store(T,A) int5store(T,A)
#define dirpos_store(T,A) ((*(uchar*) (T)) = A) #define dirpos_store(T,A) ((*(uchar*) (T)) = A)
#define pagerange_store(T,A) int2store(T,A) #define pagerange_store(T,A) int2store(T,A)
#define clr_type_store(T,A) ((*(uchar*) (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) ((P)[0])
#define pagerange_korr(P) uint2korr(P) #define pagerange_korr(P) uint2korr(P)
#define clr_type_korr(P) ((P)[0])
#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
...@@ -230,7 +238,8 @@ translog_write_record(LSN *lsn, enum translog_record_type type, ...@@ -230,7 +238,8 @@ translog_write_record(LSN *lsn, enum translog_record_type type,
struct st_transaction *trn, struct st_transaction *trn,
struct st_maria_info *tbl_info, struct st_maria_info *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,
void *hook_arg);
extern void translog_destroy(); extern void translog_destroy();
...@@ -299,12 +308,11 @@ struct st_translog_parts ...@@ -299,12 +308,11 @@ struct st_translog_parts
typedef my_bool(*prewrite_rec_hook) (enum translog_record_type type, typedef my_bool(*prewrite_rec_hook) (enum translog_record_type type,
TRN *trn, struct st_maria_info *tbl_info, TRN *trn, struct st_maria_info *tbl_info,
struct st_translog_parts *parts); void *hook_arg);
typedef my_bool(*inwrite_rec_hook) (enum translog_record_type type, typedef my_bool(*inwrite_rec_hook) (enum translog_record_type type,
TRN *trn, struct st_maria_info *tbl_info, TRN *trn, struct st_maria_info *tbl_info,
LSN *lsn, LSN *lsn, void *hook_arg);
struct st_translog_parts *parts);
typedef uint16(*read_rec_hook) (enum translog_record_type type, typedef uint16(*read_rec_hook) (enum translog_record_type type,
uint16 read_length, uchar *read_buff, uint16 read_length, uchar *read_buff,
......
...@@ -177,7 +177,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, int mode, ...@@ -177,7 +177,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, int mode,
share->delay_key_write=1; share->delay_key_write=1;
info.state= &share->state.state; /* Change global values by default */ info.state= &share->state.state; /* Change global values by default */
if (!share->base.born_transactional) /* but for transactional ones ... */ if (!share->base.born_transactional) /* For transactional ones ... */
info.trn= &dummy_transaction_object; /* ... force crash if no trn given */ info.trn= &dummy_transaction_object; /* ... force crash if no trn given */
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
......
...@@ -3941,7 +3941,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, ...@@ -3941,7 +3941,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
} }
} }
compile_time_assert(sizeof(pagecache->blocks == 4)); compile_time_assert(sizeof(pagecache->blocks) <= 4);
str->length= 4 + /* number of dirty pages */ str->length= 4 + /* number of dirty pages */
(4 + /* file */ (4 + /* file */
4 + /* pageno */ 4 + /* pageno */
...@@ -3963,8 +3963,8 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, ...@@ -3963,8 +3963,8 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
{ {
if (block->type != PAGECACHE_LSN_PAGE) if (block->type != PAGECACHE_LSN_PAGE)
continue; /* no need to store it in the checkpoint record */ continue; /* no need to store it in the checkpoint record */
compile_time_assert((4 == sizeof(block->hash_link->file.file))); compile_time_assert(sizeof(block->hash_link->file.file) <= 4);
compile_time_assert((4 == sizeof(block->hash_link->pageno))); compile_time_assert(sizeof(block->hash_link->pageno) <= 4);
int4store(ptr, block->hash_link->file.file); int4store(ptr, block->hash_link->file.file);
ptr+= 4; ptr+= 4;
int4store(ptr, block->hash_link->pageno); int4store(ptr, block->hash_link->pageno);
......
This diff is collapsed.
...@@ -85,7 +85,7 @@ int maria_rename(const char *old_name, const char *new_name) ...@@ -85,7 +85,7 @@ int maria_rename(const char *old_name, const char *new_name)
&dummy_transaction_object, NULL, &dummy_transaction_object, NULL,
old_name_len + new_name_len, old_name_len + new_name_len,
sizeof(log_array)/sizeof(log_array[0]), sizeof(log_array)/sizeof(log_array[0]),
log_array, NULL) || log_array, NULL, NULL) ||
translog_flush(lsn))) translog_flush(lsn)))
{ {
maria_close(info); maria_close(info);
......
This diff is collapsed.
...@@ -27,11 +27,9 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec) ...@@ -27,11 +27,9 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
bool auto_key_changed=0; bool auto_key_changed=0;
ulonglong changed; ulonglong changed;
MARIA_SHARE *share=info->s; MARIA_SHARE *share=info->s;
ha_checksum old_checksum;
DBUG_ENTER("maria_update"); DBUG_ENTER("maria_update");
LINT_INIT(new_key); LINT_INIT(new_key);
LINT_INIT(changed); LINT_INIT(changed);
LINT_INIT(old_checksum);
DBUG_EXECUTE_IF("maria_pretend_crashed_table_on_usage", DBUG_EXECUTE_IF("maria_pretend_crashed_table_on_usage",
maria_print_error(info->s, HA_ERR_CRASHED); maria_print_error(info->s, HA_ERR_CRASHED);
...@@ -59,16 +57,6 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec) ...@@ -59,16 +57,6 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
goto err_end; /* Record has changed */ goto err_end; /* Record has changed */
} }
if (share->calc_checksum)
{
/*
We can't use the row based checksum as this doesn't have enough
precision.
*/
if (info->s->calc_checksum)
old_checksum= (*info->s->calc_checksum)(info, oldrec);
}
/* Calculate and check all unique constraints */ /* Calculate and check all unique constraints */
key_changed=0; key_changed=0;
for (i=0 ; i < share->state.header.uniques ; i++) for (i=0 ; i < share->state.header.uniques ; i++)
...@@ -137,19 +125,23 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec) ...@@ -137,19 +125,23 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
} }
} }
} }
/*
If we are running with external locking, we must update the index file
that something has changed.
*/
if (changed || !my_disable_locking)
key_changed|= HA_STATE_CHANGED;
if (share->calc_checksum) if (share->calc_checksum)
{ {
info->cur_row.checksum= (*share->calc_checksum)(info,newrec); /*
info->state->checksum+= (info->cur_row.checksum - old_checksum); We can't use the row based checksum as this doesn't have enough
/* Store new checksum in index file header */ precision (one byte, while the table's is more bytes).
key_changed|= HA_STATE_CHANGED; At least _ma_check_unique() modifies the 'newrec' record, so checksum
has to be computed _after_ it. Nobody apparently modifies 'oldrec'.
We need to pass the old row's checksum down to (*update_record)(), we do
this via info->new_row.checksum (not intuitive but existing code
mandated that cur_row is the new row).
If (*update_record)() fails, table will be marked corrupted so no need
to revert the live checksum change.
*/
info->state->checksum+= !share->now_transactional *
((info->cur_row.checksum= (*share->calc_checksum)(info, newrec)) -
(info->new_row.checksum= (*share->calc_checksum)(info, oldrec)));
} }
{ {
/* /*
...@@ -165,14 +157,9 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec) ...@@ -165,14 +157,9 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
org_delete_link= share->state.dellink; org_delete_link= share->state.dellink;
if ((*share->update_record)(info, pos, oldrec, newrec)) if ((*share->update_record)(info, pos, oldrec, newrec))
goto err; goto err;
if (!key_changed &&
(memcmp((char*) &state, (char*) info->state, sizeof(state)) ||
org_split != share->state.split ||
org_delete_link != share->state.dellink))
key_changed|= HA_STATE_CHANGED; /* Must update index file */
} }
if (auto_key_changed) if (auto_key_changed)
set_if_bigger(info->s->state.auto_increment, set_if_bigger(share->state.auto_increment,
ma_retrieve_auto_increment(info, newrec)); ma_retrieve_auto_increment(info, newrec));
/* /*
...@@ -195,8 +182,8 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec) ...@@ -195,8 +182,8 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
allow_break(); /* Allow SIGHUP & SIGINT */ allow_break(); /* Allow SIGHUP & SIGINT */
if (info->invalidator != 0) if (info->invalidator != 0)
{ {
DBUG_PRINT("info", ("invalidator... '%s' (update)", info->s->open_file_name)); DBUG_PRINT("info", ("invalidator... '%s' (update)", share->open_file_name));
(*info->invalidator)(info->s->open_file_name); (*info->invalidator)(share->open_file_name);
info->invalidator=0; info->invalidator=0;
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -232,7 +219,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec) ...@@ -232,7 +219,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
} }
else else
{ {
maria_print_error(info->s, HA_ERR_CRASHED); maria_print_error(share, HA_ERR_CRASHED);
maria_mark_crashed(info); maria_mark_crashed(info);
} }
info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_ROW_CHANGED | info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_ROW_CHANGED |
...@@ -243,7 +230,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec) ...@@ -243,7 +230,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
allow_break(); /* Allow SIGHUP & SIGINT */ allow_break(); /* Allow SIGHUP & SIGINT */
if (save_errno == HA_ERR_KEY_NOT_FOUND) if (save_errno == HA_ERR_KEY_NOT_FOUND)
{ {
maria_print_error(info->s, HA_ERR_CRASHED); maria_print_error(share, HA_ERR_CRASHED);
save_errno=HA_ERR_CRASHED; save_errno=HA_ERR_CRASHED;
} }
DBUG_RETURN(my_errno=save_errno); DBUG_RETURN(my_errno=save_errno);
......
...@@ -162,10 +162,6 @@ int maria_write(MARIA_HA *info, uchar *record) ...@@ -162,10 +162,6 @@ int maria_write(MARIA_HA *info, uchar *record)
rw_unlock(&share->key_root_lock[i]); rw_unlock(&share->key_root_lock[i]);
} }
} }
/**
@todo RECOVERY BUG
this += must happen under log's mutex when writing the UNDO
*/
if (share->calc_write_checksum) if (share->calc_write_checksum)
info->cur_row.checksum= (*share->calc_write_checksum)(info,record); info->cur_row.checksum= (*share->calc_write_checksum)(info,record);
if (filepos != HA_OFFSET_ERROR) if (filepos != HA_OFFSET_ERROR)
...@@ -176,7 +172,8 @@ int maria_write(MARIA_HA *info, uchar *record) ...@@ -176,7 +172,8 @@ int maria_write(MARIA_HA *info, uchar *record)
@todo when we enable multiple writers, we will have to protect @todo when we enable multiple writers, we will have to protect
'records' and 'checksum' somehow. 'records' and 'checksum' somehow.
*/ */
info->state->checksum+= info->cur_row.checksum; info->state->checksum+= !share->now_transactional *
info->cur_row.checksum;
} }
if (share->base.auto_key) if (share->base.auto_key)
set_if_bigger(info->s->state.auto_increment, set_if_bigger(info->s->state.auto_increment,
......
...@@ -198,8 +198,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -198,8 +198,8 @@ int main(int argc __attribute__((unused)), char *argv[])
trn->first_undo_lsn= TRANSACTION_LOGGED_LONG_ID; trn->first_undo_lsn= TRANSACTION_LOGGED_LONG_ID;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
trn, NULL, trn, NULL, 6, TRANSLOG_INTERNAL_PARTS + 1,
6, TRANSLOG_INTERNAL_PARTS + 1, parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
translog_destroy(); translog_destroy();
...@@ -220,8 +220,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -220,8 +220,8 @@ int main(int argc __attribute__((unused)), char *argv[])
/* check auto-count feature */ /* check auto-count feature */
parts[TRANSLOG_INTERNAL_PARTS + 1].str= NULL; parts[TRANSLOG_INTERNAL_PARTS + 1].str= NULL;
parts[TRANSLOG_INTERNAL_PARTS + 1].length= 0; parts[TRANSLOG_INTERNAL_PARTS + 1].length= 0;
if (translog_write_record(&lsn, LOGREC_FIXED_RECORD_1LSN_EXAMPLE, if (translog_write_record(&lsn, LOGREC_FIXED_RECORD_1LSN_EXAMPLE, trn,
trn, NULL, LSN_STORE_SIZE, 0, parts, NULL)) NULL, LSN_STORE_SIZE, 0, parts, NULL, NULL))
{ {
fprintf(stderr, "1 Can't write reference defore record #%lu\n", fprintf(stderr, "1 Can't write reference defore record #%lu\n",
(ulong) i); (ulong) i);
...@@ -241,7 +241,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -241,7 +241,7 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE, LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE,
trn, NULL, 0, TRANSLOG_INTERNAL_PARTS + 2, trn, NULL, 0, TRANSLOG_INTERNAL_PARTS + 2,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "1 Can't write var reference defore record #%lu\n", fprintf(stderr, "1 Can't write var reference defore record #%lu\n",
(ulong) i); (ulong) i);
...@@ -259,8 +259,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -259,8 +259,8 @@ int main(int argc __attribute__((unused)), char *argv[])
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 23; parts[TRANSLOG_INTERNAL_PARTS + 0].length= 23;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_FIXED_RECORD_2LSN_EXAMPLE, LOGREC_FIXED_RECORD_2LSN_EXAMPLE,
trn, NULL, trn, NULL, 23, TRANSLOG_INTERNAL_PARTS + 1,
23, TRANSLOG_INTERNAL_PARTS + 1, parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "0 Can't write reference defore record #%lu\n", fprintf(stderr, "0 Can't write reference defore record #%lu\n",
(ulong) i); (ulong) i);
...@@ -280,7 +280,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -280,7 +280,8 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE, LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE,
trn, NULL, 14 + rec_len, trn, NULL, 14 + rec_len,
TRANSLOG_INTERNAL_PARTS + 2, parts, NULL)) TRANSLOG_INTERNAL_PARTS + 2, parts, NULL,
NULL))
{ {
fprintf(stderr, "0 Can't write var reference defore record #%lu\n", fprintf(stderr, "0 Can't write var reference defore record #%lu\n",
(ulong) i); (ulong) i);
...@@ -297,7 +298,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -297,7 +298,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
trn, NULL, 6, trn, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) i); fprintf(stderr, "Can't write record #%lu\n", (ulong) i);
translog_destroy(); translog_destroy();
...@@ -316,7 +317,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -316,7 +317,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE, LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE,
trn, NULL, rec_len, trn, NULL, rec_len,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i); fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i);
translog_destroy(); translog_destroy();
......
...@@ -106,7 +106,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -106,7 +106,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
&dummy_transaction_object, NULL, 6, &dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
translog_destroy(); translog_destroy();
......
...@@ -96,7 +96,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -96,7 +96,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
&dummy_transaction_object, NULL, 6, &dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
translog_destroy(); translog_destroy();
......
...@@ -194,8 +194,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -194,8 +194,8 @@ int main(int argc __attribute__((unused)), char *argv[])
trn->short_id= 0; trn->short_id= 0;
trn->first_undo_lsn= TRANSACTION_LOGGED_LONG_ID; trn->first_undo_lsn= TRANSACTION_LOGGED_LONG_ID;
if (translog_write_record(&lsn, LOGREC_FIXED_RECORD_0LSN_EXAMPLE, if (translog_write_record(&lsn, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
trn, NULL, trn, NULL, 6, TRANSLOG_INTERNAL_PARTS + 1, parts,
6, TRANSLOG_INTERNAL_PARTS + 1, parts, NULL)) NULL, NULL))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
translog_destroy(); translog_destroy();
...@@ -214,10 +214,9 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -214,10 +214,9 @@ int main(int argc __attribute__((unused)), char *argv[])
parts[TRANSLOG_INTERNAL_PARTS + 0].length= LSN_STORE_SIZE; parts[TRANSLOG_INTERNAL_PARTS + 0].length= LSN_STORE_SIZE;
trn->short_id= i % 0xFFFF; trn->short_id= i % 0xFFFF;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_FIXED_RECORD_1LSN_EXAMPLE, LOGREC_FIXED_RECORD_1LSN_EXAMPLE, trn, NULL,
trn, NULL, LSN_STORE_SIZE, TRANSLOG_INTERNAL_PARTS + 1,
LSN_STORE_SIZE, parts, NULL, NULL))
TRANSLOG_INTERNAL_PARTS + 1, parts, NULL))
{ {
fprintf(stderr, "1 Can't write reference before record #%lu\n", fprintf(stderr, "1 Can't write reference before record #%lu\n",
(ulong) i); (ulong) i);
...@@ -237,7 +236,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -237,7 +236,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE, LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE,
trn, NULL, LSN_STORE_SIZE + rec_len, trn, NULL, LSN_STORE_SIZE + rec_len,
TRANSLOG_INTERNAL_PARTS + 2, TRANSLOG_INTERNAL_PARTS + 2,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "1 Can't write var reference before record #%lu\n", fprintf(stderr, "1 Can't write var reference before record #%lu\n",
(ulong) i); (ulong) i);
...@@ -256,9 +255,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -256,9 +255,8 @@ int main(int argc __attribute__((unused)), char *argv[])
trn->short_id= i % 0xFFFF; trn->short_id= i % 0xFFFF;
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_FIXED_RECORD_2LSN_EXAMPLE, LOGREC_FIXED_RECORD_2LSN_EXAMPLE,
trn, NULL, 23, trn, NULL, 23, TRANSLOG_INTERNAL_PARTS + 1,
TRANSLOG_INTERNAL_PARTS + 1, parts, NULL, NULL))
parts, NULL))
{ {
fprintf(stderr, "0 Can't write reference before record #%lu\n", fprintf(stderr, "0 Can't write reference before record #%lu\n",
(ulong) i); (ulong) i);
...@@ -279,7 +277,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -279,7 +277,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE, LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE,
trn, NULL, LSN_STORE_SIZE * 2 + rec_len, trn, NULL, LSN_STORE_SIZE * 2 + rec_len,
TRANSLOG_INTERNAL_PARTS + 2, TRANSLOG_INTERNAL_PARTS + 2,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "0 Can't write var reference before record #%lu\n", fprintf(stderr, "0 Can't write var reference before record #%lu\n",
(ulong) i); (ulong) i);
...@@ -296,7 +294,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -296,7 +294,7 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
trn, NULL, 6, trn, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, parts, NULL)) TRANSLOG_INTERNAL_PARTS + 1, parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) i); fprintf(stderr, "Can't write record #%lu\n", (ulong) i);
translog_destroy(); translog_destroy();
...@@ -314,7 +312,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -314,7 +312,7 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE, LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE,
trn, NULL, rec_len, trn, NULL, rec_len,
TRANSLOG_INTERNAL_PARTS + 1, parts, NULL)) TRANSLOG_INTERNAL_PARTS + 1, parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i); fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i);
translog_destroy(); translog_destroy();
......
...@@ -138,7 +138,7 @@ void writer(int num) ...@@ -138,7 +138,7 @@ void writer(int num)
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
&trn, NULL, 6, TRANSLOG_INTERNAL_PARTS + 1, &trn, NULL, 6, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write LOGREC_FIXED_RECORD_0LSN_EXAMPLE record #%lu " fprintf(stderr, "Can't write LOGREC_FIXED_RECORD_0LSN_EXAMPLE record #%lu "
"thread %i\n", (ulong) i, num); "thread %i\n", (ulong) i, num);
...@@ -155,7 +155,7 @@ void writer(int num) ...@@ -155,7 +155,7 @@ void writer(int num)
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE, LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE,
&trn, NULL, &trn, NULL,
len, TRANSLOG_INTERNAL_PARTS + 1, len, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i); fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i);
translog_destroy(); translog_destroy();
...@@ -307,7 +307,7 @@ int main(int argc __attribute__((unused)), ...@@ -307,7 +307,7 @@ int main(int argc __attribute__((unused)),
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
&dummy_transaction_object, NULL, 6, &dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write the first record\n"); fprintf(stderr, "Can't write the first record\n");
translog_destroy(); translog_destroy();
......
...@@ -85,7 +85,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -85,7 +85,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
&dummy_transaction_object, NULL, 6, &dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
translog_destroy(); translog_destroy();
......
...@@ -97,7 +97,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -97,7 +97,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
&dummy_transaction_object, NULL, 6, &dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
translog_destroy(); translog_destroy();
......
...@@ -80,7 +80,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -80,7 +80,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
&dummy_transaction_object, NULL, 6, &dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
translog_destroy(); translog_destroy();
...@@ -102,7 +102,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -102,7 +102,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
&dummy_transaction_object, NULL, 6, &dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0); fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
translog_destroy(); translog_destroy();
...@@ -125,7 +125,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -125,7 +125,7 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_write_record(&lsn, if (translog_write_record(&lsn,
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE, LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE,
&dummy_transaction_object, NULL, LONG_BUFFER_SIZE, &dummy_transaction_object, NULL, LONG_BUFFER_SIZE,
TRANSLOG_INTERNAL_PARTS + 1, parts, NULL)) TRANSLOG_INTERNAL_PARTS + 1, parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write variable record\n"); fprintf(stderr, "Can't write variable record\n");
translog_destroy(); translog_destroy();
...@@ -150,7 +150,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -150,7 +150,7 @@ int main(int argc __attribute__((unused)), char *argv[])
LOGREC_FIXED_RECORD_0LSN_EXAMPLE, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
&dummy_transaction_object, NULL, 6, &dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1, TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL)) parts, NULL, NULL))
{ {
fprintf(stderr, "Can't write last record\n"); fprintf(stderr, "Can't write last record\n");
translog_destroy(); translog_destroy();
......
...@@ -78,10 +78,10 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info,uchar **sort_keys, ...@@ -78,10 +78,10 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info,uchar **sort_keys,
static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek, static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek,
uint sort_length); uint sort_length);
static int NEAR_F write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file, static int NEAR_F write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file,
char *key, uint sort_length, uint count); uchar *key, uint sort_length, uint count);
static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info,
IO_CACHE *to_file, IO_CACHE *to_file,
char* key, uint sort_length, uchar* key, uint sort_length,
uint count); uint count);
static inline int static inline int
my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs); my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs);
...@@ -858,16 +858,15 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek, ...@@ -858,16 +858,15 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info,
IO_CACHE *to_file,char* key, IO_CACHE *to_file, uchar* key,
uint sort_length, uint count) uint sort_length, uint count)
{ {
uint idx; uint idx;
uchar *bufs = key;
char *bufs = key;
for (idx=1;idx<=count;idx++) for (idx=1;idx<=count;idx++)
{ {
int err; int err;
if ((err= my_var_write(info,to_file, (uchar*) bufs))) if ((err= my_var_write(info, to_file, bufs)))
return (err); return (err);
bufs=bufs+sort_length; bufs=bufs+sort_length;
} }
...@@ -876,10 +875,10 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, ...@@ -876,10 +875,10 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info,
static int NEAR_F write_merge_key(MI_SORT_PARAM *info __attribute__((unused)), static int NEAR_F write_merge_key(MI_SORT_PARAM *info __attribute__((unused)),
IO_CACHE *to_file, char* key, IO_CACHE *to_file, uchar* key,
uint sort_length, uint count) uint sort_length, uint count)
{ {
return my_b_write(to_file,(uchar*) key,(uint) sort_length*count); return my_b_write(to_file, key, (uint) sort_length * count);
} }
/* /*
......
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