/* This program is for resetting the lsn and checksum fields of an InnoDB page, so that ibbackup and mysqld will not complain of corruption. NOTE that this program does NOT fix the corruption, though! Read the instructions below VERY carefully. Copyright 2005 Innobase Oy. This program is released under the GNU GPL license version 2. */ #include #include #include #include int main(void) { off_t page_number; int file; off_t offs; off_t ret_offset; ssize_t ret; char* file_name; char buf[8]; /* page_number is the number of the page in the ibdata file that you want to reset. Note that if you have several ibdata files, you have to calculate the page number in the particular ibdata file, and NOT use the global tablespace page number. InnoDB page size is 16 kB. */ file_name = "ibdata1"; page_number = 22357; offs = page_number * 16 * 1024; memset(buf, '\0', 8); file = open(file_name, O_RDWR); if (file == -1) { printf("Cannot open %s\n", file_name); exit(1); } /* Reset FIL_PAGE_SPACE_OR_CHKSUM */ ret_offset = lseek(file, offs, SEEK_SET); if (ret_offset < 0) { printf("Error in lseek 1\n"); exit(1); } ret = write(file, buf, (ssize_t)4); if (ret != 4) { printf("Error in write 1\n"); exit(1); } /* Read FIL_PAGE_LSN */ ret_offset = lseek(file, offs + 16, SEEK_SET); if (ret_offset < 0) { printf("Error in lseek 2\n"); exit(1); } ret = read(file, buf, (ssize_t)8); if (ret != 8) { printf("Error in read\n"); exit(1); } /* Reset FIL_PAGE_END_LSN_OLD_CHKSUM */ ret_offset = lseek(file, offs + 16 * 1024 - 8, SEEK_SET); if (ret_offset < 0) { printf("Error in lseek 3\n"); exit(1); } ret = write(file, buf, (ssize_t)8); if (ret != 8) { printf("Error in write 2\n"); exit(1); } close(file); printf("lsn and checksum fields of page %lu in file %s reset\n", (unsigned long)page_number, file_name); return(0); }