Merge lp:~laurynas-biveinis/percona-xtrabackup/BT-28340-cpp-2.0 into lp:percona-xtrabackup/2.0

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 501
Proposed branch: lp:~laurynas-biveinis/percona-xtrabackup/BT-28340-cpp-2.0
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 973 lines (+248/-145)
11 files modified
src/Makefile (+14/-7)
src/buffer.c (+1/-0)
src/compress.c (+4/-5)
src/compress.h (+8/-0)
src/local.c (+1/-0)
src/stream.c (+1/-0)
src/xbstream.c (+1/-0)
src/xbstream_read.c (+1/-0)
src/xbstream_write.c (+1/-0)
src/xtrabackup.cc (+209/-132)
utils/build.sh (+7/-1)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-xtrabackup/BT-28340-cpp-2.0
Reviewer Review Type Date Requested Status
Laurynas Biveinis Pending
Review via email: mp+149810@code.launchpad.net

This proposal supersedes a proposal from 2013-02-20.

Description of the change

3rd MP: xtrabackup_stream declaration and bug 1130581 fixed.
http://jenkins.percona.com/job/percona-xtrabackup-2.0-param/333/

2nd MP: compress.c changes as described in a comment.
http://jenkins.percona.com/job/percona-xtrabackup-2.0-param/332/

1st MP:
BT 28340
http://jenkins.percona.com/job/percona-xtrabackup-2.0-param/331/
Build InnoDB-facing parts of XtraBackup with a C++ compiler,
implementing
https://blueprints.launchpad.net/percona-xtrabackup/+spec/xtrabackup-cpp

For 2.0, the InnoDB-facing parts is defined as xtrabackup.cc, renamed
from xtrabackup.c. The rest is built with a C compiler.

utils/build.sh: add -fpermissive to CXXFLAGS for 5.0 and 5.1-builtin
InnoDB.

src/Makefile: define CXXFLAGS, define COMMON_FLAGS for C- and
C++-shared flags. Split XTRABACKUPOBJS into XTRABACKUPCOBJS and
XTRABACKUPCCOBJS. Add a C++ build rule.

Fix a bunch of compilation warnings, including new C++ warnings (and
errors) and some of the existing ones.

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Missed that compress.c includes univ.i and uses ibool and ut_a. The fix is trivial, not affecting anything else, thus leaving as "Needs Review" for now.

=== modified file 'src/compress.c'
--- src/compress.c 2013-02-14 05:45:51 +0000
+++ src/compress.c 2013-02-19 07:34:28 +0000
@@ -21,7 +21,6 @@
 #include <mysql_version.h>
 #include <my_base.h>
 #include <quicklz.h>
-#include <univ.i>
 #include <zlib.h>
 #include "common.h"
 #include "datasink.h"
@@ -63,9 +62,9 @@
  size_t bytes_processed;
 } ds_compress_file_t;

-extern ibool xtrabackup_stream;
+extern my_bool xtrabackup_stream;
 extern uint xtrabackup_parallel;
-extern ibool xtrabackup_compress_threads;
+extern my_bool xtrabackup_compress_threads;

 static ds_ctxt_t *compress_init(const char *root);
 static ds_file_t *compress_open(ds_ctxt_t *ctxt, const char *path,
@@ -272,7 +271,7 @@
         &thd->data_mutex);
    }

- ut_a(threads[i].to_len > 0);
+ xb_a(threads[i].to_len > 0);

    if (dest_ds->write(dest_file, "NEWBNEWB", 8) ||
        write_uint64_le(dest_ds, dest_file,

review: Needs Fixing
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

The instant after submitting the 2nd MP I realized that
- xtrabackup_stream needs its declaration adjusted in xtrabackup.cc;
- xtrabackup_compress_threads is declared ibool/my_bool in compress.c and uint in xtrabackup.cc!

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) wrote :

>utils/build.sh: add -fpermissive to CXXFLAGS for 5.0 and 5.1-builtin
> InnoDB.

Unfortunately this breaks building with clang which doesn't support -fpermissive.

Which is not a big deal for me, "CC=gcc CXX=g++ utils/build.sh" works just fine. But someone somewhere might get hit by this.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Fixing 5.0 and 5.1-builtin not to need -fpermissive needs making a rather large patch for include/*.ic in an effort that is IMHO hard to justify. I suggest we document that building with clang is not supported for these two configurations.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Makefile'
2--- src/Makefile 2013-01-07 06:17:40 +0000
3+++ src/Makefile 2013-02-21 12:24:29 +0000
4@@ -12,10 +12,13 @@
5 LIBS += -lpthread
6 DEFS = -DUNIV_LINUX -DMYSQL_SERVER
7
8-CFLAGS += -DXTRABACKUP_VERSION=\"$(XTRABACKUP_VERSION)\" -pedantic -Wall -Wundef -Wshadow -fdiagnostics-show-option -fno-strict-aliasing -Wno-strict-aliasing -Wextra -Wformat -Wno-format-nonliteral -Wno-format-security -Wno-long-long -Wmissing-declarations -Wno-redundant-decls --std=gnu99
9+COMMON_FLAGS = -DXTRABACKUP_VERSION=\"$(XTRABACKUP_VERSION)\" -pedantic -Wall -Wundef -Wshadow -fdiagnostics-show-option -fno-strict-aliasing -Wno-strict-aliasing -Wextra -Wformat -Wno-format-nonliteral -Wno-format-security -Wno-long-long -Wmissing-declarations -Wno-redundant-decls
10+CFLAGS += $(COMMON_FLAGS) --std=gnu99
11+CXXFLAGS += $(COMMON_FLAGS)
12
13 ifneq ($(DEBUG),)
14 CFLAGS += -DXB_DEBUG=1
15+CXXFLAGS += -DXB_DEBUG=1
16 endif
17
18 TARGET=xtrabackup
19@@ -23,9 +26,10 @@
20 BIN_DIR=$(PREFIX)/bin
21
22 COMMON_INC = -I. -I libarchive/libarchive -I quicklz
23-XTRABACKUPOBJS = xtrabackup.o stream.o local.o compress.o buffer.o \
24+XTRABACKUPCOBJS = stream.o local.o compress.o buffer.o \
25 xbstream_write.o \
26 quicklz/quicklz.o
27+XTRABACKUPCCOBJS = xtrabackup.o
28 XBSTREAMOBJS = xbstream.o xbstream_write.o xbstream_read.o
29
30 LIBARCHIVE_A = libarchive/libarchive/libarchive.a
31@@ -171,20 +175,23 @@
32 xtradb55: TARGET := xtrabackup_55
33 xtradb55: $(TARGET) xbstream
34
35-$(XTRABACKUPOBJS): %.o: %.c
36+$(XTRABACKUPCOBJS): %.o: %.c
37 $(CC) $(CFLAGS) $(INC) $(DEFS) -c $< -o $@
38
39+$(XTRABACKUPCCOBJS): %.o: %.cc
40+ $(CXX) $(CXXFLAGS) $(INC) $(DEFS) -c $< -o $@
41+
42 xbstream.o xbstream_read.o: %.o: %.c
43 $(CC) $(CFLAGS) $(INC) $(DEFS) -c $< -o $@
44
45 xbstream: $(XBSTREAMOBJS) $(MYSQLOBJS) local.o
46 $(CC) $(CFLAGS) $^ $(INC) $(MYSQLOBJS) $(LIBS) -o $@
47
48-xtrabackup.o: xtrabackup.c xb_regex.h
49+xtrabackup.o: xtrabackup.cc xb_regex.h
50
51-$(TARGET): $(XTRABACKUPOBJS) $(INNODBOBJS) $(MYSQLOBJS) $(LIBARCHIVE_A)
52- $(CC) $(CFLAGS) $(XTRABACKUPOBJS) $(INNODBOBJS) $(MYSQLOBJS) $(LIBS) \
53+$(TARGET): $(XTRABACKUPCCOBJS) $(XTRABACKUPCOBJS) $(INNODBOBJS) $(MYSQLOBJS) $(LIBARCHIVE_A)
54+ $(CXX) $(CFXXLAGS) $(XTRABACKUPCCOBJS) $(XTRABACKUPCOBJS) $(INNODBOBJS) $(MYSQLOBJS) $(LIBS) \
55 $(LIBARCHIVE_A) -o $(TARGET)
56
57 clean:
58- rm -f $(XTRABACKUPOBJS) $(XBSTREAMOBJS) xtrabackup xtrabackup_*
59+ rm -f $(XTRABACKUPCCOBJS) $(XTRABACKUPCOBJS) $(XBSTREAMOBJS) xtrabackup xtrabackup_*
60
61=== modified file 'src/buffer.c'
62--- src/buffer.c 2013-01-07 06:17:40 +0000
63+++ src/buffer.c 2013-02-21 12:24:29 +0000
64@@ -23,6 +23,7 @@
65 specified buffer size (DS_DEFAULT_BUFFER_SIZE by default), with the only
66 exception for the last write for a file. */
67
68+#include <mysql_version.h>
69 #include <my_base.h>
70 #include "common.h"
71 #include "datasink.h"
72
73=== modified file 'src/compress.c'
74--- src/compress.c 2013-01-13 12:28:59 +0000
75+++ src/compress.c 2013-02-21 12:24:29 +0000
76@@ -18,10 +18,9 @@
77
78 *******************************************************/
79
80-
81+#include <mysql_version.h>
82 #include <my_base.h>
83 #include <quicklz.h>
84-#include <univ.i>
85 #include <zlib.h>
86 #include "common.h"
87 #include "datasink.h"
88@@ -63,9 +62,9 @@
89 size_t bytes_processed;
90 } ds_compress_file_t;
91
92-extern ibool xtrabackup_stream;
93+extern my_bool xtrabackup_stream;
94 extern uint xtrabackup_parallel;
95-extern ibool xtrabackup_compress_threads;
96+extern uint xtrabackup_compress_threads;
97
98 static ds_ctxt_t *compress_init(const char *root);
99 static ds_file_t *compress_open(ds_ctxt_t *ctxt, const char *path,
100@@ -272,7 +271,7 @@
101 &thd->data_mutex);
102 }
103
104- ut_a(threads[i].to_len > 0);
105+ xb_a(threads[i].to_len > 0);
106
107 if (dest_ds->write(dest_file, "NEWBNEWB", 8) ||
108 write_uint64_le(dest_ds, dest_file,
109
110=== modified file 'src/compress.h'
111--- src/compress.h 2013-01-11 12:56:00 +0000
112+++ src/compress.h 2013-02-21 12:24:29 +0000
113@@ -25,7 +25,15 @@
114
115 extern datasink_t datasink_compress;
116
117+#ifdef __cplusplus
118+extern "C" {
119+#endif
120+
121 /* Return a target datasink for the specified compress datasink */
122 ds_ctxt_t *compress_get_dest_ctxt(ds_ctxt_t *);
123
124+#ifdef __cplusplus
125+}
126+#endif
127+
128 #endif
129
130=== modified file 'src/local.c'
131--- src/local.c 2013-01-11 12:56:00 +0000
132+++ src/local.c 2013-02-21 12:24:29 +0000
133@@ -18,6 +18,7 @@
134
135 *******************************************************/
136
137+#include <mysql_version.h>
138 #include <my_base.h>
139 #include <mysys_err.h>
140 #include "common.h"
141
142=== modified file 'src/stream.c'
143--- src/stream.c 2013-01-11 12:56:00 +0000
144+++ src/stream.c 2013-02-21 12:24:29 +0000
145@@ -18,6 +18,7 @@
146
147 *******************************************************/
148
149+#include <mysql_version.h>
150 #include <my_base.h>
151 #include <archive.h>
152 #include <archive_entry.h>
153
154=== modified file 'src/xbstream.c'
155--- src/xbstream.c 2013-01-11 12:56:00 +0000
156+++ src/xbstream.c 2013-02-21 12:24:29 +0000
157@@ -18,6 +18,7 @@
158
159 *******************************************************/
160
161+#include <mysql_version.h>
162 #include <my_base.h>
163 #include <my_getopt.h>
164 #include <hash.h>
165
166=== modified file 'src/xbstream_read.c'
167--- src/xbstream_read.c 2013-01-11 12:56:00 +0000
168+++ src/xbstream_read.c 2013-02-21 12:24:29 +0000
169@@ -18,6 +18,7 @@
170
171 *******************************************************/
172
173+#include <mysql_version.h>
174 #include <my_base.h>
175 #include <zlib.h>
176 #include "common.h"
177
178=== modified file 'src/xbstream_write.c'
179--- src/xbstream_write.c 2013-01-11 12:56:00 +0000
180+++ src/xbstream_write.c 2013-02-21 12:24:29 +0000
181@@ -18,6 +18,7 @@
182
183 *******************************************************/
184
185+#include <mysql_version.h>
186 #include <my_base.h>
187 #include <zlib.h>
188 #include "common.h"
189
190=== renamed file 'src/xtrabackup.c' => 'src/xtrabackup.cc'
191--- src/xtrabackup.c 2013-01-13 22:34:01 +0000
192+++ src/xtrabackup.cc 2013-02-21 12:24:29 +0000
193@@ -48,9 +48,9 @@
194
195 //#define XTRABACKUP_TARGET_IS_PLUGIN
196
197+#include <mysql_version.h>
198 #include <my_base.h>
199 #include <my_getopt.h>
200-#include <mysql_version.h>
201 #include <mysql_com.h>
202
203 #if (MYSQL_VERSION_ID < 50100)
204@@ -59,6 +59,8 @@
205 #define G_PTR uchar*
206 #endif
207
208+extern "C" {
209+
210 #include <univ.i>
211 #include <os0file.h>
212 #include <os0thread.h>
213@@ -86,12 +88,16 @@
214 #include <btr0sea.h>
215 #include <log0recv.h>
216 #include <fcntl.h>
217+#include <buf0flu.h>
218 #include <buf0lru.h>
219
220 #ifdef INNODB_VERSION_SHORT
221 #include <ibuf0ibuf.h>
222+#include <page0zip.h>
223 #endif
224
225+} /* extern "C" */
226+
227 #include "common.h"
228 #include "datasink.h"
229 #include "local.h"
230@@ -145,6 +151,8 @@
231 #define UNIV_PAGE_SIZE_SHIFT_MAX UNIV_PAGE_SIZE_SHIFT
232 #endif
233
234+extern "C" {
235+
236 #if MYSQL_VERSION_ID >= 50507
237 /*
238 As of MySQL 5.5.7, InnoDB uses thd_wait plugin service.
239@@ -168,7 +176,7 @@
240
241 #endif /* MYSQL_VERSION_ID >= 50507 */
242
243-/* prototypes for static functions in original */
244+/* prototypes for static and non-prototyped functions in original */
245 #ifndef INNODB_VERSION_SHORT
246 page_t*
247 btr_node_ptr_get_child(
248@@ -177,7 +185,92 @@
249 rec_t* node_ptr,/* in: node pointer */
250 const ulint* offsets,/* in: array returned by rec_get_offsets() */
251 mtr_t* mtr); /* in: mtr */
252-#else
253+
254+ibool
255+thd_is_replication_slave_thread(
256+ void* thd);
257+
258+ibool
259+thd_has_edited_nontrans_tables(
260+ void* thd);
261+
262+ibool
263+thd_is_select(
264+ const void* thd);
265+
266+void
267+innobase_mysql_print_thd(
268+ FILE* f,
269+ void* input_thd,
270+ uint max_query_len);
271+
272+void
273+innobase_convert_from_table_id(
274+ char* to,
275+ const char* from,
276+ ulint len);
277+
278+void
279+innobase_convert_from_id(
280+ char* to,
281+ const char* from,
282+ ulint len);
283+
284+int
285+innobase_strcasecmp(
286+ const char* a,
287+ const char* b);
288+
289+void
290+innobase_casedn_str(
291+ char* a);
292+
293+struct charset_info_st*
294+innobase_get_charset(
295+ void* mysql_thd);
296+
297+int
298+innobase_mysql_tmpfile(void);
299+
300+void
301+innobase_invalidate_query_cache(
302+ trx_t* trx,
303+ char* full_name,
304+ ulint full_name_len);
305+
306+/*****************************************************************//**
307+Convert a table or index name to the MySQL system_charset_info (UTF-8)
308+and quote it if needed.
309+@return pointer to the end of buf */
310+char*
311+innobase_convert_name(
312+/*==================*/
313+ char* buf, /*!< out: buffer for converted identifier */
314+ ulint buflen, /*!< in: length of buf, in bytes */
315+ const char* id, /*!< in: identifier to convert */
316+ ulint idlen, /*!< in: length of id, in bytes */
317+ void* thd, /*!< in: MySQL connection thread, or NULL */
318+ ibool table_id);/*!< in: TRUE=id is a table or database name;
319+ FALSE=id is an index name */
320+
321+int
322+innobase_mysql_cmp(
323+ int mysql_type,
324+ uint charset_number,
325+ unsigned char* a,
326+ unsigned int a_length,
327+ unsigned char* b,
328+ unsigned int b_length);
329+
330+ulint
331+innobase_get_at_most_n_mbchars(
332+ ulint charset_id,
333+ ulint prefix_len,
334+ ulint data_len,
335+ const char* str);
336+
337+#else /* #ifndef INNODB_VERSION_SHORT */
338+
339 buf_block_t*
340 btr_node_ptr_get_child(
341 /*===================*/
342@@ -191,8 +284,30 @@
343 /*===============*/
344 dict_index_t* index, /*!< in: index tree */
345 mtr_t* mtr); /*!< in: mtr */
346+
347+int
348+innobase_mysql_cmp(
349+/*===============*/
350+ int mysql_type,
351+ uint charset_number,
352+ unsigned char* a,
353+ unsigned int a_length,
354+ unsigned char* b,
355+ unsigned int b_length);
356+
357+#endif /* #ifndef INNODB_VERSION_SHORT */
358+
359+#ifdef XTRADB_BASED
360+trx_t*
361+innobase_get_trx();
362 #endif
363
364+void
365+innobase_get_cset_width(
366+ ulint cset,
367+ ulint* mbminlen,
368+ ulint* mbmaxlen);
369+
370 int
371 fil_file_readdir_next_file(
372 /*=======================*/
373@@ -269,6 +384,8 @@
374 a file, so this is either "open" or
375 "create" */
376
377+} /* extern "C" */
378+
379 /****************************************************************//**
380 A simple function to open or create a file.
381 @return own: handle to the file, not defined if error, error number
382@@ -723,7 +840,9 @@
383 const char* name) /*!< in: space name */
384 {
385 fil_space_t* space;
386+#ifdef INNODB_VERSION_SHORT
387 ulint fold;
388+#endif
389
390 ut_ad(mutex_own(&fil_system->mutex));
391
392@@ -745,6 +864,7 @@
393
394 /*******************************************************************//**
395 Free all spaces in space_list. */
396+static
397 void
398 fil_free_all_spaces(void)
399 /*=====================*/
400@@ -756,7 +876,6 @@
401 space = UT_LIST_GET_FIRST(fil_system->space_list);
402
403 while (space != NULL) {
404- fil_node_t* node;
405 fil_space_t* prev_space = space;
406
407 space = UT_LIST_GET_NEXT(space_list, space);
408@@ -841,9 +960,9 @@
409
410 char *xtrabackup_stream_str = NULL;
411 xb_stream_fmt_t xtrabackup_stream_fmt;
412-ibool xtrabackup_stream = FALSE;
413+my_bool xtrabackup_stream = FALSE;
414
415-char *xtrabackup_compress_alg = NULL;
416+static const char *xtrabackup_compress_alg = NULL;
417 ibool xtrabackup_compress = FALSE;
418 uint xtrabackup_compress_threads;
419
420@@ -907,7 +1026,9 @@
421 long innobase_open_files = 300L;
422
423 long innobase_page_size = (1 << 14); /* 16KB */
424+#ifdef XTRADB_BASED
425 static ulong innobase_log_block_size = 512;
426+#endif
427 my_bool innobase_fast_checksum = FALSE;
428 my_bool innobase_extra_undoslots = FALSE;
429 char* innobase_doublewrite_file = NULL;
430@@ -970,7 +1091,8 @@
431 {
432 datafiles_iter_t *it;
433
434- it = ut_malloc(sizeof(datafiles_iter_t));
435+ it = static_cast<datafiles_iter_t *>
436+ (ut_malloc(sizeof(datafiles_iter_t)));
437 it->mutex = OS_MUTEX_CREATE();
438
439 it->system = f_system;
440@@ -1426,7 +1548,7 @@
441 }
442 #endif
443
444-UNIV_INLINE
445+static
446 void
447 debug_sync_point(const char *name)
448 {
449@@ -1434,7 +1556,6 @@
450 FILE *fp;
451 pid_t pid;
452 char pid_path[FN_REFLEN];
453- int stat_loc;
454
455 if (xtrabackup_debug_sync == NULL) {
456 return;
457@@ -1562,6 +1683,8 @@
458
459 /* ================ Dummys =================== */
460
461+extern "C" {
462+
463 ibool
464 thd_is_replication_slave_thread(
465 void* thd)
466@@ -1590,18 +1713,6 @@
467 }
468
469 void
470-innobase_mysql_prepare_print_arbitrary_thd(void)
471-{
472- /* do nothing */
473-}
474-
475-void
476-innobase_mysql_end_print_arbitrary_thd(void)
477-{
478- /* do nothing */
479-}
480-
481-void
482 innobase_mysql_print_thd(
483 FILE* f,
484 void* input_thd,
485@@ -1695,6 +1806,8 @@
486 return(NULL);
487 }
488
489+#ifdef INNODB_VERSION_SHORT
490+
491 const char*
492 innobase_get_stmt(
493 void* mysql_thd,
494@@ -1706,6 +1819,8 @@
495 return("nothing");
496 }
497
498+#endif
499+
500 int
501 innobase_mysql_tmpfile(void)
502 {
503@@ -1764,12 +1879,15 @@
504 return(fd2);
505 }
506
507+} /* extern "C" */
508+
509 /***********************************************************************
510 Creates a temporary file in tmpdir with a specified prefix in the file
511 name. The file will be automatically removed on close.
512 Unlike innobase_mysql_tmpfile(), dup() is not used, so the returned
513 file must be closed with my_close().
514 @return file descriptor or a negative number in case of error.*/
515+static
516 File
517 xtrabackup_create_tmpfile(char *path, const char *prefix)
518 {
519@@ -1793,6 +1911,8 @@
520 return(fd);
521 }
522
523+extern "C" {
524+
525 void
526 innobase_invalidate_query_cache(
527 trx_t* trx,
528@@ -1809,43 +1929,7 @@
529 /* do nothing */
530 }
531
532-int
533-mysql_get_identifier_quote_char(
534- trx_t* trx,
535- const char* name,
536- ulint namelen)
537-{
538- (void)trx;
539- (void)name;
540- (void)namelen;
541- return '"';
542-}
543-
544-void
545-innobase_print_identifier(
546- FILE* f,
547- trx_t* trx __attribute__((unused)),
548- ibool table_id __attribute__((unused)),
549- const char* name,
550- ulint namelen)
551-{
552- const char* s = name;
553- const char* e = s + namelen;
554- int q;
555-
556- q = '"';
557-
558- putc(q, f);
559- while (s < e) {
560- int c = *s++;
561- if (c == q) {
562- putc(c, f);
563- }
564- putc(c, f);
565- }
566- putc(q, f);
567-}
568-
569+#if MYSQL_VERSION_ID >= 50500
570 /**********************************************************************//**
571 It should be safe to use lower_case_table_names=0 for xtrabackup. If it causes
572 any problems, we can add the lower_case_table_names option to xtrabackup
573@@ -1870,6 +1954,9 @@
574
575 return((name) ? name : "null");
576 }
577+#endif
578+
579+} /* extern "C" */
580
581 /*****************************************************************//**
582 Convert an SQL identifier to the MySQL system_charset_info (UTF-8)
583@@ -1935,6 +2022,8 @@
584 return(buf);
585 }
586
587+extern "C" {
588+
589 /*****************************************************************//**
590 Convert a table or index name to the MySQL system_charset_info (UTF-8)
591 and quote it if needed.
592@@ -2133,13 +2222,6 @@
593 return(char_length);
594 }
595
596-ibool
597-innobase_query_is_update(void)
598-{
599- msg("xtrabackup: innobase_query_is_update() is called\n");
600- return(0);
601-}
602-
603 #ifdef INNODB_VERSION_SHORT
604 ulint
605 innobase_raw_format(
606@@ -2206,6 +2288,8 @@
607 #endif
608 #endif
609
610+} /* extern "C" */
611+
612 /***********************************************************************//**
613 Compatibility wrapper around os_file_flush().
614 @return TRUE if success */
615@@ -2225,7 +2309,7 @@
616 /***********************************************************************
617 Computes bit shift for a given value. If the argument is not a power
618 of 2, returns 0.*/
619-UNIV_INLINE
620+static inline
621 ulint
622 get_bit_shift(ulint value)
623 {
624@@ -3179,8 +3263,8 @@
625 ibool success;
626 ulint space;
627
628- buf = ut_malloc(2 * UNIV_PAGE_SIZE_MAX);
629- page = ut_align(buf, UNIV_PAGE_SIZE_MAX);
630+ buf = static_cast<byte *>(ut_malloc(2 * UNIV_PAGE_SIZE_MAX));
631+ page = static_cast<byte *>(ut_align(buf, UNIV_PAGE_SIZE_MAX));
632
633 success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE_MAX);
634 if (!success) {
635@@ -3301,10 +3385,13 @@
636
637 if (xtrabackup_incremental) {
638 /* allocate buffer for incremental backup (4096 pages) */
639- incremental_buffer_base = ut_malloc((UNIV_PAGE_SIZE_MAX / 4 + 1)
640- * UNIV_PAGE_SIZE_MAX);
641- incremental_buffer = ut_align(incremental_buffer_base,
642- UNIV_PAGE_SIZE_MAX);
643+ incremental_buffer_base
644+ = static_cast<byte *>(ut_malloc((UNIV_PAGE_SIZE_MAX
645+ / 4 + 1)
646+ * UNIV_PAGE_SIZE_MAX));
647+ incremental_buffer
648+ = static_cast<byte *>(ut_align(incremental_buffer_base,
649+ UNIV_PAGE_SIZE_MAX));
650
651 snprintf(meta_name, sizeof(meta_name),
652 "%s%s", dst_name, XB_DELTA_INFO_SUFFIX);
653@@ -3350,8 +3437,9 @@
654 node->name, dstfile->path);
655 }
656
657- buf2 = ut_malloc(COPY_CHUNK * page_size + UNIV_PAGE_SIZE);
658- page = ut_align(buf2, UNIV_PAGE_SIZE);
659+ buf2 = static_cast<byte *>(ut_malloc(COPY_CHUNK
660+ * page_size + UNIV_PAGE_SIZE));
661+ page = static_cast<byte *>(ut_align(buf2, UNIV_PAGE_SIZE));
662
663 success = os_file_read(src_file, page, 0, 0, UNIV_PAGE_SIZE);
664 if (!success) {
665@@ -3910,6 +3998,7 @@
666 Initialize the tablespace memory cache and populate it by scanning for and
667 opening data files.
668 @returns DB_SUCCESS or error code.*/
669+static
670 ulint
671 xb_data_files_init(void)
672 /*====================*/
673@@ -3991,6 +4080,7 @@
674 /*********************************************************************//**
675 Normalizes init parameter values to use units we use inside InnoDB.
676 @return DB_SUCCESS or error code */
677+static
678 void
679 xb_normalize_init_values(void)
680 /*==========================*/
681@@ -4030,6 +4120,7 @@
682
683 /************************************************************************
684 Destroy the tablespace memory cache. */
685+static
686 void
687 xb_data_files_close(void)
688 /*====================*/
689@@ -4082,42 +4173,6 @@
690 srv_shutdown_state = SRV_SHUTDOWN_NONE;
691 }
692
693-/***************************************************************************
694-Creates an output directory for a given tablespace, if it does not exist */
695-static
696-int
697-xtrabackup_create_output_dir(
698-/*==========================*/
699- /* out: 0 if succes, -1 if failure */
700- fil_space_t *space) /* in: tablespace */
701-{
702- char path[FN_REFLEN];
703- char *ptr1, *ptr2;
704-
705- /* mkdir if not exist */
706- ptr1 = strstr(space->name, SRV_PATH_SEPARATOR_STR);
707- if (ptr1) {
708- ptr2 = strstr(ptr1 + 1, SRV_PATH_SEPARATOR_STR);
709- } else {
710- ptr2 = NULL;
711- }
712- if(!trx_sys_sys_space(space->id) && ptr2)
713- {
714- /* single table space */
715- *ptr2 = 0; /* temporary (it's my lazy..)*/
716- snprintf(path, sizeof(path), "%s%s", xtrabackup_target_dir,
717- ptr1);
718- *ptr2 = SRV_PATH_SEPARATOR;
719-
720- if (my_mkdir(path, 0777, MYF(0)) < 0 && my_errno != EEXIST) {
721- msg("xtrabackup: Error: cannot mkdir %d: %s\n",
722- my_errno, path);
723- return -1;
724- }
725- }
726- return 0;
727-}
728-
729 /**************************************************************************
730 Datafiles copying thread.*/
731 static
732@@ -4128,7 +4183,6 @@
733 {
734 data_thread_ctxt_t *ctxt = (data_thread_ctxt_t *) arg;
735 uint num = ctxt->num;
736- fil_space_t* space;
737 fil_node_t* node;
738
739 /*
740@@ -4140,7 +4194,6 @@
741 debug_sync_point("data_copy_thread_func");
742
743 while ((node = datafiles_iter_next(ctxt->it)) != NULL) {
744- space = node->space;
745
746 /* copy the datafile */
747 if(xtrabackup_copy_datafile(node, num, ctxt->ds_ctxt)) {
748@@ -4279,7 +4332,8 @@
749 tables_regex_num++;
750 }
751
752- tables_regex = ut_malloc(sizeof(xb_regex_t) * tables_regex_num);
753+ tables_regex = static_cast<xb_regex_t *>
754+ (ut_malloc(sizeof(xb_regex_t) * tables_regex_num));
755
756 p = xtrabackup_tables;
757 for (i=0; i < tables_regex_num; i++) {
758@@ -4331,7 +4385,9 @@
759 *p = '\0';
760 }
761
762- table = malloc(sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
763+ table = static_cast<xtrabackup_tables_t *>
764+ (malloc(sizeof(xtrabackup_tables_t)
765+ + strlen(name_buf) + 1));
766 memset(table, '\0', sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
767 table->name = ((char*)table) + sizeof(xtrabackup_tables_t);
768 strcpy(table->name, name_buf);
769@@ -4361,12 +4417,14 @@
770 for (i = 0; i < hash_get_n_cells(tables_hash); i++) {
771 xtrabackup_tables_t* table;
772
773- table = HASH_GET_FIRST(tables_hash, i);
774+ table = static_cast<xtrabackup_tables_t *>
775+ (HASH_GET_FIRST(tables_hash, i));
776
777 while (table) {
778 xtrabackup_tables_t* prev_table = table;
779
780- table = HASH_GET_NEXT(name_hash, prev_table);
781+ table = static_cast<xtrabackup_tables_t *>
782+ (HASH_GET_NEXT(name_hash, prev_table));
783
784 HASH_DELETE(xtrabackup_tables_t, name_hash, tables_hash,
785 ut_fold_string(prev_table->name), prev_table);
786@@ -4585,7 +4643,7 @@
787 log_group_t* max_cp_group;
788 ulint max_cp_field;
789 byte* buf;
790- byte log_hdr_buf_[LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE];
791+ byte* log_hdr_buf_;
792 byte* log_hdr_buf;
793 ulint err;
794
795@@ -4593,7 +4651,10 @@
796 os_thread_id_t log_copying_thread_id;
797 datafiles_iter_t *it;
798
799- log_hdr_buf = ut_align(log_hdr_buf_, OS_FILE_LOG_BLOCK_SIZE);
800+ log_hdr_buf_ = static_cast<byte *>
801+ (ut_malloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE));
802+ log_hdr_buf = static_cast<byte *>
803+ (ut_align(log_hdr_buf_, OS_FILE_LOG_BLOCK_SIZE));
804
805 /* get current checkpoint_lsn */
806 /* Look for the latest checkpoint from any of the log groups */
807@@ -4604,6 +4665,7 @@
808
809 if (err != DB_SUCCESS) {
810
811+ ut_free(log_hdr_buf_);
812 exit(EXIT_FAILURE);
813 }
814
815@@ -4630,6 +4692,7 @@
816
817 if (err != DB_SUCCESS) {
818
819+ ut_free(log_hdr_buf_);
820 exit(EXIT_FAILURE);
821 }
822
823@@ -4656,6 +4719,7 @@
824 msg("xtrabackup: error: "
825 "xtrabackup_create_tmpfile() failed. "
826 "(errno: %d)\n", my_errno);
827+ ut_free(log_hdr_buf_);
828 exit(EXIT_FAILURE);
829 }
830 } else {
831@@ -4667,6 +4731,7 @@
832 if (dst_log_fd < 0) {
833 msg("xtrabackup: error: cannot open %s "
834 "(errno: %d)\n", dst_log_path, my_errno);
835+ ut_free(log_hdr_buf_);
836 exit(EXIT_FAILURE);
837 }
838 }
839@@ -4675,6 +4740,7 @@
840 if (dst_log_fd < 0) {
841 msg("xtrabackup: error: dup() failed (errno: %d)",
842 errno);
843+ ut_free(log_hdr_buf_);
844 exit(EXIT_FAILURE);
845 }
846 }
847@@ -4688,9 +4754,12 @@
848
849 if (my_write(dst_log_fd, log_hdr_buf, LOG_FILE_HDR_SIZE,
850 MYF(MY_WME | MY_NABP))) {
851+ ut_free(log_hdr_buf_);
852 exit(EXIT_FAILURE);
853 }
854
855+ ut_free(log_hdr_buf_);
856+
857 /* start flag */
858 log_copying = TRUE;
859
860@@ -4960,8 +5029,10 @@
861 ulonglong sum_data, sum_data_extern;
862 ulonglong n_recs;
863 ulint page_size;
864+#ifdef INNODB_VERSION_SHORT
865 buf_block_t* block;
866 ulint zip_size;
867+#endif
868
869 n_pages = sum_data = n_recs = 0;
870 n_pages_extern = sum_data_extern = 0;
871@@ -5516,8 +5587,10 @@
872 goto error;
873 }
874
875- log_buf_ = ut_malloc(LOG_FILE_HDR_SIZE * 2);
876- log_buf = ut_align(log_buf_, LOG_FILE_HDR_SIZE);
877+ log_buf_ = static_cast<byte *>
878+ (ut_malloc(LOG_FILE_HDR_SIZE * 2));
879+ log_buf = static_cast<byte *>
880+ (ut_align(log_buf_, LOG_FILE_HDR_SIZE));
881
882 success = os_file_read(src_file, log_buf, 0, 0, LOG_FILE_HDR_SIZE);
883 if (!success) {
884@@ -5567,8 +5640,8 @@
885
886
887 /* TODO: We should skip the following modifies, if it is not the first time. */
888- log_buf_ = ut_malloc(UNIV_PAGE_SIZE * 129);
889- log_buf = ut_align(log_buf_, UNIV_PAGE_SIZE);
890+ log_buf_ = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE * 129));
891+ log_buf = static_cast<byte *>(ut_align(log_buf_, UNIV_PAGE_SIZE));
892
893 /* read log file header */
894 success = os_file_read(src_file, log_buf, 0, 0, LOG_FILE_HDR_SIZE);
895@@ -5831,9 +5904,9 @@
896 return ret;
897 }
898
899- buf = ut_malloc(3 * UNIV_PAGE_SIZE);
900+ buf = static_cast<byte *>(ut_malloc(3 * UNIV_PAGE_SIZE));
901 /* Align the memory for file i/o if we might have O_DIRECT set */
902- page = ut_align(buf, UNIV_PAGE_SIZE);
903+ page = static_cast<byte *>(ut_align(buf, UNIV_PAGE_SIZE));
904
905 memset(page, '\0', UNIV_PAGE_SIZE);
906
907@@ -6155,10 +6228,12 @@
908 xb_file_set_nocache(dst_file, dst_path, "OPEN");
909
910 /* allocate buffer for incremental backup (4096 pages) */
911- incremental_buffer_base = ut_malloc((UNIV_PAGE_SIZE_MAX / 4 + 1) *
912- UNIV_PAGE_SIZE_MAX);
913- incremental_buffer = ut_align(incremental_buffer_base,
914- UNIV_PAGE_SIZE_MAX);
915+ incremental_buffer_base = static_cast<byte *>
916+ (ut_malloc((UNIV_PAGE_SIZE_MAX / 4 + 1) *
917+ UNIV_PAGE_SIZE_MAX));
918+ incremental_buffer = static_cast<byte *>
919+ (ut_align(incremental_buffer_base,
920+ UNIV_PAGE_SIZE_MAX));
921
922 msg("Applying %s to %s...\n", src_path, dst_path);
923
924@@ -6439,8 +6514,8 @@
925
926 xb_file_set_nocache(src_file, src_path, "OPEN");
927
928- log_buf_ = ut_malloc(LOG_FILE_HDR_SIZE * 2);
929- log_buf = ut_align(log_buf_, LOG_FILE_HDR_SIZE);
930+ log_buf_ = static_cast<byte *>(ut_malloc(LOG_FILE_HDR_SIZE * 2));
931+ log_buf = static_cast<byte *>(ut_align(log_buf_, LOG_FILE_HDR_SIZE));
932
933 success = os_file_read(src_file, log_buf, 0, 0, LOG_FILE_HDR_SIZE);
934 if (!success) {
935@@ -6668,8 +6743,10 @@
936 byte* page;
937 byte* buf = NULL;
938
939- buf = ut_malloc(UNIV_PAGE_SIZE * 2);
940- page = ut_align(buf, UNIV_PAGE_SIZE);
941+ buf = static_cast<byte *>
942+ (ut_malloc(UNIV_PAGE_SIZE * 2));
943+ page = static_cast<byte *>
944+ (ut_align(buf, UNIV_PAGE_SIZE));
945
946 /* flush insert buffer at shutdwon */
947 innobase_fast_shutdown = 0;
948
949=== modified file 'utils/build.sh'
950--- utils/build.sh 2013-01-02 04:20:08 +0000
951+++ utils/build.sh 2013-02-21 12:24:29 +0000
952@@ -30,6 +30,12 @@
953 extra_config_55=
954 fi
955
956+if [ "$1" = "innodb51_builtin" -o "$1" = "innodb50" ]
957+then
958+ # include/*.ic in pre-5.1-plugin InnoDB do not compile well in C++.
959+ export CXXFLAGS="$CXXFLAGS -fpermissive"
960+fi
961+
962 MAKE_CMD=make
963 if gmake --version > /dev/null 2>&1
964 then
965@@ -176,7 +182,7 @@
966 build_xtrabackup
967 }
968
969-if ! test -f src/xtrabackup.c
970+if ! test -f src/xtrabackup.cc
971 then
972 echo "`basename $0` must be run from the directory with XtraBackup sources"
973 usage

Subscribers

People subscribed via source and target branches