diff options
Diffstat (limited to 'extra')
31 files changed, 617 insertions, 525 deletions
diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index 2fc56ce5e98..b7b1d215711 100644 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -1,14 +1,14 @@ # Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. -# +# # 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA @@ -30,9 +30,9 @@ ENDIF() # to mysqld_error.h using cmake -E copy_if_different ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp COMMAND comp_err - --charset=${PROJECT_SOURCE_DIR}/sql/share/charsets + --charset=${PROJECT_SOURCE_DIR}/sql/share/charsets --out-dir=${CMAKE_BINARY_DIR}/sql/share/ - --header_file=${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp + --header_file=${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp --name_file=${CMAKE_BINARY_DIR}/include/mysqld_ername.h.tmp --state_file=${CMAKE_BINARY_DIR}/include/sql_state.h.tmp --in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg-utf8.txt @@ -43,7 +43,7 @@ ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp ADD_CUSTOM_TARGET(GenError ALL - DEPENDS + DEPENDS ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp) MYSQL_ADD_EXECUTABLE(my_print_defaults my_print_defaults.c) @@ -106,9 +106,9 @@ IF(UNIX) MYSQL_ADD_EXECUTABLE(resolve_stack_dump resolve_stack_dump.c) TARGET_LINK_LIBRARIES(resolve_stack_dump mysys) - MYSQL_ADD_EXECUTABLE(mysql_waitpid mysql_waitpid.c COMPONENT Client) - TARGET_LINK_LIBRARIES(mysql_waitpid mysys) + MYSQL_ADD_EXECUTABLE(mariadb-waitpid mysql_waitpid.c COMPONENT Client) + TARGET_LINK_LIBRARIES(mariadb-waitpid mysys) - MYSQL_ADD_EXECUTABLE(mysqld_safe_helper mysqld_safe_helper.c COMPONENT Server) - TARGET_LINK_LIBRARIES(mysqld_safe_helper mysys) + MYSQL_ADD_EXECUTABLE(mariadbd-safe-helper mysqld_safe_helper.c COMPONENT Server) + TARGET_LINK_LIBRARIES(mariadbd-safe-helper mysys) ENDIF() diff --git a/extra/comp_err.c b/extra/comp_err.c index 704bbc0eaf6..52353ac9eea 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -31,6 +31,7 @@ #include <m_string.h> #include <my_getopt.h> #include <my_dir.h> +#include <ctype.h> #define MAX_ROWS 3000 #define ERRORS_PER_RANGE 1000 @@ -150,8 +151,6 @@ static uint parse_input_file(const char *file_name, struct errors **top_error, static int get_options(int *argc, char ***argv); static void print_version(void); static void usage(void); -static my_bool get_one_option(int optid, const struct my_option *opt, - char *argument); static char *parse_text_line(char *pos); static int copy_rows(FILE * to, char *row, int row_nr, long start_pos); static char *parse_default_language(char *str); @@ -751,18 +750,19 @@ static struct message *find_message(struct errors *err, const char *lang, for the format specifiers RETURN VALUE - Returns the checksum for all the characters of the + Returns the checksum for all letters of the format specifiers Ex. - "text '%-64.s' text part 2 %d'" - ^^^^^^ ^^ + "text '%-.64s' text part 2 %zu'" + ^ ^^ characters will be xored to form checksum + Non-letters are skipped, because they do not change the type + of the argument. + NOTE: - Does not support format specifiers with positional args - like "%2$s" but that is not yet supported by my_vsnprintf - either. + Does not support format specifiers with positional args like "%2$s" */ static ha_checksum checksum_format_specifier(const char* msg) @@ -779,20 +779,17 @@ static ha_checksum checksum_format_specifier(const char* msg) start= p+1; /* Entering format specifier */ num_format_specifiers++; } - else if (start) + else if (start && isalpha(*p)) { + chksum= my_checksum(chksum, p, 1); switch(*p) { case 'd': case 'u': case 'x': case 's': case 'M': - chksum= my_checksum(chksum, (uchar*) start, (uint) (p + 1 - start)); start= 0; /* Not in format specifier anymore */ break; - - default: - break; } } @@ -889,7 +886,7 @@ static char *get_word(char **str) DBUG_ENTER("get_word"); *str= find_end_of_word(start); - DBUG_RETURN(my_strndup(start, (uint) (*str - start), + DBUG_RETURN(my_strndup(PSI_NOT_INSTRUMENTED, start, (uint) (*str - start), MYF(MY_WME | MY_FAE))); } @@ -923,7 +920,7 @@ static struct message *parse_message_string(struct message *new_message, while (*str != ' ' && *str != '\t' && *str) str++; if (!(new_message->lang_short_name= - my_strndup(start, (uint) (str - start), + my_strndup(PSI_NOT_INSTRUMENTED, start, (uint) (str - start), MYF(MY_WME | MY_FAE)))) DBUG_RETURN(0); /* Fatal error */ DBUG_PRINT("info", ("msg_slang: %s", new_message->lang_short_name)); @@ -943,9 +940,9 @@ static struct message *parse_message_string(struct message *new_message, start= str + 1; str= parse_text_line(start); - if (!(new_message->text= my_strndup(start, (uint) (str - start), - MYF(MY_WME | MY_FAE)))) - DBUG_RETURN(0); /* Fatal error */ + if (!(new_message->text= my_strndup(PSI_NOT_INSTRUMENTED, start, + (uint) (str - start), MYF(MY_WME | MY_FAE)))) + DBUG_RETURN(0); DBUG_PRINT("info", ("msg_text: %s", new_message->text)); DBUG_RETURN(new_message); @@ -958,11 +955,11 @@ static struct errors *generate_empty_message(uint d_code, my_bool skip) struct message message; /* create a new element */ - if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error), - MYF(MY_WME)))) + if (!(new_error= (struct errors *) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(*new_error), MYF(MY_WME)))) return(0); - if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 1, - MYF(0))) + if (my_init_dynamic_array(PSI_NOT_INSTRUMENTED, &new_error->msg, + sizeof(struct message), 0, 1, MYF(0))) return(0); /* OOM: Fatal error */ new_error->er_name= NULL; @@ -973,8 +970,10 @@ static struct errors *generate_empty_message(uint d_code, my_bool skip) message.text= 0; /* If skip set, don't generate a text */ - if (!(message.lang_short_name= my_strdup(default_language, MYF(MY_WME))) || - (!skip && !(message.text= my_strdup("", MYF(MY_WME))))) + if (!(message.lang_short_name= my_strdup(PSI_NOT_INSTRUMENTED, + default_language, MYF(MY_WME))) || + (!skip && !(message.text= my_strdup(PSI_NOT_INSTRUMENTED, + "", MYF(MY_WME))))) return(0); /* Can't fail as msg is preallocated */ @@ -995,13 +994,14 @@ static struct errors *parse_error_string(char *str, int er_count) DBUG_PRINT("enter", ("str: %s", str)); /* create a new element */ - if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error), - MYF(MY_WME)))) + if (!(new_error= (struct errors *) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(*new_error), MYF(MY_WME)))) DBUG_RETURN(0); new_error->next_error= 0; - if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 0, MYF(0))) - DBUG_RETURN(0); /* OOM: Fatal error */ + if (my_init_dynamic_array(PSI_NOT_INSTRUMENTED, &new_error->msg, + sizeof(struct message), 0, 0, MYF(0))) + DBUG_RETURN(0); /* getting the error name */ str= skip_delimiters(str); @@ -1087,7 +1087,8 @@ static struct languages *parse_charset_string(char *str) do { /*creating new element of the linked list */ - new_lang= (struct languages *) my_malloc(sizeof(*new_lang), MYF(MY_WME)); + new_lang= (struct languages *) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(*new_lang), MYF(MY_WME)); new_lang->next_lang= head; head= new_lang; @@ -1134,11 +1135,12 @@ static void print_version(void) static my_bool -get_one_option(int optid, const struct my_option *opt __attribute__ ((unused)), - char *argument __attribute__ ((unused))) +get_one_option(const struct my_option *opt, + char *argument __attribute__ ((unused)), + const char *filename __attribute__ ((unused))) { DBUG_ENTER("get_one_option"); - switch (optid) { + switch (opt->id) { case 'V': print_version(); my_end(0); diff --git a/extra/crc32_armv8_neon/CMakeLists.txt b/extra/crc32_armv8_neon/CMakeLists.txt new file mode 100644 index 00000000000..ba1d34d7c2e --- /dev/null +++ b/extra/crc32_armv8_neon/CMakeLists.txt @@ -0,0 +1,8 @@ +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include) + +ADD_CONVENIENCE_LIBRARY(${CRC32_LIBRARY} $<TARGET_OBJECTS:common_crc32c_armv8>) +ADD_LIBRARY(common_crc32c_armv8 OBJECT crc32_armv8.c) + +SET_TARGET_PROPERTIES(common_crc32c_armv8 PROPERTIES COMPILE_FLAGS "${ARMV8_CRC_COMPILE_FLAGS}") + diff --git a/extra/crc32_armv8_neon/crc32_armv8.c b/extra/crc32_armv8_neon/crc32_armv8.c new file mode 100644 index 00000000000..20f341552e2 --- /dev/null +++ b/extra/crc32_armv8_neon/crc32_armv8.c @@ -0,0 +1,301 @@ +#include <my_global.h> +#include <string.h> + + +#if defined(__GNUC__) && defined(__linux__) && defined(HAVE_ARMV8_CRC) + +#include <sys/auxv.h> +#include <asm/hwcap.h> + +#ifndef HWCAP_CRC32 +#define HWCAP_CRC32 (1 << 7) +#endif + +unsigned int crc32c_aarch64_available(void) +{ + unsigned long auxv = getauxval(AT_HWCAP); + return (auxv & HWCAP_CRC32) != 0; +} + +#endif + +#ifndef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS + +/* Request crc extension capabilities from the assembler */ +asm(".arch_extension crc"); + +#ifdef HAVE_ARMV8_CRYPTO +/* crypto extension */ +asm(".arch_extension crypto"); +#endif + +#define CRC32CX(crc, value) __asm__("crc32cx %w[c], %w[c], %x[v]":[c]"+r"(crc):[v]"r"(value)) +#define CRC32CW(crc, value) __asm__("crc32cw %w[c], %w[c], %w[v]":[c]"+r"(crc):[v]"r"(value)) +#define CRC32CH(crc, value) __asm__("crc32ch %w[c], %w[c], %w[v]":[c]"+r"(crc):[v]"r"(value)) +#define CRC32CB(crc, value) __asm__("crc32cb %w[c], %w[c], %w[v]":[c]"+r"(crc):[v]"r"(value)) + +#define CRC32C3X8(buffer, ITR) \ + __asm__("crc32cx %w[c1], %w[c1], %x[v]":[c1]"+r"(crc1):[v]"r"(*((const uint64_t *)buffer + 42*1 + (ITR))));\ + __asm__("crc32cx %w[c2], %w[c2], %x[v]":[c2]"+r"(crc2):[v]"r"(*((const uint64_t *)buffer + 42*2 + (ITR))));\ + __asm__("crc32cx %w[c0], %w[c0], %x[v]":[c0]"+r"(crc0):[v]"r"(*((const uint64_t *)buffer + 42*0 + (ITR)))); + +#define CRC32C3X8_ZERO \ + __asm__("crc32cx %w[c0], %w[c0], xzr":[c0]"+r"(crc0)); + +#else /* HAVE_ARMV8_CRC_CRYPTO_INTRINSICS */ + +/* Intrinsics header*/ +#include <arm_acle.h> +#include <arm_neon.h> + +#define CRC32CX(crc, value) (crc) = __crc32cd((crc), (value)) +#define CRC32CW(crc, value) (crc) = __crc32cw((crc), (value)) +#define CRC32CH(crc, value) (crc) = __crc32ch((crc), (value)) +#define CRC32CB(crc, value) (crc) = __crc32cb((crc), (value)) + +#define CRC32C3X8(buffer, ITR) \ + crc1 = __crc32cd(crc1, *((const uint64_t *)buffer + 42*1 + (ITR)));\ + crc2 = __crc32cd(crc2, *((const uint64_t *)buffer + 42*2 + (ITR)));\ + crc0 = __crc32cd(crc0, *((const uint64_t *)buffer + 42*0 + (ITR))); + +#define CRC32C3X8_ZERO \ + crc0 = __crc32cd(crc0, (const uint64_t)0); + +#endif /* HAVE_ARMV8_CRC_CRYPTO_INTRINSICS */ + +#define CRC32C7X3X8(buffer, ITR) do {\ + CRC32C3X8(buffer, ((ITR) * 7 + 0)) \ + CRC32C3X8(buffer, ((ITR) * 7 + 1)) \ + CRC32C3X8(buffer, ((ITR) * 7 + 2)) \ + CRC32C3X8(buffer, ((ITR) * 7 + 3)) \ + CRC32C3X8(buffer, ((ITR) * 7 + 4)) \ + CRC32C3X8(buffer, ((ITR) * 7 + 5)) \ + CRC32C3X8(buffer, ((ITR) * 7 + 6)) \ + } while(0) + +#define CRC32C7X3X8_ZERO do {\ + CRC32C3X8_ZERO \ + CRC32C3X8_ZERO \ + CRC32C3X8_ZERO \ + CRC32C3X8_ZERO \ + CRC32C3X8_ZERO \ + CRC32C3X8_ZERO \ + CRC32C3X8_ZERO \ + } while(0) + +#define PREF4X64L1(buffer, PREF_OFFSET, ITR) \ + __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]"::[v]"r"(buffer), [c]"I"((PREF_OFFSET) + ((ITR) + 0)*64));\ + __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]"::[v]"r"(buffer), [c]"I"((PREF_OFFSET) + ((ITR) + 1)*64));\ + __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]"::[v]"r"(buffer), [c]"I"((PREF_OFFSET) + ((ITR) + 2)*64));\ + __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]"::[v]"r"(buffer), [c]"I"((PREF_OFFSET) + ((ITR) + 3)*64)); + +#define PREF1KL1(buffer, PREF_OFFSET) \ + PREF4X64L1(buffer,(PREF_OFFSET), 0) \ + PREF4X64L1(buffer,(PREF_OFFSET), 4) \ + PREF4X64L1(buffer,(PREF_OFFSET), 8) \ + PREF4X64L1(buffer,(PREF_OFFSET), 12) + +#define PREF4X64L2(buffer, PREF_OFFSET, ITR) \ + __asm__("PRFM PLDL2KEEP, [%x[v],%[c]]"::[v]"r"(buffer), [c]"I"((PREF_OFFSET) + ((ITR) + 0)*64));\ + __asm__("PRFM PLDL2KEEP, [%x[v],%[c]]"::[v]"r"(buffer), [c]"I"((PREF_OFFSET) + ((ITR) + 1)*64));\ + __asm__("PRFM PLDL2KEEP, [%x[v],%[c]]"::[v]"r"(buffer), [c]"I"((PREF_OFFSET) + ((ITR) + 2)*64));\ + __asm__("PRFM PLDL2KEEP, [%x[v],%[c]]"::[v]"r"(buffer), [c]"I"((PREF_OFFSET) + ((ITR) + 3)*64)); + +#define PREF1KL2(buffer, PREF_OFFSET) \ + PREF4X64L2(buffer,(PREF_OFFSET), 0) \ + PREF4X64L2(buffer,(PREF_OFFSET), 4) \ + PREF4X64L2(buffer,(PREF_OFFSET), 8) \ + PREF4X64L2(buffer,(PREF_OFFSET), 12) + + +uint32_t crc32c_aarch64(uint32_t crc, const unsigned char *buffer, uint64_t len) +{ + uint32_t crc0, crc1, crc2; + int64_t length = (int64_t)len; + + crc = 0xFFFFFFFFU; + + if (buffer) { + +/* Crypto extension Support + * Process 1024 Bytes (per block) + */ +#ifdef HAVE_ARMV8_CRYPTO + +/* Intrinsics Support */ +#ifdef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS + const poly64_t k1 = 0xe417f38a, k2 = 0x8f158014; + uint64_t t0, t1; + + /* Process per block size of 1024 Bytes + * A block size = 8 + 42*3*sizeof(uint64_t) + 8 + */ + while ((length -= 1024) >= 0) { + /* Prefetch 3*1024 data for avoiding L2 cache miss */ + PREF1KL2(buffer, 1024*3); + /* Do first 8 bytes here for better pipelining */ + crc0 = __crc32cd(crc, *(const uint64_t *)buffer); + crc1 = 0; + crc2 = 0; + buffer += sizeof(uint64_t); + + /* Process block inline + * Process crc0 last to avoid dependency with above + */ + CRC32C7X3X8(buffer, 0); + CRC32C7X3X8(buffer, 1); + CRC32C7X3X8(buffer, 2); + CRC32C7X3X8(buffer, 3); + CRC32C7X3X8(buffer, 4); + CRC32C7X3X8(buffer, 5); + + buffer += 42*3*sizeof(uint64_t); + /* Prefetch data for following block to avoid L1 cache miss */ + PREF1KL1(buffer, 1024); + + /* Last 8 bytes + * Merge crc0 and crc1 into crc2 + * crc1 multiply by K2 + * crc0 multiply by K1 + */ + t1 = (uint64_t)vmull_p64(crc1, k2); + t0 = (uint64_t)vmull_p64(crc0, k1); + crc = __crc32cd(crc2, *(const uint64_t *)buffer); + crc1 = __crc32cd(0, t1); + crc ^= crc1; + crc0 = __crc32cd(0, t0); + crc ^= crc0; + + buffer += sizeof(uint64_t); + } + +#else /* HAVE_ARMV8_CRC_CRYPTO_INTRINSICS */ + + /*No intrinsics*/ + __asm__("mov x16, #0xf38a \n\t" + "movk x16, #0xe417, lsl 16 \n\t" + "mov v1.2d[0], x16 \n\t" + "mov x16, #0x8014 \n\t" + "movk x16, #0x8f15, lsl 16 \n\t" + "mov v0.2d[0], x16 \n\t" + :::"x16"); + + while ((length -= 1024) >= 0) { + PREF1KL2(buffer, 1024*3); + __asm__("crc32cx %w[c0], %w[c], %x[v]\n\t" + :[c0]"=r"(crc0):[c]"r"(crc), [v]"r"(*(const uint64_t *)buffer):); + crc1 = 0; + crc2 = 0; + buffer += sizeof(uint64_t); + + CRC32C7X3X8(buffer, 0); + CRC32C7X3X8(buffer, 1); + CRC32C7X3X8(buffer, 2); + CRC32C7X3X8(buffer, 3); + CRC32C7X3X8(buffer, 4); + CRC32C7X3X8(buffer, 5); + + buffer += 42*3*sizeof(uint64_t); + PREF1KL1(buffer, 1024); + __asm__("mov v2.2d[0], %x[c1] \n\t" + "pmull v2.1q, v2.1d, v0.1d \n\t" + "mov v3.2d[0], %x[c0] \n\t" + "pmull v3.1q, v3.1d, v1.1d \n\t" + "crc32cx %w[c], %w[c2], %x[v] \n\t" + "mov %x[c1], v2.2d[0] \n\t" + "crc32cx %w[c1], wzr, %x[c1] \n\t" + "eor %w[c], %w[c], %w[c1] \n\t" + "mov %x[c0], v3.2d[0] \n\t" + "crc32cx %w[c0], wzr, %x[c0] \n\t" + "eor %w[c], %w[c], %w[c0] \n\t" + :[c1]"+r"(crc1), [c0]"+r"(crc0), [c2]"+r"(crc2), [c]"+r"(crc) + :[v]"r"(*((const uint64_t *)buffer))); + buffer += sizeof(uint64_t); + } +#endif /* HAVE_ARMV8_CRC_CRYPTO_INTRINSICS */ + + /* Done if Input data size is aligned with 1024 */ + if(!(length += 1024)) + return (~crc); + +#endif /* HAVE_ARMV8_CRYPTO */ + + while ((length -= sizeof(uint64_t)) >= 0) { + CRC32CX(crc, *(uint64_t *)buffer); + buffer += sizeof(uint64_t); + } + /* The following is more efficient than the straight loop */ + if (length & sizeof(uint32_t)) { + CRC32CW(crc, *(uint32_t *)buffer); + buffer += sizeof(uint32_t); + } + if (length & sizeof(uint16_t)) { + CRC32CH(crc, *(uint16_t *)buffer); + buffer += sizeof(uint16_t); + } + if (length & sizeof(uint8_t)) + CRC32CB(crc, *buffer); + + } else { +#ifdef HAVE_ARMV8_CRYPTO +#ifdef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS + const poly64_t k1 = 0xe417f38a; + uint64_t t0; + while ((length -= 1024) >= 0) { + crc0 = __crc32cd(crc, 0); + + CRC32C7X3X8_ZERO; + CRC32C7X3X8_ZERO; + CRC32C7X3X8_ZERO; + CRC32C7X3X8_ZERO; + CRC32C7X3X8_ZERO; + CRC32C7X3X8_ZERO; + + /* Merge crc0 into crc: crc0 multiply by K1 */ + t0 = (uint64_t)vmull_p64(crc0, k1); + crc = __crc32cd(0, t0); + } +#else /* !HAVE_ARMV8_CRC_CRYPTO_INTRINSICS */ + __asm__("mov x16, #0xf38a \n\t" + "movk x16, #0xe417, lsl 16 \n\t" + "mov v1.2d[0], x16 \n\t" + :::"x16"); + + while ((length -= 1024) >= 0) { + __asm__("crc32cx %w[c0], %w[c], xzr\n\t" + :[c0]"=r"(crc0):[c]"r"(crc)); + + CRC32C7X3X8_ZERO; + CRC32C7X3X8_ZERO; + CRC32C7X3X8_ZERO; + CRC32C7X3X8_ZERO; + CRC32C7X3X8_ZERO; + CRC32C7X3X8_ZERO; + + __asm__("mov v3.2d[0], %x[c0] \n\t" + "pmull v3.1q, v3.1d, v1.1d \n\t" + "mov %x[c0], v3.2d[0] \n\t" + "crc32cx %w[c], wzr, %x[c0] \n\t" + :[c]"=r"(crc) + :[c0]"r"(crc0)); + } +#endif /* HAVE_ARMV8_CRC_CRYPTO_INTRINSICS */ + if(!(length += 1024)) + return (~crc); +#endif /* HAVE_ARMV8_CRYPTO */ + while ((length -= sizeof(uint64_t)) >= 0) + CRC32CX(crc, 0); + + /* The following is more efficient than the straight loop */ + if (length & sizeof(uint32_t)) + CRC32CW(crc, 0); + + if (length & sizeof(uint16_t)) + CRC32CH(crc, 0); + + if (length & sizeof(uint8_t)) + CRC32CB(crc, 0); + } + + return (~crc); +} diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc index 5e9fe81af8e..d8d043d89b9 100644 --- a/extra/innochecksum.cc +++ b/extra/innochecksum.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. - Copyright (c) 2014, 2019, MariaDB Corporation. + Copyright (c) 2014, 2020, MariaDB Corporation. 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 @@ -49,7 +49,6 @@ The parts not included are excluded by #ifndef UNIV_INNOCHECKSUM. */ #include "page0zip.h" /* page_zip_*() */ #include "trx0undo.h" /* TRX_* */ #include "ut0crc32.h" /* ut_crc32_init() */ -#include "fsp0pagecompress.h" /* fil_get_compression_alg_name */ #include "fil0crypt.h" /* fil_space_verify_crypt_checksum */ #include <string.h> @@ -468,7 +467,7 @@ is_page_corrupted( /* use to store LSN values. */ ulint logseq; ulint logseqfield; - ulint page_type = mach_read_from_2(buf+FIL_PAGE_TYPE); + const uint16_t page_type = fil_page_get_type(buf); uint key_version = buf_page_get_key_version(buf, flags); ulint space_id = mach_read_from_4( buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); @@ -836,7 +835,7 @@ parse_page( strcpy(str, "-"); } - switch (mach_read_from_2(page + FIL_PAGE_TYPE)) { + switch (fil_page_get_type(page)) { case FIL_PAGE_INDEX: { uint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); @@ -895,8 +894,8 @@ parse_page( const byte* des = xdes + XDES_ARR_OFFSET + XDES_SIZE * ((page_no & (physical_page_size - 1)) / FSP_EXTENT_SIZE); - if (xdes_get_bit(des, XDES_FREE_BIT, - page_no % FSP_EXTENT_SIZE)) { + if (xdes_is_free(des, + page_no % FSP_EXTENT_SIZE)) { index.free_pages++; return; } @@ -1332,11 +1331,11 @@ static void usage(void) extern "C" my_bool innochecksum_get_one_option( - int optid, - const struct my_option *opt MY_ATTRIBUTE((unused)), - char *argument MY_ATTRIBUTE((unused))) + const struct my_option *opt, + char *argument MY_ATTRIBUTE((unused)), + const char *) { - switch (optid) { + switch (opt->id) { #ifndef DBUG_OFF case '#': dbug_setting = argument @@ -1551,8 +1550,6 @@ int main( /* our input filename. */ char* filename; /* Buffer to store pages read. */ - byte* buf_ptr = NULL; - byte* xdes_ptr = NULL; byte* buf = NULL; byte* xdes = NULL; /* bytes read count */ @@ -1632,10 +1629,10 @@ int main( } - buf_ptr = (byte*) malloc(UNIV_PAGE_SIZE_MAX * 2); - xdes_ptr = (byte*)malloc(UNIV_PAGE_SIZE_MAX * 2); - buf = (byte *) ut_align(buf_ptr, UNIV_PAGE_SIZE_MAX); - xdes = (byte *) ut_align(xdes_ptr, UNIV_PAGE_SIZE_MAX); + buf = static_cast<byte*>(aligned_malloc(UNIV_PAGE_SIZE_MAX, + UNIV_PAGE_SIZE_MAX)); + xdes = static_cast<byte*>(aligned_malloc(UNIV_PAGE_SIZE_MAX, + UNIV_PAGE_SIZE_MAX)); /* The file name is not optional. */ for (int i = 0; i < argc; ++i) { @@ -1936,7 +1933,7 @@ first_non_zero: skip_page = false; } - ulint cur_page_type = mach_read_from_2(buf+FIL_PAGE_TYPE); + const uint16_t cur_page_type = fil_page_get_type(buf); /* FIXME: Page compressed or Page compressed and encrypted pages do not contain checksum. */ @@ -2014,21 +2011,9 @@ first_non_zero: fclose(log_file); } - free(buf_ptr); - free(xdes_ptr); - - my_end(exit_status); - DBUG_RETURN(exit_status); + goto common_exit; my_exit: - if (buf_ptr) { - free(buf_ptr); - } - - if (xdes_ptr) { - free(xdes_ptr); - } - if (!read_from_stdin && fil_in) { fclose(fil_in); } @@ -2037,6 +2022,9 @@ my_exit: fclose(log_file); } +common_exit: + aligned_free(buf); + aligned_free(xdes); my_end(exit_status); DBUG_RETURN(exit_status); } diff --git a/extra/mariabackup/CMakeLists.txt b/extra/mariabackup/CMakeLists.txt index 796427107d4..ad36d2fa6a6 100644 --- a/extra/mariabackup/CMakeLists.txt +++ b/extra/mariabackup/CMakeLists.txt @@ -37,7 +37,8 @@ INCLUDE_DIRECTORIES( ) IF(NOT HAVE_SYSTEM_REGEX) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/pcre) + INCLUDE_DIRECTORIES(${PCRE_INCLUDES}) + ADD_DEFINITIONS(${PCRE2_DEBIAN_HACK}) ENDIF() @@ -54,7 +55,7 @@ ENDIF() ADD_DEFINITIONS(-DPCRE_STATIC=1) ADD_DEFINITIONS(${SSL_DEFINES}) -MYSQL_ADD_EXECUTABLE(mariabackup +MYSQL_ADD_EXECUTABLE(mariadb-backup xtrabackup.cc innobackupex.cc changed_page_bitmap.cc @@ -74,22 +75,20 @@ MYSQL_ADD_EXECUTABLE(mariabackup backup_mysql.cc backup_copy.cc encryption_plugin.cc + ${PROJECT_BINARY_DIR}/sql/sql_builtin.cc ${PROJECT_SOURCE_DIR}/sql/net_serv.cc ${NT_SERVICE_SOURCE} ${PROJECT_SOURCE_DIR}/libmysqld/libmysql.c COMPONENT backup ) - # Export all symbols on Unix, for better crash callstacks -SET_TARGET_PROPERTIES(mariabackup PROPERTIES ENABLE_EXPORTS TRUE) +SET_TARGET_PROPERTIES(mariadb-backup PROPERTIES ENABLE_EXPORTS TRUE) ADD_SUBDIRECTORY(crc) - -TARGET_LINK_LIBRARIES(mariabackup sql crc) - +TARGET_LINK_LIBRARIES(mariadb-backup sql sql_builtins crc) IF(NOT HAVE_SYSTEM_REGEX) - TARGET_LINK_LIBRARIES(mariabackup pcreposix) + TARGET_LINK_LIBRARIES(mariadb-backup pcre2-posix) ENDIF() diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index 6a0674bf7f5..edcbb94c20f 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -466,14 +466,13 @@ struct datafile_cur_t { char abs_path[FN_REFLEN]; MY_STAT statinfo; uint thread_n; - byte* orig_buf; byte* buf; size_t buf_size; size_t buf_read; size_t buf_offset; explicit datafile_cur_t(const char* filename = NULL) : - file(), thread_n(0), orig_buf(NULL), buf(NULL), buf_size(0), + file(), thread_n(0), buf(NULL), buf_size(0), buf_read(0), buf_offset(0) { memset(rel_path, 0, sizeof rel_path); @@ -1028,16 +1027,16 @@ static int fix_win_file_permissions(const char *file) ea.grfInheritance = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE; ea.Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN; ACL* pNewDACL = 0; - SetEntriesInAcl(1, &ea, pOldDACL, &pNewDACL); - if (pNewDACL) + DWORD err = SetEntriesInAcl(1, &ea, pOldDACL, &pNewDACL); + if (!err) { + DBUG_ASSERT(pNewDACL); SetSecurityInfo(hFile, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, pNewDACL, NULL); + LocalFree((HLOCAL)pNewDACL); } if (pSD != NULL) LocalFree((HLOCAL)pSD); - if (pNewDACL != NULL) - LocalFree((HLOCAL)pNewDACL); CloseHandle(hFile); return 0; } @@ -1864,24 +1863,25 @@ copy_back() dst_dir = (srv_log_group_home_dir && *srv_log_group_home_dir) ? srv_log_group_home_dir : mysql_data_home; - /* --backup generates a single ib_logfile0, which we must copy + /* --backup generates a single LOG_FILE_NAME, which we must copy if it exists. */ ds_data = ds_create(dst_dir, DS_TYPE_LOCAL); MY_STAT stat_arg; - if (!my_stat("ib_logfile0", &stat_arg, MYF(0)) || !stat_arg.st_size) { + if (!my_stat(LOG_FILE_NAME, &stat_arg, MYF(0)) || !stat_arg.st_size) { /* After completed --prepare, redo log files are redundant. We must delete any redo logs at the destination, so that the database will not jump to a different log sequence number (LSN). */ - for (uint i = 0; i <= SRV_N_LOG_FILES_MAX + 1; i++) { - char filename[FN_REFLEN]; - snprintf(filename, sizeof filename, "%s/ib_logfile%u", - dst_dir, i); - unlink(filename); - } - } else if (!(ret = copy_or_move_file("ib_logfile0", "ib_logfile0", + char filename[FN_REFLEN]; + snprintf(filename, sizeof filename, "%s/%s0", dst_dir, + LOG_FILE_NAME_PREFIX); + unlink(filename); + snprintf(filename, sizeof filename, "%s/%s101", dst_dir, + LOG_FILE_NAME_PREFIX); + unlink(filename); + } else if (!(ret = copy_or_move_file(LOG_FILE_NAME, LOG_FILE_NAME, dst_dir, 1))) { goto cleanup; } @@ -1973,7 +1973,7 @@ copy_back() } /* skip the redo log (it was already copied) */ - if (!strcmp(filename, "ib_logfile0")) { + if (!strcmp(filename, LOG_FILE_NAME)) { continue; } diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index e008b2352a7..6d804f78e15 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -476,31 +476,21 @@ bool get_mysql_vars(MYSQL *connection) } if (innodb_data_file_path_var && *innodb_data_file_path_var) - { - innobase_data_file_path= my_strdup(innodb_data_file_path_var, MYF(MY_FAE)); - } + innobase_data_file_path= my_strdup(PSI_NOT_INSTRUMENTED, + innodb_data_file_path_var, MYF(MY_FAE)); if (innodb_data_home_dir_var) - { - innobase_data_home_dir= my_strdup(innodb_data_home_dir_var, MYF(MY_FAE)); - } + innobase_data_home_dir= my_strdup(PSI_NOT_INSTRUMENTED, + innodb_data_home_dir_var, MYF(MY_FAE)); if (innodb_log_group_home_dir_var && *innodb_log_group_home_dir_var) - { - srv_log_group_home_dir= - my_strdup(innodb_log_group_home_dir_var, MYF(MY_FAE)); - } + srv_log_group_home_dir= my_strdup(PSI_NOT_INSTRUMENTED, + innodb_log_group_home_dir_var, + MYF(MY_FAE)); if (innodb_undo_directory_var && *innodb_undo_directory_var) - { - srv_undo_dir= my_strdup(innodb_undo_directory_var, MYF(MY_FAE)); - } - - if (innodb_log_files_in_group_var) - { - srv_n_log_files= strtol(innodb_log_files_in_group_var, &endptr, 10); - ut_ad(*endptr == 0); - } + srv_undo_dir= my_strdup(PSI_NOT_INSTRUMENTED, innodb_undo_directory_var, + MYF(MY_FAE)); if (innodb_log_file_size_var) { @@ -522,7 +512,8 @@ bool get_mysql_vars(MYSQL *connection) if (page_zip_level_var != NULL) { - page_zip_level= strtoul(page_zip_level_var, &endptr, 10); + page_zip_level= static_cast<uint>(strtoul(page_zip_level_var, &endptr, + 10)); ut_ad(*endptr == 0); } @@ -1603,7 +1594,6 @@ bool write_backup_config_file() "[mysqld]\n" "innodb_checksum_algorithm=%s\n" "innodb_data_file_path=%s\n" - "innodb_log_files_in_group=%lu\n" "innodb_log_file_size=%llu\n" "innodb_page_size=%lu\n" "innodb_undo_directory=%s\n" @@ -1613,7 +1603,6 @@ bool write_backup_config_file() "%s\n", innodb_checksum_algorithm_names[srv_checksum_algorithm], make_local_paths(innobase_data_file_path).c_str(), - srv_n_log_files, srv_log_file_size, srv_page_size, srv_undo_dir, diff --git a/extra/mariabackup/crc/crc-intel-pclmul.c b/extra/mariabackup/crc/crc-intel-pclmul.c index cf4f3ef4380..032802c1823 100644 --- a/extra/mariabackup/crc/crc-intel-pclmul.c +++ b/extra/mariabackup/crc/crc-intel-pclmul.c @@ -358,7 +358,7 @@ crc32_reflected_less_than_16 (u32 *pcrc, const byte *inbuf, size_t inlen, else { data = ((const struct u16_unaligned_s *)inbuf)->a; - data |= inbuf[2] << 16; + data |= ((u32) inbuf[2]) << 16; data ^= crc; data <<= 8; crc >>= 24; diff --git a/extra/mariabackup/crc/crc_glue.c b/extra/mariabackup/crc/crc_glue.c index a9709c8378e..bc14d0bb9df 100644 --- a/extra/mariabackup/crc/crc_glue.c +++ b/extra/mariabackup/crc/crc_glue.c @@ -63,9 +63,9 @@ unsigned long crc32_iso3309(unsigned long crc, const unsigned char *buf, unsigne { #if __GNUC__ >= 4 && defined(__x86_64__) && defined(HAVE_CLMUL_INSTRUCTION) if (pclmul_enabled) { - uint32_t crc_accum = crc ^ 0xffffffffL; + uint32_t crc_accum = (uint32_t) ~crc; crc32_intel_pclmul(&crc_accum, buf, len); - return crc_accum ^ 0xffffffffL; + return ~crc_accum; } #endif return crc32(crc, buf, len); diff --git a/extra/mariabackup/ds_buffer.cc b/extra/mariabackup/ds_buffer.cc index 720a329c238..308070ab3b3 100644 --- a/extra/mariabackup/ds_buffer.cc +++ b/extra/mariabackup/ds_buffer.cc @@ -71,13 +71,13 @@ buffer_init(const char *root) ds_ctxt_t *ctxt; ds_buffer_ctxt_t *buffer_ctxt; - ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_buffer_ctxt_t), - MYF(MY_FAE)); + ctxt = (ds_ctxt_t *)my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(ds_ctxt_t) + sizeof(ds_buffer_ctxt_t), MYF(MY_FAE)); buffer_ctxt = (ds_buffer_ctxt_t *) (ctxt + 1); buffer_ctxt->buffer_size = DS_DEFAULT_BUFFER_SIZE; ctxt->ptr = buffer_ctxt; - ctxt->root = my_strdup(root, MYF(MY_FAE)); + ctxt->root = my_strdup(PSI_NOT_INSTRUMENTED, root, MYF(MY_FAE)); return ctxt; } @@ -101,9 +101,8 @@ buffer_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat) buffer_ctxt = (ds_buffer_ctxt_t *) ctxt->ptr; - file = (ds_file_t *) my_malloc(sizeof(ds_file_t) + - sizeof(ds_buffer_file_t) + - buffer_ctxt->buffer_size, + file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(ds_file_t) + + sizeof(ds_buffer_file_t) + buffer_ctxt->buffer_size, MYF(MY_FAE)); buffer_file = (ds_buffer_file_t *) (file + 1); diff --git a/extra/mariabackup/ds_compress.cc b/extra/mariabackup/ds_compress.cc index 487718e2ac0..54c49deac16 100644 --- a/extra/mariabackup/ds_compress.cc +++ b/extra/mariabackup/ds_compress.cc @@ -100,16 +100,15 @@ compress_init(const char *root) return NULL; } - ctxt = (ds_ctxt_t *) my_malloc(sizeof(ds_ctxt_t) + - sizeof(ds_compress_ctxt_t), - MYF(MY_FAE)); + ctxt = (ds_ctxt_t *) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(ds_ctxt_t) + sizeof(ds_compress_ctxt_t), MYF(MY_FAE)); compress_ctxt = (ds_compress_ctxt_t *) (ctxt + 1); compress_ctxt->threads = threads; compress_ctxt->nthreads = xtrabackup_compress_threads; ctxt->ptr = compress_ctxt; - ctxt->root = my_strdup(root, MYF(MY_FAE)); + ctxt->root = my_strdup(PSI_NOT_INSTRUMENTED, root, MYF(MY_FAE)); return ctxt; } @@ -159,9 +158,8 @@ compress_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat) goto err; } - file = (ds_file_t *) my_malloc(sizeof(ds_file_t) + - sizeof(ds_compress_file_t), - MYF(MY_FAE)); + file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(ds_file_t) + sizeof(ds_compress_file_t), MYF(MY_FAE)); comp_file = (ds_compress_file_t *) (file + 1); comp_file->dest_file = dest_file; comp_file->comp_ctxt = comp_ctxt; @@ -336,8 +334,8 @@ create_worker_threads(uint n) comp_thread_ctxt_t *threads; uint i; - threads = (comp_thread_ctxt_t *) - my_malloc(sizeof(comp_thread_ctxt_t) * n, MYF(MY_FAE)); + threads = (comp_thread_ctxt_t *) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(comp_thread_ctxt_t) * n, MYF(MY_FAE)); for (i = 0; i < n; i++) { comp_thread_ctxt_t *thd = threads + i; @@ -347,9 +345,8 @@ create_worker_threads(uint n) thd->cancelled = FALSE; thd->data_avail = FALSE; - thd->to = (char *) my_malloc(COMPRESS_CHUNK_SIZE + - MY_QLZ_COMPRESS_OVERHEAD, - MYF(MY_FAE)); + thd->to = (char *) my_malloc(PSI_NOT_INSTRUMENTED, + COMPRESS_CHUNK_SIZE + MY_QLZ_COMPRESS_OVERHEAD, MYF(MY_FAE)); /* Initialize the control mutex and condition var */ if (pthread_mutex_init(&thd->ctrl_mutex, NULL) || diff --git a/extra/mariabackup/ds_local.cc b/extra/mariabackup/ds_local.cc index fb2ea0a1629..06b061f3646 100644 --- a/extra/mariabackup/ds_local.cc +++ b/extra/mariabackup/ds_local.cc @@ -69,9 +69,9 @@ local_init(const char *root) return NULL; } - ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t), MYF(MY_FAE)); + ctxt = (ds_ctxt_t *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(ds_ctxt_t), MYF(MY_FAE)); - ctxt->root = my_strdup(root, MYF(MY_FAE)); + ctxt->root = my_strdup(PSI_NOT_INSTRUMENTED, root, MYF(MY_FAE)); return ctxt; } @@ -109,7 +109,7 @@ local_open(ds_ctxt_t *ctxt, const char *path, path_len = strlen(fullpath) + 1; /* terminating '\0' */ - file = (ds_file_t *) my_malloc(sizeof(ds_file_t) + + file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(ds_file_t) + sizeof(ds_local_file_t) + path_len, MYF(MY_FAE)); diff --git a/extra/mariabackup/ds_stdout.cc b/extra/mariabackup/ds_stdout.cc index 85dbb83865b..d30c105d258 100644 --- a/extra/mariabackup/ds_stdout.cc +++ b/extra/mariabackup/ds_stdout.cc @@ -49,9 +49,9 @@ stdout_init(const char *root) { ds_ctxt_t *ctxt; - ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t), MYF(MY_FAE)); + ctxt = (ds_ctxt_t *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(ds_ctxt_t), MYF(MY_FAE)); - ctxt->root = my_strdup(root, MYF(MY_FAE)); + ctxt->root = my_strdup(PSI_NOT_INSTRUMENTED, root, MYF(MY_FAE)); return ctxt; } @@ -69,10 +69,8 @@ stdout_open(ds_ctxt_t *ctxt __attribute__((unused)), pathlen = strlen(fullpath) + 1; - file = (ds_file_t *) my_malloc(sizeof(ds_file_t) + - sizeof(ds_stdout_file_t) + - pathlen, - MYF(MY_FAE)); + file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(ds_file_t) + + sizeof(ds_stdout_file_t) + pathlen, MYF(MY_FAE)); stdout_file = (ds_stdout_file_t *) (file + 1); diff --git a/extra/mariabackup/ds_tmpfile.cc b/extra/mariabackup/ds_tmpfile.cc index 22dff165aa0..4851c2f0263 100644 --- a/extra/mariabackup/ds_tmpfile.cc +++ b/extra/mariabackup/ds_tmpfile.cc @@ -61,8 +61,8 @@ tmpfile_init(const char *root) ds_ctxt_t *ctxt; ds_tmpfile_ctxt_t *tmpfile_ctxt; - ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_tmpfile_ctxt_t), - MYF(MY_FAE)); + ctxt = (ds_ctxt_t *)my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(ds_ctxt_t) + sizeof(ds_tmpfile_ctxt_t), MYF(MY_FAE)); tmpfile_ctxt = (ds_tmpfile_ctxt_t *) (ctxt + 1); tmpfile_ctxt->file_list = NULL; if (pthread_mutex_init(&tmpfile_ctxt->mutex, NULL)) { @@ -72,7 +72,7 @@ tmpfile_init(const char *root) } ctxt->ptr = tmpfile_ctxt; - ctxt->root = my_strdup(root, MYF(MY_FAE)); + ctxt->root = my_strdup(PSI_NOT_INSTRUMENTED, root, MYF(MY_FAE)); return ctxt; } @@ -100,9 +100,8 @@ tmpfile_open(ds_ctxt_t *ctxt, const char *path, path_len = strlen(path) + 1; /* terminating '\0' */ - file = (ds_file_t *) my_malloc(sizeof(ds_file_t) + - sizeof(ds_tmp_file_t) + path_len, - MYF(MY_FAE)); + file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(ds_file_t) + sizeof(ds_tmp_file_t) + path_len, MYF(MY_FAE)); tmp_file = (ds_tmp_file_t *) (file + 1); tmp_file->file = file; @@ -114,7 +113,7 @@ tmpfile_open(ds_ctxt_t *ctxt, const char *path, memcpy(tmp_file->orig_path, path, path_len); /* Store the real temporary file name in file->path */ - file->path = my_strdup(tmp_path, MYF(MY_FAE)); + file->path = my_strdup(PSI_NOT_INSTRUMENTED, tmp_path, MYF(MY_FAE)); file->ptr = tmp_file; /* Store the file object in the list to be piped later */ @@ -170,7 +169,7 @@ tmpfile_deinit(ds_ctxt_t *ctxt) pipe_ctxt = ctxt->pipe_ctxt; xb_a(pipe_ctxt != NULL); - buf = my_malloc(buf_size, MYF(MY_FAE)); + buf = my_malloc(PSI_NOT_INSTRUMENTED, buf_size, MYF(MY_FAE)); tmpfile_ctxt = (ds_tmpfile_ctxt_t *) ctxt->ptr; list = tmpfile_ctxt->file_list; diff --git a/extra/mariabackup/ds_xbstream.cc b/extra/mariabackup/ds_xbstream.cc index 5a753b08474..7522510ab27 100644 --- a/extra/mariabackup/ds_xbstream.cc +++ b/extra/mariabackup/ds_xbstream.cc @@ -79,8 +79,8 @@ xbstream_init(const char *root __attribute__((unused))) ds_stream_ctxt_t *stream_ctxt; xb_wstream_t *xbstream; - ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_stream_ctxt_t), - MYF(MY_FAE)); + ctxt = (ds_ctxt_t *)my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(ds_ctxt_t) + sizeof(ds_stream_ctxt_t), MYF(MY_FAE)); stream_ctxt = (ds_stream_ctxt_t *)(ctxt + 1); if (pthread_mutex_init(&stream_ctxt->mutex, NULL)) { @@ -131,9 +131,8 @@ xbstream_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat) } pthread_mutex_unlock(&stream_ctxt->mutex); - file = (ds_file_t *) my_malloc(sizeof(ds_file_t) + - sizeof(ds_stream_file_t), - MYF(MY_FAE)); + file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(ds_file_t) + sizeof(ds_stream_file_t), MYF(MY_FAE)); stream_file = (ds_stream_file_t *) (file + 1); xbstream = stream_ctxt->xbstream; diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index 453aab802c9..8f06005a9e4 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -142,7 +142,7 @@ xb_fil_cur_open( int err; /* Initialize these first so xb_fil_cur_close() handles them correctly in case of error */ - cursor->orig_buf = NULL; + cursor->buf = NULL; cursor->node = NULL; cursor->space_id = node->space->id; @@ -238,10 +238,8 @@ xb_fil_cur_open( /* Allocate read buffer */ cursor->buf_size = XB_FIL_CUR_PAGES * cursor->page_size; - cursor->orig_buf = static_cast<byte *> - (malloc(cursor->buf_size + srv_page_size)); - cursor->buf = static_cast<byte *> - (ut_align(cursor->orig_buf, srv_page_size)); + cursor->buf = static_cast<byte*>(aligned_malloc(cursor->buf_size, + srv_page_size)); cursor->buf_read = 0; cursor->buf_npages = 0; @@ -278,7 +276,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no, byte tmp_frame[UNIV_PAGE_SIZE_MAX]; byte tmp_page[UNIV_PAGE_SIZE_MAX]; const ulint page_size = cursor->page_size; - ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE); + uint16_t page_type = fil_page_get_type(page); /* We ignore the doublewrite buffer pages.*/ if (cursor->space_id == TRX_SYS_SPACE @@ -361,7 +359,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no, || page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { ulint decomp = fil_page_decompress(tmp_frame, tmp_page, space->flags); - page_type = mach_read_from_2(tmp_page + FIL_PAGE_TYPE); + page_type = fil_page_get_type(tmp_page); return (!decomp || (decomp != srv_page_size @@ -494,7 +492,8 @@ xb_fil_cur_close( cursor->read_filter->deinit(&cursor->read_filter_ctxt); } - free(cursor->orig_buf); + aligned_free(cursor->buf); + cursor->buf = NULL; if (cursor->node != NULL) { xb_fil_node_close_file(cursor->node); diff --git a/extra/mariabackup/fil_cur.h b/extra/mariabackup/fil_cur.h index b789efde05f..70e4888ba63 100644 --- a/extra/mariabackup/fil_cur.h +++ b/extra/mariabackup/fil_cur.h @@ -44,8 +44,7 @@ struct xb_fil_cur_t { xb_read_filt_t* read_filter; /*!< read filter */ xb_read_filt_ctxt_t read_filter_ctxt; /*!< read filter context */ - byte* orig_buf; /*!< read buffer */ - byte* buf; /*!< aligned pointer for orig_buf */ + byte* buf; /*!< read buffer */ size_t buf_size; /*!< buffer size in bytes */ size_t buf_read; /*!< number of read bytes in buffer after the last cursor read */ diff --git a/extra/mariabackup/innobackupex.cc b/extra/mariabackup/innobackupex.cc index f0e9c06b355..319399b97c5 100644 --- a/extra/mariabackup/innobackupex.cc +++ b/extra/mariabackup/innobackupex.cc @@ -728,11 +728,10 @@ indicates an error.\n"); static my_bool -ibx_get_one_option(int optid, - const struct my_option *opt __attribute__((unused)), - char *argument) +ibx_get_one_option(const struct my_option *opt, + char *argument, const char *) { - switch(optid) { + switch(opt->id) { case '?': usage(); exit(0); @@ -775,7 +774,8 @@ ibx_get_one_option(int optid, { char *start = argument; my_free(opt_ibx_password); - opt_ibx_password= my_strdup(argument, MYF(MY_FAE)); + opt_ibx_password= my_strdup(PSI_NOT_INSTRUMENTED, + argument, MYF(MY_FAE)); /* Destroy argument */ while (*argument) *argument++= 'x'; diff --git a/extra/mariabackup/write_filt.cc b/extra/mariabackup/write_filt.cc index 09470384684..8c4d2345f91 100644 --- a/extra/mariabackup/write_filt.cc +++ b/extra/mariabackup/write_filt.cc @@ -76,7 +76,7 @@ wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name, /* allocate buffer for incremental backup (4096 pages) */ cp->delta_buf_size = (cursor->page_size / 4) * cursor->page_size; - cp->delta_buf = (unsigned char *)os_mem_alloc_large(&cp->delta_buf_size); + cp->delta_buf = (unsigned char *)my_large_malloc(&cp->delta_buf_size, MYF(0)); if (!cp->delta_buf) { msg(cursor->thread_n,"Can't allocate %zu bytes", @@ -185,7 +185,7 @@ static void wf_incremental_deinit(xb_write_filt_ctxt_t *ctxt) { xb_wf_incremental_ctxt_t *cp = &(ctxt->u.wf_incremental_ctxt); - os_mem_free_large(cp->delta_buf, cp->delta_buf_size); + my_large_free(cp->delta_buf, cp->delta_buf_size); } /************************************************************************ diff --git a/extra/mariabackup/xb_regex.h b/extra/mariabackup/xb_regex.h index 9b8f5789eeb..8f2f0908658 100644 --- a/extra/mariabackup/xb_regex.h +++ b/extra/mariabackup/xb_regex.h @@ -25,7 +25,8 @@ my_regex is used on Windows and native calls are used on POSIX platforms. */ #ifdef HAVE_SYSTEM_REGEX #include <regex.h> #else -#include <pcreposix.h> +#define PCRE2_STATIC 1 /* Important on Windows */ +#include <pcre2posix.h> #endif typedef regex_t* xb_regex_t; diff --git a/extra/mariabackup/xbstream.cc b/extra/mariabackup/xbstream.cc index 1655b69235c..ba55141cdd9 100644 --- a/extra/mariabackup/xbstream.cc +++ b/extra/mariabackup/xbstream.cc @@ -90,8 +90,8 @@ typedef struct { static int get_options(int *argc, char ***argv); static int mode_create(int argc, char **argv); static int mode_extract(int n_threads, int argc, char **argv); -static my_bool get_one_option(int optid, const struct my_option *opt, - char *argument); +static my_bool get_one_option(const struct my_option *opt, + char *argument, const char *filename); int main(int argc, char **argv) @@ -194,10 +194,9 @@ set_run_mode(run_mode_t mode) static my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument __attribute__((unused))) +get_one_option(const struct my_option *opt, char *, const char *) { - switch (optid) { + switch (opt->id) { case 'c': if (set_run_mode(RUN_MODE_CREATE)) { return TRUE; @@ -227,7 +226,7 @@ stream_one_file(File file, xb_wstream_file_t *xbfile) posix_fadvise(file, 0, 0, POSIX_FADV_SEQUENTIAL); offset = my_tell(file, MYF(MY_WME)); - buf = (uchar*)(my_malloc(XBSTREAM_BUFFER_SIZE, MYF(MY_FAE))); + buf = (uchar*)(my_malloc(PSI_NOT_INSTRUMENTED, XBSTREAM_BUFFER_SIZE, MYF(MY_FAE))); while ((bytes = (ssize_t)my_read(file, buf, XBSTREAM_BUFFER_SIZE, MYF(MY_WME))) > 0) { @@ -322,13 +321,13 @@ file_entry_new(extract_ctxt_t *ctxt, const char *path, uint pathlen) file_entry_t *entry; ds_file_t *file; - entry = (file_entry_t *) my_malloc(sizeof(file_entry_t), + entry = (file_entry_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(file_entry_t), MYF(MY_WME | MY_ZEROFILL)); if (entry == NULL) { return NULL; } - entry->path = my_strndup(path, pathlen, MYF(MY_WME)); + entry->path = my_strndup(PSI_NOT_INSTRUMENTED, path, pathlen, MYF(MY_WME)); if (entry->path == NULL) { goto err; } @@ -496,8 +495,8 @@ mode_extract(int n_threads, int argc __attribute__((unused)), pthread_mutex_t mutex; int ret = 0; - if (my_hash_init(&filehash, &my_charset_bin, START_FILE_HASH_SIZE, - 0, 0, (my_hash_get_key) get_file_entry_key, + if (my_hash_init(PSI_NOT_INSTRUMENTED, &filehash, &my_charset_bin, + START_FILE_HASH_SIZE, 0, 0, (my_hash_get_key) get_file_entry_key, (my_hash_free_key) file_entry_free, MYF(0))) { msg("%s: failed to initialize file hash.", my_progname); return 1; diff --git a/extra/mariabackup/xbstream_read.cc b/extra/mariabackup/xbstream_read.cc index ff13800fd94..3880dd50ed5 100644 --- a/extra/mariabackup/xbstream_read.cc +++ b/extra/mariabackup/xbstream_read.cc @@ -42,7 +42,7 @@ xb_stream_read_new(void) { xb_rstream_t *stream; - stream = (xb_rstream_t *) my_malloc(sizeof(xb_rstream_t), MYF(MY_FAE)); + stream = (xb_rstream_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(xb_rstream_t), MYF(MY_FAE)); #ifdef __WIN__ setmode(fileno(stdin), _O_BINARY); @@ -190,7 +190,7 @@ xb_stream_read_chunk(xb_rstream_t *stream, xb_rstream_chunk_t *chunk) /* Reallocate the buffer if needed */ if (chunk->length > chunk->buflen) { - chunk->data = my_realloc(chunk->data, chunk->length, + chunk->data = my_realloc(PSI_NOT_INSTRUMENTED, chunk->data, chunk->length, MYF(MY_WME | MY_ALLOW_ZERO_PTR)); if (chunk->data == NULL) { msg("xb_stream_read_chunk(): failed to increase buffer " diff --git a/extra/mariabackup/xbstream_write.cc b/extra/mariabackup/xbstream_write.cc index fcf92f40acd..b6fd9c294a5 100644 --- a/extra/mariabackup/xbstream_write.cc +++ b/extra/mariabackup/xbstream_write.cc @@ -65,7 +65,7 @@ xb_stream_write_new(void) { xb_wstream_t *stream; - stream = (xb_wstream_t *) my_malloc(sizeof(xb_wstream_t), MYF(MY_FAE)); + stream = (xb_wstream_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(xb_wstream_t), MYF(MY_FAE)); pthread_mutex_init(&stream->mutex, NULL); return stream;; @@ -87,7 +87,7 @@ xb_stream_write_open(xb_wstream_t *stream, const char *path, return NULL; } - file = (xb_wstream_file_t *) my_malloc(sizeof(xb_wstream_file_t) + + file = (xb_wstream_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(xb_wstream_file_t) + path_len + 1, MYF(MY_FAE)); file->path = (char *) (file + 1); diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 0a06052d19b..04b47c12e0a 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -104,6 +104,7 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA #include <crc_glue.h> #include <log.h> #include <derror.h> +#include <thr_timer.h> int sys_var_init(); @@ -121,8 +122,6 @@ my_bool xtrabackup_print_param; my_bool xtrabackup_export; -my_bool xtrabackup_rollback_xa; - longlong xtrabackup_use_memory; uint opt_protocol; @@ -231,8 +230,8 @@ parameters are declared in mysqld.cc: */ long innobase_buffer_pool_awe_mem_mb = 0; long innobase_file_io_threads = 4; -long innobase_read_io_threads = 4; -long innobase_write_io_threads = 4; +ulong innobase_read_io_threads = 4; +ulong innobase_write_io_threads = 4; longlong innobase_page_size = (1LL << 14); /* 16KB */ char* innobase_buffer_pool_filename = NULL; @@ -244,12 +243,6 @@ static char* innobase_ignored_opt; char* innobase_data_home_dir; char* innobase_data_file_path; -my_bool innobase_use_doublewrite; -my_bool innobase_file_per_table; -my_bool innobase_locks_unsafe_for_binlog; -my_bool innobase_rollback_on_timeout; -my_bool innobase_create_status_file; - /* The following counter is used to convey information to InnoDB about server activity: in selects it is not sensible to call srv_active_wake_master_thread after each fetch or search, we only do @@ -355,8 +348,6 @@ typedef std::map<space_id_t,std::string> space_id_to_name_t; struct ddl_tracker_t { /** Tablspaces with their ID and name, as they were copied to backup.*/ space_id_to_name_t tables_in_backup; - /** Tablespaces for that optimized DDL without redo log was found.*/ - std::set<space_id_t> optimized_ddl; /** Drop operations found in redo log. */ std::set<space_id_t> drops; /* For DDL operation found in redo log, */ @@ -595,26 +586,25 @@ std::string filename_to_spacename(const byte *filename, size_t len) /** Report an operation to create, delete, or rename a file during backup. @param[in] space_id tablespace identifier -@param[in] flags tablespace flags (NULL if not create) +@param[in] create whether the file is being created @param[in] name file name (not NUL-terminated) @param[in] len length of name, in bytes @param[in] new_name new file name (NULL if not rename) @param[in] new_len length of new_name, in bytes (0 if NULL) */ -static void backup_file_op(ulint space_id, const byte* flags, +static void backup_file_op(ulint space_id, bool create, const byte* name, ulint len, const byte* new_name, ulint new_len) { - ut_ad(!flags || !new_name); + ut_ad(!create || !new_name); ut_ad(name); ut_ad(len); ut_ad(!new_name == !new_len); pthread_mutex_lock(&backup_mutex); - if (flags) { + if (create) { ddl_tracker.id_to_name[space_id] = filename_to_spacename(name, len); - msg("DDL tracking : create %zu \"%.*s\": %x", - space_id, int(len), name, mach_read_from_4(flags)); + msg("DDL tracking : create %zu \"%.*s\"", space_id, int(len), name); } else if (new_name) { ddl_tracker.id_to_name[space_id] = filename_to_spacename(new_name, new_len); @@ -637,14 +627,14 @@ static void backup_file_op(ulint space_id, const byte* flags, We will abort backup in this case. */ -static void backup_file_op_fail(ulint space_id, const byte* flags, +static void backup_file_op_fail(ulint space_id, bool create, const byte* name, ulint len, const byte* new_name, ulint new_len) { bool fail; - if (flags) { - msg("DDL tracking : create %zu \"%.*s\": %x", - space_id, int(len), name, mach_read_from_4(flags)); + if (create) { + msg("DDL tracking : create %zu \"%.*s\"", + space_id, int(len), name); std::string spacename = filename_to_spacename(name, len); fail = !check_if_skip_table(spacename.c_str()); } @@ -668,30 +658,6 @@ static void backup_file_op_fail(ulint space_id, const byte* flags, } -/** Callback whenever MLOG_INDEX_LOAD happens. -@param[in] space_id space id to check */ -static void backup_optimized_ddl_op(ulint space_id) -{ - pthread_mutex_lock(&backup_mutex); - ddl_tracker.optimized_ddl.insert(space_id); - pthread_mutex_unlock(&backup_mutex); -} - -/* - Optimized DDL callback at the end of backup that - run with --no-lock. Usually aborts the backup. -*/ -static void backup_optimized_ddl_op_fail(ulint space_id) { - msg("DDL tracking : optimized DDL on space %zu", space_id); - if (ddl_tracker.tables_in_backup.find(space_id) != ddl_tracker.tables_in_backup.end()) { - ut_a(opt_no_lock); - msg("ERROR : Optimized DDL operation detected in the late phase of backup." - "Backup is inconsistent. Remove --no-lock option to fix."); - exit(EXIT_FAILURE); - } -} - - /* Retrieve default data directory, to be used with --copy-back. @@ -743,7 +709,6 @@ enum options_xtrabackup OPT_XTRA_BACKUP, OPT_XTRA_PREPARE, OPT_XTRA_EXPORT, - OPT_XTRA_ROLLBACK_XA, OPT_XTRA_PRINT_PARAM, OPT_XTRA_USE_MEMORY, OPT_XTRA_THROTTLE, @@ -856,12 +821,6 @@ struct my_option xb_client_options[]= { "create files to import to another database when prepare.", (G_PTR *) &xtrabackup_export, (G_PTR *) &xtrabackup_export, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"rollback-xa", OPT_XTRA_ROLLBACK_XA, - "Rollback prepared XA's on --prepare. " - "After preparing target directory with this option " - "it can no longer be a base for incremental backup.", - (G_PTR *) &xtrabackup_rollback_xa, (G_PTR *) &xtrabackup_rollback_xa, 0, - GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"print-param", OPT_XTRA_PRINT_PARAM, "print parameter of mysqld needed for copyback.", (G_PTR *) &xtrabackup_print_param, (G_PTR *) &xtrabackup_print_param, 0, @@ -1243,6 +1202,10 @@ uint xb_client_options_count = array_elements(xb_client_options); static const char *dbug_option; #endif +namespace deprecated { +extern ulong srv_n_log_files; +} + struct my_option xb_server_options[] = { {"datadir", 'h', "Path to the database root.", (G_PTR*) &mysql_data_home, @@ -1291,11 +1254,10 @@ struct my_option xb_server_options[] = GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef BTR_CUR_HASH_ADAPT {"innodb_adaptive_hash_index", OPT_INNODB_ADAPTIVE_HASH_INDEX, - "Enable InnoDB adaptive hash index (enabled by default). " - "Disable with --skip-innodb-adaptive-hash-index.", + "Enable InnoDB adaptive hash index (disabled by default).", &btr_search_enabled, &btr_search_enabled, - 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif /* BTR_CUR_HASH_ADAPT */ {"innodb_autoextend_increment", OPT_INNODB_AUTOEXTEND_INCREMENT, "Data file autoextend increment in megabytes", @@ -1310,8 +1272,8 @@ struct my_option xb_server_options[] = &innobase_data_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"innodb_doublewrite", OPT_INNODB_DOUBLEWRITE, "Enable InnoDB doublewrite buffer during --prepare.", - (G_PTR*) &innobase_use_doublewrite, - (G_PTR*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (G_PTR*) &srv_use_doublewrite_buf, + (G_PTR*) &srv_use_doublewrite_buf, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY, "Number of IOPs the server can do. Tunes the background IO rate", (G_PTR*) &srv_io_capacity, (G_PTR*) &srv_io_capacity, @@ -1330,8 +1292,8 @@ struct my_option xb_server_options[] = 1, 0}, {"innodb_file_per_table", OPT_INNODB_FILE_PER_TABLE, "Stores each InnoDB table to an .ibd file in the database dir.", - (G_PTR*) &innobase_file_per_table, - (G_PTR*) &innobase_file_per_table, 0, GET_BOOL, NO_ARG, + (G_PTR*) &srv_file_per_table, + (G_PTR*) &srv_file_per_table, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0}, {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD, @@ -1347,11 +1309,12 @@ struct my_option xb_server_options[] = {"innodb_log_file_size", OPT_INNODB_LOG_FILE_SIZE, "Ignored for mysqld option compatibility", (G_PTR*) &srv_log_file_size, (G_PTR*) &srv_log_file_size, 0, - GET_ULL, REQUIRED_ARG, 48 << 20, 1 << 20, log_group_max_size, 0, + GET_ULL, REQUIRED_ARG, 48 << 20, 1 << 20, + std::numeric_limits<ulonglong>::max(), 0, UNIV_PAGE_SIZE_MAX, 0}, {"innodb_log_files_in_group", OPT_INNODB_LOG_FILES_IN_GROUP, "Ignored for mysqld option compatibility", - &srv_n_log_files, &srv_n_log_files, + &deprecated::srv_n_log_files, &deprecated::srv_n_log_files, 0, GET_LONG, REQUIRED_ARG, 1, 1, 100, 0, 1, 0}, {"innodb_log_group_home_dir", OPT_INNODB_LOG_GROUP_HOME_DIR, "Path to InnoDB log files.", &srv_log_group_home_dir, @@ -1420,11 +1383,6 @@ struct my_option xb_server_options[] = &xb_plugin_dir, &xb_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, - {"innodb-log-checksums", OPT_INNODB_LOG_CHECKSUMS, - "Whether to require checksums for InnoDB redo log blocks", - &innodb_log_checksums, &innodb_log_checksums, - 0, GET_BOOL, REQUIRED_ARG, 1, 0, 0, 0, 0, 0 }, - {"open_files_limit", OPT_OPEN_FILES_LIMIT, "the maximum number of file " "descriptors to reserve with setrlimit().", (G_PTR*) &xb_open_files_limit, (G_PTR*) &xb_open_files_limit, 0, GET_ULONG, @@ -1606,9 +1564,9 @@ static int prepare_export() outf= popen(cmdline,"r"); if (!outf) goto end; - + char outline[FN_REFLEN]; - while(fgets(outline, sizeof(outline)-1, outf)) + while (fgets(outline, FN_REFLEN - 1, outf)) fprintf(stderr,"%s",outline); err = pclose(outf); @@ -1685,11 +1643,10 @@ check_if_param_set(const char *param) } my_bool -xb_get_one_option(int optid, - const struct my_option *opt __attribute__((unused)), - char *argument) +xb_get_one_option(const struct my_option *opt, + char *argument, const char *) { - switch(optid) { + switch(opt->id) { case 'h': strmake(mysql_real_data_home,argument, FN_REFLEN - 1); mysql_data_home= mysql_real_data_home; @@ -1802,7 +1759,7 @@ xb_get_one_option(int optid, { char *start= argument; my_free(opt_password); - opt_password= my_strdup(argument, MYF(MY_FAE)); + opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); while (*argument) *argument++= 'x'; // Destroy argument if (*start) start[1]=0 ; @@ -1961,23 +1918,12 @@ static bool innodb_init_param() srv_buf_pool_size = (ulint) xtrabackup_use_memory; srv_buf_pool_chunk_unit = (ulong)srv_buf_pool_size; - srv_buf_pool_instances = 1; - srv_n_page_cleaners = 1; srv_n_file_io_threads = (ulint) innobase_file_io_threads; - srv_n_read_io_threads = (ulint) innobase_read_io_threads; - srv_n_write_io_threads = (ulint) innobase_write_io_threads; - - srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite; - - row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout; - - srv_file_per_table = (my_bool) innobase_file_per_table; - - srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog; + srv_n_read_io_threads = innobase_read_io_threads; + srv_n_write_io_threads = innobase_write_io_threads; srv_max_n_open_files = ULINT_UNDEFINED - 5; - srv_innodb_status = (ibool) innobase_create_status_file; srv_print_verbose_log = verbose ? 2 : 1; @@ -2015,10 +1961,6 @@ static bool innodb_init_param() srv_undo_dir = (char*) "."; } - log_checksum_algorithm_ptr = innodb_log_checksums || srv_encrypt_log - ? log_block_calc_checksum_crc32 - : log_block_calc_checksum_none; - #ifdef _WIN32 srv_use_native_aio = TRUE; #endif @@ -2740,12 +2682,9 @@ static lsn_t xtrabackup_copy_log(lsn_t start_lsn, lsn_t end_lsn, bool last) } } - store_t store = STORE_NO; - - if (more_data && recv_parse_log_recs(0, &store, 0, false)) { - + store_t store= STORE_NO; + if (more_data && recv_sys.parse(0, &store, false)) { msg("Error: copying the log failed"); - return(0); } @@ -2861,7 +2800,7 @@ static os_thread_ret_t DECLARE_THREAD(log_copying_thread)(void*) for (;;) { os_event_reset(log_copying_stop); os_event_wait_time_low(log_copying_stop, - xtrabackup_log_copy_interval * 1000ULL, + xtrabackup_log_copy_interval * 1000U, 0); if (xtrabackup_copy_logfile()) { break; @@ -2989,7 +2928,7 @@ Initialize the appropriate datasink(s). Both local backups and streaming in the Otherwise (i.e. when streaming in the 'tar' format) we need 2 separate datasinks for the data stream (and don't allow parallel data copying) and for metainfo -files (including ib_logfile0). The second datasink writes to temporary +files (including LOG_FILE_NAME). The second datasink writes to temporary files first, and then streams them in a serialized way when closed. */ static void xtrabackup_init_datasinks(void) @@ -3336,8 +3275,6 @@ static dberr_t xb_assign_undo_space_start() { pfs_os_file_t file; - byte* buf; - byte* page; bool ret; dberr_t error = DB_SUCCESS; ulint space; @@ -3356,8 +3293,8 @@ static dberr_t xb_assign_undo_space_start() return DB_ERROR; } - buf = static_cast<byte*>(ut_malloc_nokey(2U << srv_page_size_shift)); - page = static_cast<byte*>(ut_align(buf, srv_page_size)); + byte* page = static_cast<byte*> + (aligned_malloc(srv_page_size, srv_page_size)); if (os_file_read(IORequestRead, file, page, 0, srv_page_size) != DB_SUCCESS) { @@ -3404,7 +3341,7 @@ retry: srv_undo_space_id_start = space; func_exit: - ut_free(buf); + aligned_free(page); ret = os_file_close(file); ut_a(ret); @@ -3860,58 +3797,23 @@ xb_filters_free() } } -/*********************************************************************//** -Create log file metadata. */ -static -void -open_or_create_log_file( -/*====================*/ - fil_space_t* space, - ulint i) /*!< in: log file number in group */ -{ - char name[FN_REFLEN]; - ulint dirnamelen; - - os_normalize_path(srv_log_group_home_dir); - - dirnamelen = strlen(srv_log_group_home_dir); - ut_a(dirnamelen < (sizeof name) - 10 - sizeof "ib_logfile"); - memcpy(name, srv_log_group_home_dir, dirnamelen); - - /* Add a path separator if needed. */ - if (dirnamelen && name[dirnamelen - 1] != OS_PATH_SEPARATOR) { - name[dirnamelen++] = OS_PATH_SEPARATOR; - } - - sprintf(name + dirnamelen, "%s%zu", "ib_logfile", i); - - ut_a(fil_validate()); - - space->add(name, OS_FILE_CLOSED, - ulint(srv_log_file_size >> srv_page_size_shift), - false, false); -} - -/*********************************************************************** +#ifdef RLIMIT_NOFILE +/** Set the open files limit. Based on set_max_open_files(). - +@param max_file_limit requested open files limit @return the resulting open files limit. May be less or more than the requested value. */ -static uint -xb_set_max_open_files( -/*==================*/ - uint max_file_limit) /*!<in: open files limit */ +static ulong xb_set_max_open_files(rlim_t max_file_limit) { -#if defined(RLIMIT_NOFILE) struct rlimit rlimit; - uint old_cur; + rlim_t old_cur; if (getrlimit(RLIMIT_NOFILE, &rlimit)) { goto end; } - old_cur = (uint) rlimit.rlim_cur; + old_cur = rlimit.rlim_cur; if (rlimit.rlim_cur == RLIM_INFINITY) { @@ -3927,8 +3829,8 @@ xb_set_max_open_files( rlimit.rlim_cur = rlimit.rlim_max = max_file_limit; if (setrlimit(RLIMIT_NOFILE, &rlimit)) { - - max_file_limit = old_cur; /* Use original value */ + /* Use original value */ + max_file_limit = static_cast<ulong>(old_cur); } else { rlimit.rlim_cur = 0; /* Safety if next call fails */ @@ -3938,16 +3840,16 @@ xb_set_max_open_files( if (rlimit.rlim_cur) { /* If call didn't fail */ - max_file_limit = (uint) rlimit.rlim_cur; + max_file_limit = rlimit.rlim_cur; } } end: - return(max_file_limit); + return static_cast<ulong>(max_file_limit); +} #else - return(0); +# define xb_set_max_open_files(x) 0UL #endif -} static void stop_backup_threads() { @@ -3988,7 +3890,9 @@ static bool xtrabackup_backup_low() if (recv_find_max_checkpoint(&max_cp_field) == DB_SUCCESS && log_sys.log.format != 0) { if (max_cp_field == LOG_CHECKPOINT_1) { - log_header_read(max_cp_field); + log_sys.log.read(max_cp_field, + {log_sys.checkpoint_buf, + OS_FILE_LOG_BLOCK_SIZE}); } metadata_to_lsn = mach_read_from_8( log_sys.checkpoint_buf + LOG_CHECKPOINT_LSN); @@ -4076,8 +3980,8 @@ static bool xtrabackup_backup_func() } msg("cd to %s", mysql_real_data_home); encryption_plugin_backup_init(mysql_connection); - msg("open files limit requested %u, set to %u", - (uint) xb_open_files_limit, + msg("open files limit requested %lu, set to %lu", + xb_open_files_limit, xb_set_max_open_files(xb_open_files_limit)); mysql_data_home= mysql_data_home_buff; @@ -4123,11 +4027,10 @@ fail: especially in 64-bit computers */ } - + srv_thread_pool_init(); sync_check_init(); ut_d(sync_check_enable()); /* Reset the system variables in the recovery module. */ - recv_sys_var_init(); trx_pool_init(); ut_crc32_init(); @@ -4148,14 +4051,8 @@ fail: SRV_MAX_N_PENDING_SYNC_IOS); log_sys.create(); - log_sys.log.create(srv_n_log_files); - fil_space_t* space = fil_space_create( - "innodb_redo_log", SRV_LOG_SPACE_FIRST_ID, 0, - FIL_TYPE_LOG, NULL); - - for (ulint i = 0; i < srv_n_log_files; i++) { - open_or_create_log_file(space, i); - } + log_sys.log.create(); + log_sys.log.open_file(get_log_file_path()); /* create extra LSN dir if it does not exist. */ if (xtrabackup_extra_lsndir @@ -4201,11 +4098,11 @@ reread_log_header: goto fail; } - const byte* buf = log_sys.checkpoint_buf; + byte* buf = log_sys.checkpoint_buf; checkpoint_lsn_start = log_sys.log.get_lsn(); checkpoint_no_start = log_sys.next_checkpoint_no; - log_header_read(max_cp_field); + log_sys.log.read(max_cp_field, {buf, OS_FILE_LOG_BLOCK_SIZE}); if (checkpoint_no_start != mach_read_from_8(buf + LOG_CHECKPOINT_NO) || checkpoint_lsn_start @@ -4224,10 +4121,10 @@ reread_log_header: /* open the log file */ memset(&stat_info, 0, sizeof(MY_STAT)); - dst_log_file = ds_open(ds_redo, "ib_logfile0", &stat_info); + dst_log_file = ds_open(ds_redo, LOG_FILE_NAME, &stat_info); if (dst_log_file == NULL) { - msg("Error: failed to open the target stream for " - "'ib_logfile0'."); + msg("Error: failed to open the target stream for '%s'.", + LOG_FILE_NAME); goto fail; } @@ -4248,7 +4145,7 @@ reread_log_header: log_hdr_field += (log_sys.next_checkpoint_no & 1) ? LOG_CHECKPOINT_2 : LOG_CHECKPOINT_1; /* The least significant bits of LOG_CHECKPOINT_OFFSET must be - stored correctly in the copy of the ib_logfile. The most significant + stored correctly in the copy of the LOG_FILE_NAME. The most significant bits, which identify the start offset of the log block in the file, we did choose freely, as LOG_FILE_HDR_SIZE. */ ut_ad(!((log_sys.log.get_lsn() ^ checkpoint_lsn_start) @@ -4293,7 +4190,6 @@ fail_before_log_copying_thread_start: /* copy log file by current position */ log_copy_scanned_lsn = checkpoint_lsn_start; recv_sys.recovered_lsn = log_copy_scanned_lsn; - log_optimized_ddl_op = backup_optimized_ddl_op; if (xtrabackup_copy_logfile()) goto fail_before_log_copying_thread_start; @@ -4438,7 +4334,6 @@ void backup_fix_ddl(void) /* Disable further DDL on backed up tables (only needed for --no-lock).*/ pthread_mutex_lock(&backup_mutex); log_file_op = backup_file_op_fail; - log_optimized_ddl_op = backup_optimized_ddl_op_fail; pthread_mutex_unlock(&backup_mutex); DBUG_MARIABACKUP_EVENT("backup_fix_ddl",0); @@ -4455,32 +4350,14 @@ void backup_fix_ddl(void) continue; } - bool has_optimized_ddl = - ddl_tracker.optimized_ddl.find(id) != ddl_tracker.optimized_ddl.end(); - if (ddl_tracker.id_to_name.find(id) == ddl_tracker.id_to_name.end()) { - if (has_optimized_ddl) { - new_tables.insert(name); - } continue; } /* tablespace was affected by DDL. */ const std::string new_name = ddl_tracker.id_to_name[id]; if (new_name != name) { - if (has_optimized_ddl) { - /* table was renamed, but we need a full copy - of it because of optimized DDL. We emulate a drop/create.*/ - dropped_tables.insert(name); - new_tables.insert(new_name); - } else { - /* Renamed, and no optimized DDL*/ - renamed_tables[name] = new_name; - } - } else if (has_optimized_ddl) { - /* Table was recreated, or optimized DDL ran. - In both cases we need a full copy in the backup.*/ - new_tables.insert(name); + renamed_tables[name] = new_name; } } @@ -4624,8 +4501,6 @@ xb_space_create_file( pfs_os_file_t* file) /*!<out: file handle */ { bool ret; - byte* buf; - byte* page; *file = os_file_create_simple_no_error_handling( 0, path, OS_FILE_CREATE, OS_FILE_READ_WRITE, false, &ret); @@ -4644,9 +4519,9 @@ xb_space_create_file( return ret; } - buf = static_cast<byte *>(malloc(3U << srv_page_size_shift)); /* Align the memory for file i/o if we might have O_DIRECT set */ - page = static_cast<byte *>(ut_align(buf, srv_page_size)); + byte* page = static_cast<byte*>(aligned_malloc(2 * srv_page_size, + srv_page_size)); memset(page, '\0', srv_page_size); @@ -4657,7 +4532,7 @@ xb_space_create_file( if (!zip_size) { buf_flush_init_for_writing( - NULL, page, NULL, 0, + NULL, page, NULL, fil_space_t::full_crc32(flags)); ret = os_file_write(IORequestWrite, path, *file, page, 0, @@ -4669,18 +4544,19 @@ xb_space_create_file( fprintf(stderr, "zip_size = " ULINTPF "\n", zip_size); #ifdef UNIV_DEBUG - page_zip.m_start = + page_zip.m_start = 0; #endif /* UNIV_DEBUG */ - page_zip.m_end = page_zip.m_nonempty = - page_zip.n_blobs = 0; + page_zip.m_end = 0; + page_zip.m_nonempty = 0; + page_zip.n_blobs = 0; - buf_flush_init_for_writing(NULL, page, &page_zip, 0, false); + buf_flush_init_for_writing(NULL, page, &page_zip, false); ret = os_file_write(IORequestWrite, path, *file, page_zip.data, 0, zip_size); } - free(buf); + aligned_free(page); if (ret != DB_SUCCESS) { msg("mariabackup: could not write the first page to %s", @@ -4893,8 +4769,7 @@ xtrabackup_apply_delta( xb_delta_info_t info(srv_page_size, 0, SRV_TMP_SPACE_ID); ulint page_size; ulint page_size_shift; - byte* incremental_buffer_base = NULL; - byte* incremental_buffer; + byte* incremental_buffer = NULL; size_t offset; @@ -4962,11 +4837,8 @@ xtrabackup_apply_delta( posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED); /* allocate buffer for incremental backup (4096 pages) */ - incremental_buffer_base = static_cast<byte *> - (malloc((page_size / 4 + 1) * page_size)); incremental_buffer = static_cast<byte *> - (ut_align(incremental_buffer_base, - page_size)); + (aligned_malloc(page_size / 4 * page_size, page_size)); msg("Applying %s to %s...", src_path, dst_path); @@ -5075,7 +4947,7 @@ xtrabackup_apply_delta( incremental_buffers++; } - free(incremental_buffer_base); + aligned_free(incremental_buffer); if (src_file != OS_FILE_CLOSED) { os_file_close(src_file); os_file_delete(0,src_path); @@ -5085,7 +4957,7 @@ xtrabackup_apply_delta( return TRUE; error: - free(incremental_buffer_base); + aligned_free(incremental_buffer); if (src_file != OS_FILE_CLOSED) os_file_close(src_file); if (dst_file != OS_FILE_CLOSED) @@ -5520,7 +5392,6 @@ static bool xtrabackup_prepare_func(char** argv) } srv_max_n_threads = 1000; - srv_undo_logs = 1; srv_n_purge_threads = 1; xb_filters_init(); @@ -5540,7 +5411,7 @@ static bool xtrabackup_prepare_func(char** argv) ut_crc32_init(); recv_sys.create(); log_sys.create(); - recv_recovery_on = true; + recv_sys.recovery_on = true; #ifdef WITH_INNODB_DISALLOW_WRITES srv_allow_writes_event = os_event_create(0); @@ -5578,13 +5449,10 @@ static bool xtrabackup_prepare_func(char** argv) if (!ok) goto error_cleanup; } - srv_operation= - xtrabackup_export - ? SRV_OPERATION_RESTORE_EXPORT - : (xtrabackup_rollback_xa ? SRV_OPERATION_RESTORE_ROLLBACK_XA - : SRV_OPERATION_RESTORE); + srv_operation = xtrabackup_export + ? SRV_OPERATION_RESTORE_EXPORT : SRV_OPERATION_RESTORE; - if (innodb_init_param()) { + if (innodb_init_param()) { goto error_cleanup; } @@ -5605,50 +5473,10 @@ static bool xtrabackup_prepare_func(char** argv) srv_max_dirty_pages_pct_lwm = srv_max_buf_pool_modified_pct; } - if (xtrabackup_rollback_xa) - srv_fast_shutdown= 0; - if (innodb_init()) { goto error_cleanup; } - if (xtrabackup_rollback_xa) - { - /* Please do not merge MDEV-21168 fix in 10.5+ */ - compile_time_assert(MYSQL_VERSION_ID < 10 * 10000 + 5 * 100); - XID *xid_list= - (XID *) my_malloc(MAX_XID_LIST_SIZE * sizeof(XID), MYF(0)); - if (!xid_list) - { - msg("Can't allocate %i bytes for XID's list", MAX_XID_LIST_SIZE); - ok= false; - goto error_cleanup; - } - int got; - ut_ad(recv_no_log_write); - ut_d(recv_no_log_write= false); - while ((got= trx_recover_for_mysql(xid_list, MAX_XID_LIST_SIZE)) > 0) - { - for (int i= 0; i < got; i++) - { -#ifndef DBUG_OFF - int rc= -#endif // !DBUG_OFF - innobase_rollback_by_xid(NULL, xid_list + i); -#ifndef DBUG_OFF - if (rc == 0) - { - char buf[XIDDATASIZE * 4 + 6]; // see xid_to_str - DBUG_PRINT("info", - ("rollback xid %s", xid_to_str(buf, xid_list[i]))); - } -#endif // !DBUG_OFF - } - } - ut_d(recv_no_log_write= true); - my_free(xid_list); - } - if (ok) { msg("Last binlog file %s, position %lld", trx_sys.recovered_binlog_filename, @@ -5656,34 +5484,18 @@ static bool xtrabackup_prepare_func(char** argv) } /* Check whether the log is applied enough or not. */ - if ((srv_start_lsn || fil_space_get(SRV_LOG_SPACE_FIRST_ID)) - && srv_start_lsn < target_lsn) { + if (recv_sys.recovered_lsn && recv_sys.recovered_lsn < target_lsn) { msg("mariabackup: error: " "The log was only applied up to LSN " LSN_PF ", instead of " LSN_PF, - srv_start_lsn, target_lsn); + recv_sys.recovered_lsn, target_lsn); ok = false; } #ifdef WITH_WSREP else if (ok) xb_write_galera_info(xtrabackup_incremental); #endif - if (xtrabackup_rollback_xa) - { - // See innobase_end() and thd_destructor_proxy() - while (srv_fast_shutdown == 0 && - (trx_sys.any_active_transactions() || - static_cast<uint>(thread_count) > srv_n_purge_threads + 1)) - os_thread_sleep(1000); - - srv_shutdown_bg_undo_sources(); - srv_purge_shutdown(); - buf_flush_sync_all_buf_pools(); - innodb_shutdown(); - innobase_space_shutdown(); - } - else - innodb_shutdown(); + innodb_shutdown(); innodb_free_param(); @@ -5997,7 +5809,7 @@ handle_options(int argc, char **argv, char ***argv_client, char ***argv_server) srv_operation = SRV_OPERATION_RESTORE; - files_charset_info = &my_charset_utf8_general_ci; + files_charset_info = &my_charset_utf8mb3_general_ci; setup_error_messages(); @@ -6209,9 +6021,6 @@ int main(int argc, char **argv) init_signals(); MY_INIT(argv[0]); - pthread_key_create(&THR_THD, NULL); - my_pthread_setspecific_ptr(THR_THD, NULL); - xb_regex_init(); capture_tool_command(argc, argv); @@ -6221,7 +6030,7 @@ int main(int argc, char **argv) die("mysql_server_init() failed"); } - system_charset_info = &my_charset_utf8_general_ci; + system_charset_info = &my_charset_utf8mb3_general_ci; key_map_full.set_all(); logger.init_base(); @@ -6237,9 +6046,12 @@ int main(int argc, char **argv) DBUG_SET(dbug_option); } #endif + /* Main functions for library */ + init_thr_timer(5); int status = main_low(server_defaults); + end_thr_timer(); backup_cleanup(); if (innobackupex_mode) { @@ -6255,9 +6067,6 @@ int main(int argc, char **argv) } #endif - if (THR_THD) - (void) pthread_key_delete(THR_THD); - logger.cleanup_base(); cleanup_errmsgs(); free_error_messages(); @@ -6413,10 +6222,10 @@ static int main_low(char** argv) incremental_lsn); } - if (xtrabackup_export && innobase_file_per_table == FALSE) { + if (xtrabackup_export && !srv_file_per_table) { msg("mariabackup: auto-enabling --innodb-file-per-table due to " "the --export option"); - innobase_file_per_table = TRUE; + srv_file_per_table = TRUE; } /* cannot execute both for now */ diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index 06cde330abb..09bd26c59ea 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -104,10 +104,11 @@ static void usage() static my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument __attribute__((unused))) +get_one_option(const struct my_option *opt __attribute__((unused)), + char *argument __attribute__((unused)), + const char *filename) { - switch (optid) { + switch (opt->id) { case 'c': opt_defaults_file_used= 1; break; @@ -146,16 +147,14 @@ int main(int argc, char **argv) int count, error, args_used; char **load_default_groups= 0, *tmp_arguments[6]; char **argument, **arguments, **org_argv; - char *defaults, *extra_defaults, *group_suffix; int nargs, i= 0; MY_INIT(argv[0]); org_argv= argv; - args_used= get_defaults_options(argc, argv, &defaults, &extra_defaults, - &group_suffix); + args_used= get_defaults_options(argv); /* Copy defaults-xxx arguments & program name */ - count=args_used+1; + count=args_used; arguments= tmp_arguments; memcpy((char*) arguments, (char*) org_argv, count * sizeof(*org_argv)); arguments[count]= 0; @@ -171,7 +170,8 @@ int main(int argc, char **argv) if (nargs < 2) usage(); - load_default_groups=(char**) my_malloc(nargs*sizeof(char*), MYF(MY_WME)); + load_default_groups=(char**) my_malloc(PSI_NOT_INSTRUMENTED, + nargs*sizeof(char*), MYF(MY_WME)); if (!load_default_groups) exit(1); if (opt_mysqld) @@ -200,8 +200,7 @@ int main(int argc, char **argv) } for (argument= arguments+1 ; *argument ; argument++) - if (!my_getopt_is_args_separator(*argument)) /* skip arguments separator */ - puts(*argument); + puts(*argument); my_free(load_default_groups); free_defaults(arguments); my_end(0); diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c index e19f92261db..92716489bea 100644 --- a/extra/mysql_waitpid.c +++ b/extra/mysql_waitpid.c @@ -44,10 +44,11 @@ static struct my_option my_long_options[] = }; static my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument __attribute__((unused))) +get_one_option(const struct my_option *opt, + char *argument __attribute__((unused)), + const char *filename __attribute__((unused))) { - switch(optid) { + switch(opt->id) { case 'V': printf("%s version %s by Jani Tolonen\n", progname, VER); exit(0); diff --git a/extra/perror.c b/extra/perror.c index afbd734ce16..2daddb6636f 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -96,10 +96,11 @@ static void usage(void) static my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument __attribute__((unused))) +get_one_option(const struct my_option *opt, + char *argument __attribute__((unused)), + const char *filename __attribute__((unused))) { - switch (optid) { + switch (opt->id) { case 's': verbose=0; break; diff --git a/extra/replace.c b/extra/replace.c index 717bc92d0c4..0d35c6d0194 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -259,12 +259,12 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) if (! pa->typelib.count) { if (!(pa->typelib.type_names=(const char **) - my_malloc(((PC_MALLOC-MALLOC_OVERHEAD)/ + my_malloc(PSI_NOT_INSTRUMENTED, ((PC_MALLOC-MALLOC_OVERHEAD)/ (sizeof(char *)+sizeof(*pa->flag))* (sizeof(char *)+sizeof(*pa->flag))),MYF(MY_WME)))) DBUG_RETURN(-1); - if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD), - MYF(MY_WME)))) + if (!(pa->str= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, + PS_MALLOC-MALLOC_OVERHEAD, MYF(MY_WME)))) { my_free((void*) pa->typelib.type_names); DBUG_RETURN (-1); @@ -281,9 +281,8 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) { pa->max_length=(pa->length+length+MALLOC_OVERHEAD+PS_MALLOC-1)/PS_MALLOC; pa->max_length=pa->max_length*PS_MALLOC-MALLOC_OVERHEAD; - if (!(new_pos= (uchar*) my_realloc((uchar*) pa->str, - (uint) pa->max_length, - MYF(MY_WME)))) + if (!(new_pos= (uchar*) my_realloc(PSI_NOT_INSTRUMENTED, (uchar*) pa->str, + (uint) pa->max_length, MYF(MY_WME)))) DBUG_RETURN(1); if (new_pos != pa->str) { @@ -299,7 +298,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) int len; pa->array_allocs++; len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD); - if (!(new_array=(const char **) my_realloc((uchar*) pa->typelib.type_names, + if (!(new_array=(const char **) my_realloc(PSI_NOT_INSTRUMENTED, (void*)(pa->typelib.type_names), (uint) len/ (sizeof(uchar*)+sizeof(*pa->flag))* (sizeof(uchar*)+sizeof(*pa->flag)), @@ -431,7 +430,8 @@ static REPLACE *init_replace(char * *from, char * *to,uint count, if (init_sets(&sets,states)) DBUG_RETURN(0); found_sets=0; - if (!(found_set= (FOUND_SET*) my_malloc(sizeof(FOUND_SET)*max_length*count, + if (!(found_set= (FOUND_SET*) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(FOUND_SET)*max_length*count, MYF(MY_WME)))) { free_sets(&sets); @@ -442,7 +442,8 @@ static REPLACE *init_replace(char * *from, char * *to,uint count, used_sets=-1; word_states=make_new_set(&sets); /* Start of new word */ start_states=make_new_set(&sets); /* This is first state */ - if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME)))) + if (!(follow=(FOLLOWS*) my_malloc(PSI_NOT_INSTRUMENTED, + (states+2)*sizeof(FOLLOWS), MYF(MY_WME)))) { free_sets(&sets); my_free(found_set); @@ -634,7 +635,8 @@ static REPLACE *init_replace(char * *from, char * *to,uint count, /* Alloc replace structure for the replace-state-machine */ - if ((replace=(REPLACE*) my_malloc(sizeof(REPLACE)*(sets.count)+ + if ((replace=(REPLACE*) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(REPLACE)*(sets.count)+ sizeof(REPLACE_STRING)*(found_sets+1)+ sizeof(char *)*count+result_len, MYF(MY_WME | MY_ZEROFILL)))) @@ -679,10 +681,12 @@ static int init_sets(REP_SETS *sets,uint states) { bzero((char*) sets,sizeof(*sets)); sets->size_of_bits=((states+7)/8); - if (!(sets->set_buffer=(REP_SET*) my_malloc(sizeof(REP_SET)*SET_MALLOC_HUNC, + if (!(sets->set_buffer=(REP_SET*) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(REP_SET)*SET_MALLOC_HUNC, MYF(MY_WME)))) return 1; - if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits* + if (!(sets->bit_buffer=(uint*) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(uint)*sets->size_of_bits* SET_MALLOC_HUNC,MYF(MY_WME)))) { my_free(sets->set); @@ -717,15 +721,14 @@ static REP_SET *make_new_set(REP_SETS *sets) return set; } count=sets->count+sets->invisible+SET_MALLOC_HUNC; - if (!(set=(REP_SET*) my_realloc((uchar*) sets->set_buffer, - sizeof(REP_SET)*count, - MYF(MY_WME)))) + if (!(set=(REP_SET*) my_realloc(PSI_NOT_INSTRUMENTED, sets->set_buffer, + sizeof(REP_SET)*count, MYF(MY_WME)))) return 0; sets->set_buffer=set; sets->set=set+sets->invisible; - if (!(bit_buffer=(uint*) my_realloc((uchar*) sets->bit_buffer, - (sizeof(uint)*sets->size_of_bits)*count, - MYF(MY_WME)))) + if (!(bit_buffer=(uint*) my_realloc(PSI_NOT_INSTRUMENTED, sets->bit_buffer, + (sizeof(uint)*sets->size_of_bits)*count, + MYF(MY_WME)))) return 0; sets->bit_buffer=bit_buffer; for (i=0 ; i < count ; i++) @@ -898,7 +901,7 @@ static uint replace_strings(REPLACE *rep, char **start, uint *max_length, if (to == end) { (*max_length)+=8192; - if (!(new=my_realloc(*start,*max_length,MYF(MY_WME)))) + if (!(new=my_realloc(PSI_NOT_INSTRUMENTED, *start,*max_length,MYF(MY_WME)))) return (uint) -1; to=new+(to - *start); end=(*start=new)+ *max_length-1; @@ -914,7 +917,7 @@ static uint replace_strings(REPLACE *rep, char **start, uint *max_length, if (to == end) { (*max_length)*=2; - if (!(new=my_realloc(*start,*max_length,MYF(MY_WME)))) + if (!(new=my_realloc(PSI_NOT_INSTRUMENTED, *start,*max_length,MYF(MY_WME)))) return (uint) -1; to=new+(to - *start); end=(*start=new)+ *max_length-1; @@ -938,11 +941,11 @@ static int initialize_buffer() { bufread = 8192; bufalloc = bufread + bufread / 2; - if (!(buffer = my_malloc(bufalloc+1,MYF(MY_WME)))) + if (!(buffer = my_malloc(PSI_NOT_INSTRUMENTED, bufalloc+1, MYF(MY_WME)))) return 1; bufbytes=my_eof=0; out_length=bufread; - if (!(out_buff=my_malloc(out_length,MYF(MY_WME)))) + if (!(out_buff=my_malloc(PSI_NOT_INSTRUMENTED, out_length, MYF(MY_WME)))) return(1); return 0; } @@ -979,7 +982,7 @@ int n; bufalloc *= 2; bufread *= 2; } - buffer = my_realloc(buffer, bufalloc+1, MYF(MY_WME)); + buffer = my_realloc(PSI_NOT_INSTRUMENTED, buffer, bufalloc+1, MYF(MY_WME)); if (! buffer) return(-1); } diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index b76cc2aa249..c4ed2a9ccd7 100644 --- a/extra/resolve_stack_dump.c +++ b/extra/resolve_stack_dump.c @@ -111,10 +111,11 @@ void local_exit(int error) static my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument __attribute__((unused))) +get_one_option(const struct my_option *opt, + char *argument __attribute__((unused)), + const char *filename __attribute__((unused))) { - switch(optid) { + switch(opt->id) { case 'V': print_version(); local_exit(0); @@ -234,8 +235,8 @@ static int init_sym_entry(SYM_ENTRY* se, char* buf) static void init_sym_table() { char buf[512]; - if (my_init_dynamic_array(&sym_table, sizeof(SYM_ENTRY), INIT_SYM_TABLE, - INC_SYM_TABLE, MYF(0))) + if (my_init_dynamic_array(PSI_NOT_INSTRUMENTED, &sym_table, sizeof(SYM_ENTRY), + INIT_SYM_TABLE, INC_SYM_TABLE, MYF(0))) die("Failed in my_init_dynamic_array() -- looks like out of memory problem"); while (fgets(buf, sizeof(buf), fp_sym)) diff --git a/extra/resolveip.c b/extra/resolveip.c index 59a32f5f084..6812bc47e8e 100644 --- a/extra/resolveip.c +++ b/extra/resolveip.c @@ -71,10 +71,11 @@ static void usage(void) static my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument __attribute__((unused))) +get_one_option(const struct my_option *opt, + char *argument __attribute__((unused)), + const char *filename __attribute__((unused))) { - switch (optid) { + switch (opt->id) { case 'V': print_version(); exit(0); case 'I': case '?': |