~gaul/percona-data-recovery-tool-for-innodb/prerequisites

« back to all changes in this revision

Viewing changes to innochecksum.c

  • Committer: aleksandr.kuzminsky at percona
  • Date: 2012-08-07 20:19:15 UTC
  • mfrom: (51.2.1 hexadecimal-checksums)
  • Revision ID: aleksandr.kuzminsky@percona.com-20120807201915-fi3s1ahck0m72vbq
Consistently log hexadecimal checksums

Show diffs side-by-side

added added

removed removed

Lines of Context:
242
242
    oldcsum= buf_calc_page_old_checksum(p);
243
243
    oldcsumfield= mach_read_from_4(p + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
244
244
    if (debug)
245
 
      printf("page %lu: old style: calculated = %lu; recorded = %lu\n", ct, oldcsum, oldcsumfield);
 
245
      printf("page %lu: old style: calculated = 0x%08X; recorded = 0x%08X\n", ct, oldcsum, oldcsumfield);
246
246
    if (oldcsumfield != oldcsum)
247
247
    {
248
248
      fprintf(stderr, "page %lu invalid (fails old style checksum)\n", ct);
249
 
      fprintf(stderr, "page %lu: old style: calculated = 0x%X; recorded = 0x%X\n", ct, oldcsum, oldcsumfield);
 
249
      fprintf(stderr, "page %lu: old style: calculated = 0x%08X; recorded = 0x%08X\n", ct, oldcsum, oldcsumfield);
250
250
      if(fix_checksum){
251
251
        fprintf(stderr, "fixing old checksum of page %lu\n", ct);
252
252
        // rewite recorded checksum with calculated one
267
267
        }
268
268
    }
269
269
 
 
270
<<<<<<< TREE
 
271
=======
 
272
    /* now check the new method */
 
273
    csum= buf_calc_page_new_checksum(p);
 
274
    csumfield= mach_read_from_4(p + FIL_PAGE_SPACE_OR_CHKSUM);
 
275
    if (debug)
 
276
      printf("page %lu: new style: calculated = 0x%08X; recorded = 0x%08X\n", ct, csum, csumfield);
 
277
    if (csumfield != 0 && csum != csumfield)
 
278
    {
 
279
      fprintf(stderr, "page %lu invalid (fails new style checksum)\n", ct);
 
280
      fprintf(stderr, "page %lu: new style: calculated = 0x%08X; recorded = 0x%08X\n", ct, csum, csumfield);
 
281
      if(fix_checksum){
 
282
        fprintf(stderr, "fixing new checksum of page %lu\n", ct);
 
283
        // rewite recorded checksum with calculated one
 
284
        fixed_chksum = mach_read_from_4((uchar*)&csum);
 
285
        memcpy(p + FIL_PAGE_SPACE_OR_CHKSUM, &fixed_chksum, sizeof(fixed_chksum));
 
286
        // move to beginning of the page
 
287
        if(0 != fsetpos(f, &pos)){
 
288
                perror("couldn't set a position to the start of the page");
 
289
                return 1;
 
290
                }
 
291
        if(1 != fwrite(p, UNIV_PAGE_SIZE, 1, f)){
 
292
                perror("couldn't update the page");
 
293
                return 1;
 
294
                }
 
295
        }
 
296
      else{
 
297
        return 1;
 
298
        }
 
299
    }
 
300
 
 
301
>>>>>>> MERGE-SOURCE
270
302
    /* end if this was the last page we were supposed to check */
271
303
    if (use_end_page && (ct >= end_page))
272
304
      return 0;