Commit e39aae7c authored by unknown's avatar unknown

Maria: fix for a bug in the transaction's manager and a bug in

the unit test of the control file module.


storage/maria/trnman.c:
  fix for a bug (i has to be in [1..SHORT_TRID_MAX])
storage/maria/unittest/ma_control_file-t.c:
  corrupted checksum is in buffer[0], not in buffer[1]
parent 887383d4
...@@ -163,7 +163,7 @@ static TrID new_trid() ...@@ -163,7 +163,7 @@ static TrID new_trid()
static void set_short_trid(TRN *trn) static void set_short_trid(TRN *trn)
{ {
int i= (global_trid_generator + (intptr)trn) * 312089 % SHORT_TRID_MAX; int i= (global_trid_generator + (intptr)trn) * 312089 % SHORT_TRID_MAX + 1;
my_atomic_rwlock_wrlock(&LOCK_short_trid_to_trn); my_atomic_rwlock_wrlock(&LOCK_short_trid_to_trn);
for ( ; ; i= i % SHORT_TRID_MAX + 1) /* the range is [1..SHORT_TRID_MAX] */ for ( ; ; i= i % SHORT_TRID_MAX + 1) /* the range is [1..SHORT_TRID_MAX] */
{ {
......
...@@ -346,13 +346,13 @@ static int test_bad_checksum() ...@@ -346,13 +346,13 @@ static int test_bad_checksum()
MYF(MY_WME))) >= 0); MYF(MY_WME))) >= 0);
RET_ERR_UNLESS(my_pread(fd, buffer, 1, 4, MYF(MY_FNABP | MY_WME)) == 0); RET_ERR_UNLESS(my_pread(fd, buffer, 1, 4, MYF(MY_FNABP | MY_WME)) == 0);
buffer[0]+= 3; /* mangle checksum */ buffer[0]+= 3; /* mangle checksum */
RET_ERR_UNLESS(my_pwrite(fd, buffer+1, 1, 4, MYF(MY_FNABP | MY_WME)) == 0); RET_ERR_UNLESS(my_pwrite(fd, buffer, 1, 4, MYF(MY_FNABP | MY_WME)) == 0);
/* Check that control file module sees the problem */ /* Check that control file module sees the problem */
RET_ERR_UNLESS(ma_control_file_create_or_open() == RET_ERR_UNLESS(ma_control_file_create_or_open() ==
CONTROL_FILE_BAD_CHECKSUM); CONTROL_FILE_BAD_CHECKSUM);
/* Restore checksum */ /* Restore checksum */
buffer[0]-= 3; buffer[0]-= 3;
RET_ERR_UNLESS(my_pwrite(fd, buffer+1, 1, 4, MYF(MY_FNABP | MY_WME)) == 0); RET_ERR_UNLESS(my_pwrite(fd, buffer, 1, 4, MYF(MY_FNABP | MY_WME)) == 0);
RET_ERR_UNLESS(my_close(fd, MYF(MY_WME)) == 0); RET_ERR_UNLESS(my_close(fd, MYF(MY_WME)) == 0);
return 0; return 0;
......
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