[Commits] Rev 2934: MWL#74: second attempt at fixing Mac OS X build failure. in http://bazaar.launchpad.net/~maria-captains/maria/5.1

knielsen at knielsen-hq.org knielsen at knielsen-hq.org
Mon Nov 15 16:57:26 EET 2010


At http://bazaar.launchpad.net/~maria-captains/maria/5.1

------------------------------------------------------------
revno: 2934
revision-id: knielsen at knielsen-hq.org-20101115145725-lh3g7hqex5da9v31
parent: knielsen at knielsen-hq.org-20101113091540-hnkjc85byrkzo61r
committer: knielsen at knielsen-hq.org
branch nick: work-5.1-mwl74
timestamp: Mon 2010-11-15 15:57:25 +0100
message:
  MWL#74: second attempt at fixing Mac OS X build failure.
  
  Fix maria_dump_log to not include ma_loghandler.c twice during linking
  (as this causes problems on Mac OS X when building shared libraries).
=== modified file 'storage/maria/Makefile.am'
--- a/storage/maria/Makefile.am	2010-11-13 09:15:40 +0000
+++ b/storage/maria/Makefile.am	2010-11-15 14:57:25 +0000
@@ -66,8 +66,7 @@ maria_dump_log_LDADD=		@CLIENT_EXTRA_LDF
                         $(top_builddir)/mysys/libmysys.a \
                         $(top_builddir)/dbug/libdbug.a \
                         $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-maria_dump_log_SOURCES= ma_loghandler.c unittest/ma_loghandler_examples.c
-maria_dump_log_CPPFLAGS= -DMARIA_DUMP_LOG
+maria_dump_log_SOURCES= maria_dump_log.c unittest/ma_loghandler_examples.c
 noinst_PROGRAMS =       ma_test1 ma_test2 ma_test3 ma_rt_test ma_sp_test
 noinst_HEADERS =        maria_def.h ma_rt_index.h ma_rt_key.h ma_rt_mbr.h \
                         ma_sp_defs.h ma_fulltext.h ma_ftdefs.h ma_ft_test1.h \

=== modified file 'storage/maria/ma_loghandler.c'
--- a/storage/maria/ma_loghandler.c	2010-11-07 12:25:29 +0000
+++ b/storage/maria/ma_loghandler.c	2010-11-15 14:57:25 +0000
@@ -1086,34 +1086,14 @@ static my_bool translog_max_lsn_to_heade
 
 
 /*
-  Information from transaction log file header
-*/
-
-typedef struct st_loghandler_file_info
-{
-  /*
-    LSN_IMPOSSIBLE for current file (not finished file).
-    Maximum LSN of the record which parts stored in the
-    file.
-  */
-  LSN max_lsn;
-  ulonglong timestamp;   /* Time stamp */
-  ulong maria_version;   /* Version of maria loghandler */
-  ulong mysql_version;   /* Version of mysql server */
-  ulong server_id;       /* Server ID */
-  ulong page_size;       /* Loghandler page size */
-  ulong file_number;     /* Number of the file (from the file header) */
-} LOGHANDLER_FILE_INFO;
-
-/*
   @brief Extract hander file information from loghandler file page
 
   @param desc header information descriptor to be filled with information
   @param page_buff buffer with the page content
 */
 
-static void translog_interpret_file_header(LOGHANDLER_FILE_INFO *desc,
-                                           uchar *page_buff)
+void translog_interpret_file_header(LOGHANDLER_FILE_INFO *desc,
+                                    uchar *page_buff)
 {
   uchar *ptr;
 
@@ -3400,7 +3380,7 @@ my_bool translog_walk_filenames(const ch
   @brief Fills table of dependence length of page header from page flags
 */
 
-static void translog_fill_overhead_table()
+void translog_fill_overhead_table()
 {
   uint i;
   for (i= 0; i < TRANSLOG_FLAGS_NUM; i++)
@@ -8322,156 +8302,6 @@ void translog_set_file_size(uint32 size)
 
 
 /**
-   Write debug information to log if we EXTRA_DEBUG is enabled
-*/
-
-my_bool translog_log_debug_info(TRN *trn __attribute__((unused)),
-                                enum translog_debug_info_type type
-                                __attribute__((unused)),
-                                uchar *info __attribute__((unused)),
-                                size_t length __attribute__((unused)))
-{
-#ifdef EXTRA_DEBUG
-  LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2];
-  uchar debug_type;
-  LSN lsn;
-
-  if (!trn)
-  {
-    /*
-      We can't log the current transaction because we don't have
-      an active transaction. Use a temporary transaction object instead
-    */
-    trn= &dummy_transaction_object;
-  }
-  debug_type= (uchar) type;
-  log_array[TRANSLOG_INTERNAL_PARTS + 0].str= &debug_type;
-  log_array[TRANSLOG_INTERNAL_PARTS + 0].length= 1;
-  log_array[TRANSLOG_INTERNAL_PARTS + 1].str= info;
-  log_array[TRANSLOG_INTERNAL_PARTS + 1].length= length;
-  return translog_write_record(&lsn, LOGREC_DEBUG_INFO,
-                               trn, NULL,
-                               (translog_size_t) (1+ length),
-                               sizeof(log_array)/sizeof(log_array[0]),
-                               log_array, NULL, NULL);
-#else
-  return 0;
-#endif
-}
-
-
-#ifdef MARIA_DUMP_LOG
-#include <my_getopt.h>
-extern void translog_example_table_init();
-static const char *load_default_groups[]= { "maria_dump_log",0 };
-static void get_options(int *argc,char * * *argv);
-#ifndef DBUG_OFF
-#if defined(__WIN__)
-const char *default_dbug_option= "d:t:i:O,\\maria_dump_log.trace";
-#else
-const char *default_dbug_option= "d:t:i:o,/tmp/maria_dump_log.trace";
-#endif
-#endif
-static ulonglong opt_offset;
-static ulong opt_pages;
-static const char *opt_file= NULL;
-static File handler= -1;
-static my_bool opt_unit= 0;
-static struct my_option my_long_options[] =
-{
-#ifdef IMPLTMENTED
-  {"body", 'b',
-   "Print chunk body dump",
-   (uchar **) &opt_body, (uchar **) &opt_body, 0,
-   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-#endif
-#ifndef DBUG_OFF
-  {"debug", '#', "Output debug log. Often the argument is 'd:t:o,filename'.",
-   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
-#endif
-  {"file", 'f', "Path to file which will be read",
-    (uchar**) &opt_file, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"help", '?', "Display this help and exit.",
-   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
-  { "offset", 'o', "Start reading log from this offset",
-    (uchar**) &opt_offset, (uchar**) &opt_offset,
-    0, GET_ULL, REQUIRED_ARG, 0, 0, ~(longlong) 0, 0, 0, 0 },
-  { "pages", 'n', "Number of pages to read",
-    (uchar**) &opt_pages, (uchar**) &opt_pages, 0,
-    GET_ULONG, REQUIRED_ARG, (long) ~(ulong) 0,
-    (long) 1, (long) ~(ulong) 0, (long) 0,
-    (long) 1, 0},
-  {"unit-test", 'U',
-   "Use unit test record table (for logs created by unittests",
-   (uchar **) &opt_unit, (uchar **) &opt_unit, 0,
-   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-  {"version", 'V', "Print version and exit.",
-   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
-  { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
-};
-
-
-static void print_version(void)
-{
-  VOID(printf("%s Ver 1.0 for %s on %s\n",
-              my_progname_short, SYSTEM_TYPE, MACHINE_TYPE));
-  NETWARE_SET_SCREEN_MODE(1);
-}
-
-
-static void usage(void)
-{
-  print_version();
-  puts("Copyright (C) 2008 MySQL AB");
-  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,");
-  puts("and you are welcome to modify and redistribute it under the GPL license\n");
-
-  puts("Dump content of maria log pages.");
-  VOID(printf("\nUsage: %s -f file OPTIONS\n", my_progname_short));
-  my_print_help(my_long_options);
-  print_defaults("my", load_default_groups);
-  my_print_variables(my_long_options);
-}
-
-
-static my_bool
-get_one_option(int optid __attribute__((unused)),
-               const struct my_option *opt __attribute__((unused)),
-               char *argument __attribute__((unused)))
-{
-  switch (optid) {
-  case '?':
-    usage();
-    exit(0);
-  case 'V':
-    print_version();
-    exit(0);
-#ifndef DBUG_OFF
-  case '#':
-    DBUG_SET_INITIAL(argument ? argument : default_dbug_option);
-    break;
-#endif
-  }
-  return 0;
-}
-
-
-static void get_options(int *argc,char ***argv)
-{
-  int ho_error;
-
-  if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
-    exit(ho_error);
-
-  if (opt_file == NULL)
-  {
-    usage();
-    exit(1);
-  }
-}
-
-
-/**
   @brief Dump information about file header page.
 */
 
@@ -8655,7 +8485,7 @@ static uchar *dump_chunk(uchar *buffer, 
   @brief Dump information about page with data.
 */
 
-static void dump_datapage(uchar *buffer)
+static void dump_datapage(uchar *buffer, File handler)
 {
   uchar *ptr;
   ulong offset;
@@ -8736,79 +8566,51 @@ static void dump_datapage(uchar *buffer)
   @brief Dump information about page.
 */
 
-static void dump_page(uchar *buffer)
+void dump_page(uchar *buffer, File handler)
 {
-  printf("Page by offset %llu (0x%llx)\n", opt_offset, opt_offset);
   if (strncmp((char*)maria_trans_file_magic, (char*)buffer,
               sizeof(maria_trans_file_magic)) == 0)
   {
     dump_header_page(buffer);
   }
-  dump_datapage(buffer);
+  dump_datapage(buffer, handler);
 }
 
 
 /**
-  @brief maria_dump_log main function.
+   Write debug information to log if we EXTRA_DEBUG is enabled
 */
 
-int main(int argc, char **argv)
+my_bool translog_log_debug_info(TRN *trn __attribute__((unused)),
+                                enum translog_debug_info_type type
+                                __attribute__((unused)),
+                                uchar *info __attribute__((unused)),
+                                size_t length __attribute__((unused)))
 {
-  char **default_argv;
-  uchar buffer[TRANSLOG_PAGE_SIZE];
-  MY_INIT(argv[0]);
-
-  load_defaults("my", load_default_groups, &argc, &argv);
-  default_argv= argv;
-  get_options(&argc, &argv);
-
-  if (opt_unit)
-    translog_example_table_init();
-  else
-    translog_table_init();
-  translog_fill_overhead_table();
-
-  maria_data_root= (char *)".";
+#ifdef EXTRA_DEBUG
+  LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 2];
+  uchar debug_type;
+  LSN lsn;
 
-  if ((handler= my_open(opt_file, O_RDONLY, MYF(MY_WME))) < 0)
-  {
-    fprintf(stderr, "Can't open file: '%s'  errno: %d\n",
-            opt_file, my_errno);
-    goto err;
-  }
-  if (my_seek(handler, opt_offset, SEEK_SET, MYF(MY_WME)) !=
-      opt_offset)
+  if (!trn)
   {
-     fprintf(stderr, "Can't set position %lld  file: '%s'  errno: %d\n",
-             opt_offset, opt_file, my_errno);
-     goto err;
-  }
-  for (;
-       opt_pages;
-       opt_offset+= TRANSLOG_PAGE_SIZE, opt_pages--)
-  {
-    if (my_pread(handler, buffer, TRANSLOG_PAGE_SIZE, opt_offset,
-                 MYF(MY_NABP)))
-    {
-      if (my_errno == HA_ERR_FILE_TOO_SHORT)
-        goto end;
-      fprintf(stderr, "Can't read page at position %lld  file: '%s'  "
-              "errno: %d\n", opt_offset, opt_file, my_errno);
-      goto err;
-    }
-    dump_page(buffer);
+    /*
+      We can't log the current transaction because we don't have
+      an active transaction. Use a temporary transaction object instead
+    */
+    trn= &dummy_transaction_object;
   }
-
-end:
-  my_close(handler, MYF(0));
-  free_defaults(default_argv);
-  exit(0);
-  return 0;                             /* No compiler warning */
-
-err:
-  my_close(handler, MYF(0));
-  fprintf(stderr, "%s: FAILED\n", my_progname_short);
-  free_defaults(default_argv);
-  exit(1);
-}
+  debug_type= (uchar) type;
+  log_array[TRANSLOG_INTERNAL_PARTS + 0].str= &debug_type;
+  log_array[TRANSLOG_INTERNAL_PARTS + 0].length= 1;
+  log_array[TRANSLOG_INTERNAL_PARTS + 1].str= info;
+  log_array[TRANSLOG_INTERNAL_PARTS + 1].length= length;
+  return translog_write_record(&lsn, LOGREC_DEBUG_INFO,
+                               trn, NULL,
+                               (translog_size_t) (1+ length),
+                               sizeof(log_array)/sizeof(log_array[0]),
+                               log_array, NULL, NULL);
+#else
+  return 0;
 #endif
+}

=== modified file 'storage/maria/ma_loghandler.h'
--- a/storage/maria/ma_loghandler.h	2010-10-13 15:15:43 +0000
+++ b/storage/maria/ma_loghandler.h	2010-11-15 14:57:25 +0000
@@ -358,6 +358,7 @@ translog_assign_id_to_share_from_recover
 extern my_bool translog_walk_filenames(const char *directory,
                                        my_bool (*callback)(const char *,
                                                            const char *));
+extern void dump_page(uchar *buffer, File handler);
 extern my_bool translog_log_debug_info(TRN *trn,
                                        enum translog_debug_info_type type,
                                        uchar *info, size_t length);
@@ -376,8 +377,31 @@ extern enum enum_translog_status translo
   ma_loghandler_for_recovery.h ?
 */
 
+/*
+  Information from transaction log file header
+*/
+
+typedef struct st_loghandler_file_info
+{
+  /*
+    LSN_IMPOSSIBLE for current file (not finished file).
+    Maximum LSN of the record which parts stored in the
+    file.
+  */
+  LSN max_lsn;
+  ulonglong timestamp;   /* Time stamp */
+  ulong maria_version;   /* Version of maria loghandler */
+  ulong mysql_version;   /* Version of mysql server */
+  ulong server_id;       /* Server ID */
+  ulong page_size;       /* Loghandler page size */
+  ulong file_number;     /* Number of the file (from the file header) */
+} LOGHANDLER_FILE_INFO;
+
 #define SHARE_ID_MAX 65535 /* array's size */
 
+extern void translog_fill_overhead_table();
+extern void translog_interpret_file_header(LOGHANDLER_FILE_INFO *desc,
+                                           uchar *page_buff);
 extern LSN translog_first_lsn_in_log();
 extern LSN translog_first_theoretical_lsn();
 extern LSN translog_next_LSN(TRANSLOG_ADDRESS addr, TRANSLOG_ADDRESS horizon);

=== added file 'storage/maria/maria_dump_log.c'
--- a/storage/maria/maria_dump_log.c	1970-01-01 00:00:00 +0000
+++ b/storage/maria/maria_dump_log.c	2010-11-15 14:57:25 +0000
@@ -0,0 +1,190 @@
+/* Copyright (C) 2007 MySQL AB & Sanja Belkin
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "maria_def.h"
+#include <my_getopt.h>
+extern void translog_example_table_init();
+static const char *load_default_groups[]= { "maria_dump_log",0 };
+static void get_options(int *argc,char * * *argv);
+#ifndef DBUG_OFF
+#if defined(__WIN__)
+const char *default_dbug_option= "d:t:i:O,\\maria_dump_log.trace";
+#else
+const char *default_dbug_option= "d:t:i:o,/tmp/maria_dump_log.trace";
+#endif
+#endif
+static ulonglong opt_offset;
+static ulong opt_pages;
+static const char *opt_file= NULL;
+static File handler= -1;
+static my_bool opt_unit= 0;
+static struct my_option my_long_options[] =
+{
+#ifdef IMPLTMENTED
+  {"body", 'b',
+   "Print chunk body dump",
+   (uchar **) &opt_body, (uchar **) &opt_body, 0,
+   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+#endif
+#ifndef DBUG_OFF
+  {"debug", '#', "Output debug log. Often the argument is 'd:t:o,filename'.",
+   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+#endif
+  {"file", 'f', "Path to file which will be read",
+    (uchar**) &opt_file, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"help", '?', "Display this help and exit.",
+   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+  { "offset", 'o', "Start reading log from this offset",
+    (uchar**) &opt_offset, (uchar**) &opt_offset,
+    0, GET_ULL, REQUIRED_ARG, 0, 0, ~(longlong) 0, 0, 0, 0 },
+  { "pages", 'n', "Number of pages to read",
+    (uchar**) &opt_pages, (uchar**) &opt_pages, 0,
+    GET_ULONG, REQUIRED_ARG, (long) ~(ulong) 0,
+    (long) 1, (long) ~(ulong) 0, (long) 0,
+    (long) 1, 0},
+  {"unit-test", 'U',
+   "Use unit test record table (for logs created by unittests",
+   (uchar **) &opt_unit, (uchar **) &opt_unit, 0,
+   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"version", 'V', "Print version and exit.",
+   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+  { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
+};
+
+
+static void print_version(void)
+{
+  VOID(printf("%s Ver 1.0 for %s on %s\n",
+              my_progname_short, SYSTEM_TYPE, MACHINE_TYPE));
+  NETWARE_SET_SCREEN_MODE(1);
+}
+
+
+static void usage(void)
+{
+  print_version();
+  puts("Copyright (C) 2008 MySQL AB");
+  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,");
+  puts("and you are welcome to modify and redistribute it under the GPL license\n");
+
+  puts("Dump content of maria log pages.");
+  VOID(printf("\nUsage: %s -f file OPTIONS\n", my_progname_short));
+  my_print_help(my_long_options);
+  print_defaults("my", load_default_groups);
+  my_print_variables(my_long_options);
+}
+
+
+static my_bool
+get_one_option(int optid __attribute__((unused)),
+               const struct my_option *opt __attribute__((unused)),
+               char *argument __attribute__((unused)))
+{
+  switch (optid) {
+  case '?':
+    usage();
+    exit(0);
+  case 'V':
+    print_version();
+    exit(0);
+#ifndef DBUG_OFF
+  case '#':
+    DBUG_SET_INITIAL(argument ? argument : default_dbug_option);
+    break;
+#endif
+  }
+  return 0;
+}
+
+
+static void get_options(int *argc,char ***argv)
+{
+  int ho_error;
+
+  if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
+    exit(ho_error);
+
+  if (opt_file == NULL)
+  {
+    usage();
+    exit(1);
+  }
+}
+
+
+/**
+  @brief maria_dump_log main function.
+*/
+
+int main(int argc, char **argv)
+{
+  char **default_argv;
+  uchar buffer[TRANSLOG_PAGE_SIZE];
+  MY_INIT(argv[0]);
+
+  load_defaults("my", load_default_groups, &argc, &argv);
+  default_argv= argv;
+  get_options(&argc, &argv);
+
+  if (opt_unit)
+    translog_example_table_init();
+  else
+    translog_table_init();
+  translog_fill_overhead_table();
+
+  maria_data_root= (char *)".";
+
+  if ((handler= my_open(opt_file, O_RDONLY, MYF(MY_WME))) < 0)
+  {
+    fprintf(stderr, "Can't open file: '%s'  errno: %d\n",
+            opt_file, my_errno);
+    goto err;
+  }
+  if (my_seek(handler, opt_offset, SEEK_SET, MYF(MY_WME)) !=
+      opt_offset)
+  {
+     fprintf(stderr, "Can't set position %lld  file: '%s'  errno: %d\n",
+             opt_offset, opt_file, my_errno);
+     goto err;
+  }
+  for (;
+       opt_pages;
+       opt_offset+= TRANSLOG_PAGE_SIZE, opt_pages--)
+  {
+    if (my_pread(handler, buffer, TRANSLOG_PAGE_SIZE, opt_offset,
+                 MYF(MY_NABP)))
+    {
+      if (my_errno == HA_ERR_FILE_TOO_SHORT)
+        goto end;
+      fprintf(stderr, "Can't read page at position %lld  file: '%s'  "
+              "errno: %d\n", opt_offset, opt_file, my_errno);
+      goto err;
+    }
+    printf("Page by offset %llu (0x%llx)\n", opt_offset, opt_offset);
+    dump_page(buffer, handler);
+  }
+
+end:
+  my_close(handler, MYF(0));
+  free_defaults(default_argv);
+  exit(0);
+  return 0;                             /* No compiler warning */
+
+err:
+  my_close(handler, MYF(0));
+  fprintf(stderr, "%s: FAILED\n", my_progname_short);
+  free_defaults(default_argv);
+  exit(1);
+}



More information about the commits mailing list