Skip to content

Commit

Permalink
Merge branch '10.6' into 10.11
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Oct 29, 2024
2 parents db3be9b + f00711b commit 3d0fb15
Show file tree
Hide file tree
Showing 655 changed files with 8,056 additions and 3,537 deletions.
72 changes: 61 additions & 11 deletions client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3933,9 +3933,9 @@ void do_move_file(struct st_command *command)
is_sub_path(ds_to_file.str, to_plen, vardir)) ||
(is_sub_path(ds_from_file.str, from_plen, tmpdir) &&
is_sub_path(ds_to_file.str, to_plen, tmpdir)))) {
report_or_die("Paths '%s' and '%s' are not both under MYSQLTEST_VARDIR '%s'"
"or both under MYSQL_TMP_DIR '%s'",
ds_from_file, ds_to_file, vardir, tmpdir);
report_or_die("Paths '%s' and '%s' are not both under "
"MYSQLTEST_VARDIR '%s' or both under MYSQL_TMP_DIR '%s'",
ds_from_file.str, ds_to_file.str, vardir, tmpdir);
DBUG_VOID_RETURN;
}

Expand Down Expand Up @@ -7974,18 +7974,37 @@ static const char *trking_info_desc[SESSION_TRACK_END + 1]=
/**
@brief Append state change information (received through Ok packet) to the output.
@details The appended string is lines prefixed with "-- ". Only
tracking types with info sent from the server are displayed. For
each tracking type, the first line is the type name e.g.
"-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES".
The subsequent lines are the actual tracking info. When type is
SESSION_TRACK_SYSTEM_VARIABLES, the actual tracking info is a list
of name-value pairs of lines, sorted by name, e.g. if the info
received from the server is "autocommit=ON;time_zone=SYSTEM", the
corresponding string is
-- autocommit: ON
-- time_zone: SYSTEM
@param [in,out] ds Dynamic string to hold the content to be printed.
@param [in] mysql Connection handle.
*/

static void append_session_track_info(DYNAMIC_STRING *ds, MYSQL *mysql)
{
#ifndef EMBEDDED_LIBRARY
DYNAMIC_STRING ds_sort, *ds_type= NULL;
for (unsigned int type= SESSION_TRACK_BEGIN; type <= SESSION_TRACK_END; type++)
{
const char *data;
size_t data_length;

/*
Append the tracking type line, if any corresponding tracking
info is received.
*/
if (!mysql_session_track_get_first(mysql,
(enum_session_state_type) type,
&data, &data_length))
Expand All @@ -8001,26 +8020,56 @@ static void append_session_track_info(DYNAMIC_STRING *ds, MYSQL *mysql)
DBUG_ASSERT(0);
dynstr_append_mem(ds, STRING_WITH_LEN("Tracker???\n"));
}

dynstr_append_mem(ds, STRING_WITH_LEN("-- "));
dynstr_append_mem(ds, data, data_length);
}
else
continue;

/*
The remaining of this function: format and append the actual
tracking info.
*/
if (type == SESSION_TRACK_SYSTEM_VARIABLES)
{
/* Prepare a string to be sorted before being appended. */
if (init_dynamic_string(&ds_sort, "", 1024, 1024))
die("Out of memory");
ds_type= &ds_sort;
}
else
ds_type= ds;
/* Append the first piece of info */
dynstr_append_mem(ds_type, STRING_WITH_LEN("-- "));
dynstr_append_mem(ds_type, data, data_length);
/* Whether we are appending the value of a variable */
bool appending_value= type == SESSION_TRACK_SYSTEM_VARIABLES;
/* Append remaining pieces */
while (!mysql_session_track_get_next(mysql,
(enum_session_state_type) type,
&data, &data_length))
{
dynstr_append_mem(ds, STRING_WITH_LEN("\n-- "));
if (appending_value)
dynstr_append_mem(ds_type, STRING_WITH_LEN(": "));
else
dynstr_append_mem(ds_type, STRING_WITH_LEN("\n-- "));
appending_value= !appending_value && type == SESSION_TRACK_SYSTEM_VARIABLES;
if (data == NULL)
{
DBUG_ASSERT(data_length == 0);
dynstr_append_mem(ds, STRING_WITH_LEN("<NULL>"));
dynstr_append_mem(ds_type, STRING_WITH_LEN("<NULL>"));
}
else
dynstr_append_mem(ds, data, data_length);
dynstr_append_mem(ds_type, data, data_length);
}
DBUG_ASSERT(!appending_value);
if (type == SESSION_TRACK_SYSTEM_VARIABLES)
{
dynstr_append_mem(ds_type, STRING_WITH_LEN("\n"));
dynstr_append_sorted(ds, ds_type, false);
dynstr_append_mem(ds, STRING_WITH_LEN("\n"));
dynstr_free(&ds_sort);
}
dynstr_append_mem(ds, STRING_WITH_LEN("\n\n"));
else
dynstr_append_mem(ds, STRING_WITH_LEN("\n\n"));
}
#endif /* EMBEDDED_LIBRARY */
}
Expand Down Expand Up @@ -12174,7 +12223,8 @@ void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val)
/*
Build a list of pointer to each line in ds_input, sort
the list and use the sorted list to append the strings
sorted to the output ds
sorted to the output ds. The string ds_input needs to
end with a newline.
SYNOPSIS
dynstr_append_sorted()
Expand Down
7 changes: 5 additions & 2 deletions cmake/build_configurations/mysql_release.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ ELSEIF(RPM)
IF(RPM MATCHES "opensuse|sles|centos|rhel|rocky|alma")
SET(WITH_ROCKSDB_LZ4 OFF CACHE STRING "")
ENDIF()
IF(RPM MATCHES "rhel8")
SET(WITH_READLINE ON CACHE BOOL "")
ENDIF()
ELSEIF(DEB)
SET(WITH_SSL system CACHE STRING "")
SET(WITH_ZLIB system CACHE STRING "")
Expand Down Expand Up @@ -172,12 +175,12 @@ IF(UNIX)

# Default GCC flags
IF(CMAKE_COMPILER_IS_GNUCC)
SET(COMMON_C_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized")
SET(COMMON_C_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized")
SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}")
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(COMMON_CXX_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized")
SET(COMMON_CXX_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized")
SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}")
ENDIF()
Expand Down
3 changes: 2 additions & 1 deletion cmake/cpack_rpm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ IF(WITH_WSREP)
SETA(CPACK_RPM_server_PACKAGE_REQUIRES
"galera-4" "rsync" "grep" "gawk" "iproute"
"coreutils" "findutils" "tar")
SETA(CPACK_RPM_server_PACKAGE_RECOMMENDS "lsof" "pv")
SETA(CPACK_RPM_server_PACKAGE_RECOMMENDS "lsof" "socat" "pv")
SETA(CPACK_RPM_test_PACKAGE_REQUIRES "socat")
ENDIF()

SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh)
Expand Down
2 changes: 1 addition & 1 deletion cmake/libutils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ MACRO(CREATE_EXPORTS_FILE VAR TARGET API_FUNCTIONS)
CONFIGURE_FILE_CONTENT(${CONTENT} ${EXPORTS})
# Avoid "function redeclared as variable" error
# when using gcc/clang option -flto(link time optimization)
IF(" ${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} " MATCHES " -flto")
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
SET_SOURCE_FILES_PROPERTIES(${EXPORTS} PROPERTIES COMPILE_FLAGS "-fno-lto")
ENDIF()
SET(${VAR} ${EXPORTS})
Expand Down
4 changes: 4 additions & 0 deletions cmake/mariadb_connector_c.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ ELSE()
SET(CONC_INSTALL_LAYOUT "DEFAULT")
ENDIF()

IF(WITH_BOOST_CONTEXT)
SET(CONC_WITH_BOOST_CONTEXT ON)
ENDIF()

SET(PLUGIN_INSTALL_DIR ${INSTALL_PLUGINDIR})
SET(MARIADB_UNIX_ADDR ${MYSQL_UNIX_ADDR})

Expand Down
1 change: 1 addition & 0 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
#cmakedefine HAVE_PTHREAD_ATTR_GETSTACKSIZE 1
#cmakedefine HAVE_PTHREAD_ATTR_SETSCOPE 1
#cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
#cmakedefine HAVE_PTHREAD_GETATTR_NP 1
#cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1
#cmakedefine HAVE_PTHREAD_GETAFFINITY_NP 1
#cmakedefine HAVE_PTHREAD_KEY_DELETE 1
Expand Down
1 change: 1 addition & 0 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ CHECK_FUNCTION_EXISTS (pthread_attr_getguardsize HAVE_PTHREAD_ATTR_GETGUARDSIZE)
CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE)
CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE)
CHECK_FUNCTION_EXISTS (pthread_getaffinity_np HAVE_PTHREAD_GETAFFINITY_NP)
CHECK_FUNCTION_EXISTS (pthread_getattr_np HAVE_PTHREAD_GETATTR_NP)
CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE)
CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK)
CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK)
Expand Down
5 changes: 0 additions & 5 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
# https://wiki.debian.org/Hardening
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Disable LTO on Ubuntu, see LP: #1970634 and https://jira.mariadb.org/browse/MDEV-25633
ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes), yes)
export DEB_BUILD_MAINT_OPTIONS += optimize=-lto
endif

DPKG_EXPORT_BUILDFLAGS = 1
# Include all defaults, including buildflags.mk
include /usr/share/dpkg/default.mk
Expand Down
43 changes: 6 additions & 37 deletions extra/mariabackup/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2662,7 +2662,7 @@ static bool innodb_init()
const std::string ib_logfile0{get_log_file_path()};
os_file_delete_if_exists_func(ib_logfile0.c_str(), nullptr);
os_file_t file= os_file_create_func(ib_logfile0.c_str(),
OS_FILE_CREATE, OS_FILE_NORMAL,
OS_FILE_CREATE,
#if defined _WIN32 || defined O_DIRECT
OS_DATA_FILE_NO_O_DIRECT,
#else
Expand All @@ -2687,13 +2687,9 @@ static bool innodb_init()
mach_write_to_4(b + 12, my_crc32c(0, b, 11));
static_assert(12 + 4 == SIZE_OF_FILE_CHECKPOINT, "compatibility");

#ifdef _WIN32
DWORD len;
ret= WriteFile(file, log_hdr_buf, sizeof log_hdr_buf,
&len, nullptr) && len == sizeof log_hdr_buf;
#else
ret= sizeof log_hdr_buf == write(file, log_hdr_buf, sizeof log_hdr_buf);
#endif
ret = os_file_write_func(IORequestWrite, ib_logfile0.c_str(), file,
log_hdr_buf, 0,
sizeof(log_hdr_buf)) == DB_SUCCESS;
if (!os_file_close_func(file) || !ret)
goto invalid_log;
return false;
Expand Down Expand Up @@ -7536,7 +7532,6 @@ void handle_options(int argc, char **argv, char ***argv_server,
}

static int main_low(char** argv);
static int get_exepath(char *buf, size_t size, const char *argv0);

/* ================= main =================== */
int main(int argc, char **argv)
Expand All @@ -7547,8 +7542,8 @@ int main(int argc, char **argv)

my_getopt_prefix_matching= 0;

if (get_exepath(mariabackup_exe,FN_REFLEN, argv[0]))
strncpy(mariabackup_exe,argv[0], FN_REFLEN-1);
if (my_get_exepath(mariabackup_exe, FN_REFLEN, argv[0]))
strncpy(mariabackup_exe, argv[0], FN_REFLEN-1);


if (argc > 1 )
Expand Down Expand Up @@ -7845,32 +7840,6 @@ static int main_low(char** argv)
}


static int get_exepath(char *buf, size_t size, const char *argv0)
{
#ifdef _WIN32
DWORD ret = GetModuleFileNameA(NULL, buf, (DWORD)size);
if (ret > 0)
return 0;
#elif defined(__linux__)
ssize_t ret = readlink("/proc/self/exe", buf, size-1);
if(ret > 0)
return 0;
#elif defined(__APPLE__)
size_t ret = proc_pidpath(getpid(), buf, static_cast<uint32_t>(size));
if (ret > 0) {
buf[ret] = 0;
return 0;
}
#elif defined(__FreeBSD__)
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
if (sysctl(mib, 4, buf, &size, NULL, 0) == 0) {
return 0;
}
#endif

return my_realpath(buf, argv0, 0);
}


#if defined (__SANITIZE_ADDRESS__) && defined (__linux__)
/* Avoid LeakSanitizer's false positives. */
Expand Down
17 changes: 12 additions & 5 deletions include/m_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,19 @@ static inline void safe_strcpy(char *dst, size_t dst_size, const char *src)
static inline int safe_strcpy_truncated(char *dst, size_t dst_size,
const char *src)
{
DBUG_ASSERT(dst_size > 0);

strncpy(dst, src, dst_size);
if (dst[dst_size - 1])
DBUG_ASSERT(dst_size > 0);
if (dst_size == 0)
return 1;
/*
We do not want to use strncpy() as we do not want to rely on
strncpy() filling the unused dst with 0.
We cannot use strmake() here as it in debug mode fills the buffers
with 'Z'.
*/
if (strnmov(dst, src, dst_size) == dst+dst_size)
{
dst[dst_size - 1]= 0;
dst[dst_size-1]= 0;
return 1;
}
return 0;
Expand All @@ -306,7 +313,7 @@ static inline int safe_strcpy_truncated(char *dst, size_t dst_size,
static inline int safe_strcat(char *dst, size_t dst_size, const char *src)
{
size_t init_len= strlen(dst);
if (init_len > dst_size)
if (init_len >= dst_size)
return 1;
return safe_strcpy_truncated(dst + init_len, dst_size - init_len, src);
}
Expand Down
1 change: 0 additions & 1 deletion include/my_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,6 @@ typedef long long my_ptrdiff_t;
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A), sizeof(double)))
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
#define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1))

/*
Custom version of standard offsetof() macro which can be used to get
Expand Down
Loading

0 comments on commit 3d0fb15

Please sign in to comment.