You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.2 KiB

WL#3072 Maria recovery. * Thanks to Serg's tip, we fix here the compilation issue of REDO_REPAIR_TABLE's execution, by defining versions of _ma_killed_ptr() and _ma_check_print_info|warning|error() in maria_read_log.c (we move those of maria_chk.c into an include file and include it in maria_chk.c and maria_read_log.c). Execution of such record looks like working from my tests (it only happens in maria_read_log; recovery-from-mysqld skips DDLs and REPAIR is considered DDL here as it bypasses logging): tested ALTER TABLE ENABLE KEYS and then remove table, apply log: that did a repair. * Recent changes broke maria_read_log a bit: -a became default and -o caused error; fixing this. storage/maria/Makefile.am: addind new file storage/maria/ma_recovery.c: enable execution of REDO_REPAIR_TABLE by maria_read_log now that it compiles. Now reason to keep only T_QUICK from testflag. storage/maria/maria_chk.c: moving these functions to ma_check_standalone.h for reusability storage/maria/maria_def.h: comment storage/maria/maria_read_log.c: ma_check_standalone.h needs my_progname_short. Fixing bug where "maria_read_log" would default to -a and "maria_read_log -o" would throw an error. Implemented behaviour is: - no options: usage() - -a : applys, applys UNDOs by default unless --disable-undo - -o : only prints storage/maria/ma_check_standalone.h: All standalone programs which need to use functions from ma_check.c (like maria_repair()) must define their version of _ma_killed_ptr() and _ma_check_print_info|warning|error(). Indeed, linking with ma_check.o brings in the dependencies of ma_check.o which are definitions of the above functions; if the program does not define them then the ones of ha_maria.o are used i.e. ha_maria.o is linked into the program, and this brings dependencies of ha_maria.o on mysqld.o into the program's linking which thus fails, as the program is not linked with mysqld.o. We put in this file the functions which maria_chk.c uses, so that they can be reused by maria_read_log (when it replays REDO_REPAIR_TABLE) as they are good enough (they just print to stdout/stderr like maria_read_log already does).
18 years ago
  1. /* Copyright (C) 2007 MySQL AB
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  12. /*
  13. All standalone programs which need to use functions from ma_check.c
  14. (like maria_repair()) must define their version of _ma_killed_ptr()
  15. and _ma_check_print_info|warning|error(). Indeed, linking with ma_check.o
  16. brings in the dependencies of ma_check.o which are definitions of the above
  17. functions; if the program does not define them then the ones of
  18. ha_maria.o are used i.e. ha_maria.o is linked into the program, and this
  19. brings dependencies of ha_maria.o on mysqld.o into the program's linking
  20. which thus fails, as the program is not linked with mysqld.o.
  21. This file contains the versions of these functions used by maria_chk and
  22. maria_read_log.
  23. */
  24. /*
  25. Check if check/repair operation was killed by a signal
  26. */
  27. static int not_killed= 0;
  28. volatile int *_ma_killed_ptr(HA_CHECK *param __attribute__((unused)))
  29. {
  30. return &not_killed; /* always NULL */
  31. }
  32. /* print warnings and errors */
  33. /* VARARGS */
  34. void _ma_check_print_info(HA_CHECK *param __attribute__((unused)),
  35. const char *fmt,...)
  36. {
  37. va_list args;
  38. DBUG_ENTER("_ma_check_print_info");
  39. DBUG_PRINT("enter", ("format: %s", fmt));
  40. va_start(args,fmt);
  41. VOID(vfprintf(stdout, fmt, args));
  42. VOID(fputc('\n',stdout));
  43. va_end(args);
  44. DBUG_VOID_RETURN;
  45. }
  46. /* VARARGS */
  47. void _ma_check_print_warning(HA_CHECK *param, const char *fmt,...)
  48. {
  49. va_list args;
  50. DBUG_ENTER("_ma_check_print_warning");
  51. DBUG_PRINT("enter", ("format: %s", fmt));
  52. fflush(stdout);
  53. if (!param->warning_printed && !param->error_printed)
  54. {
  55. if (param->testflag & T_SILENT)
  56. fprintf(stderr,"%s: MARIA file %s\n",my_progname_short,
  57. param->isam_file_name);
  58. param->out_flag|= O_DATA_LOST;
  59. }
  60. param->warning_printed=1;
  61. va_start(args,fmt);
  62. fprintf(stderr,"%s: warning: ",my_progname_short);
  63. VOID(vfprintf(stderr, fmt, args));
  64. VOID(fputc('\n',stderr));
  65. fflush(stderr);
  66. va_end(args);
  67. DBUG_VOID_RETURN;
  68. }
  69. /* VARARGS */
  70. void _ma_check_print_error(HA_CHECK *param, const char *fmt,...)
  71. {
  72. va_list args;
  73. DBUG_ENTER("_ma_check_print_error");
  74. DBUG_PRINT("enter", ("format: %s", fmt));
  75. fflush(stdout);
  76. if (!param->warning_printed && !param->error_printed)
  77. {
  78. if (param->testflag & T_SILENT)
  79. fprintf(stderr,"%s: MARIA file %s\n",my_progname_short,param->isam_file_name);
  80. param->out_flag|= O_DATA_LOST;
  81. }
  82. param->error_printed|=1;
  83. va_start(args,fmt);
  84. fprintf(stderr,"%s: error: ",my_progname_short);
  85. VOID(vfprintf(stderr, fmt, args));
  86. VOID(fputc('\n',stderr));
  87. fflush(stderr);
  88. va_end(args);
  89. DBUG_VOID_RETURN;
  90. }