Skip to content

Commit f1102da

Browse files
committed
Merge branch '11.8' into 12.0
2 parents 00a9afb + 8d36caf commit f1102da

File tree

451 files changed

+15084
-7030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

451 files changed

+15084
-7030
lines changed

CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ENDIF()
3131
# in RPM's:
3232

3333
#set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true")
34-
FOREACH(p CMP0022 CMP0046 CMP0040 CMP0048 CMP0054 CMP0056 CMP0067 CMP0074 CMP0075 CMP0069 CMP0135)
34+
FOREACH(p CMP0022 CMP0046 CMP0040 CMP0048 CMP0054 CMP0056 CMP0067 CMP0074 CMP0075 CMP0069 CMP0135 CMP0091)
3535
IF(POLICY ${p})
3636
CMAKE_POLICY(SET ${p} NEW)
3737
ENDIF()
@@ -119,6 +119,18 @@ ENDIF()
119119

120120
FIND_PACKAGE(Git)
121121

122+
IF(WIN32 AND (CMAKE_VERSION VERSION_GREATER "3.21"))
123+
# Install runtime dependency by default, when using vcpkg
124+
IF(NOT DEFINED INSTALL_RUNTIME_DEPENDENCIES_DEFAULT)
125+
IF("${VCPKG_INSTALLED_DIR}")
126+
SET(INSTALL_RUNTIME_DEPENDENCIES_DEFAULT OFF)
127+
ELSE()
128+
SET(INSTALL_RUNTIME_DEPENDENCIES_DEFAULT ON)
129+
ENDIF()
130+
ENDIF()
131+
OPTION(INSTALL_RUNTIME_DEPENDENCIES "Install runtime dependencies" "${INSTALL_RUNTIME_DEPENDENCIES_DEFAULT}")
132+
ENDIF()
133+
122134
# Following autotools tradition, add preprocessor definitions
123135
# specified in environment variable CPPFLAGS
124136
IF(DEFINED ENV{CPPFLAGS})
@@ -361,6 +373,7 @@ IF(WIN32)
361373
ELSE()
362374
SET(DEFAULT_MYSQL_HOME ${CMAKE_INSTALL_PREFIX})
363375
SET(SHAREDIR ${INSTALL_MYSQLSHAREDIRABS})
376+
SET(HOSTNAME "uname -n" CACHE STRING "Command for determining hostname")
364377
ENDIF()
365378

366379
SET(DEFAULT_BASEDIR "${DEFAULT_MYSQL_HOME}")

appveyor.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
11
version: build-{build}~branch-{branch}
22

3-
clone_depth: 1
3+
clone_depth: 10
4+
5+
skip_branch_with_pr: true
6+
before_build:
7+
- ps: |
8+
function Get-Remote-Ref($ref) {
9+
try {
10+
$result = git ls-remote origin $ref 2>$null
11+
if (-not $result) {
12+
"Warning: Could not fetch remote ref '$ref'"
13+
return $null
14+
}
15+
return ($result -split "`t")[0]
16+
} catch {
17+
"Warning: Exception while running git ls-remote for '$ref': $_"
18+
return $null
19+
}
20+
}
21+
Get-ChildItem Env: | Where-Object { $_.Name -like 'APPVEYOR*COMMIT' } | ForEach-Object { "$($_.Name)=$($_.Value)" }
22+
$commit = $env:APPVEYOR_REPO_COMMIT
23+
$commit2 = $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT
24+
$branch = $env:APPVEYOR_REPO_BRANCH
25+
$latest = $null
26+
$mainBranch = $branch -match '^(main|\d+\.\d+)$'
27+
if ($env:APPVEYOR_PULL_REQUEST_NUMBER -eq $null) {
28+
"Branch build detected"
29+
$latest = Get-Remote-Ref "refs/heads/$branch"
30+
} else {
31+
$pr = $env:APPVEYOR_PULL_REQUEST_NUMBER
32+
$latest = Get-Remote-Ref "refs/pull/$pr/head"
33+
$mainBranch = $False
34+
"Pull Request build detected"
35+
}
36+
if ($latest -and ($commit -ne $latest) -and ($commit2 -ne $latest) -and (-not $mainBranch)) {
37+
"Skipping outdated commit (latest is $latest)"
38+
Exit-AppVeyorBuild
39+
}
440
541
environment:
642
OPENSSL_ROOT_DIR: C:/OpenSSL-v32-Win64

client/mysqlbinlog.cc

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,15 @@ static Server_gtid_event_filter *server_id_gtid_filter= NULL;
160160

161161
static char *start_datetime_str, *stop_datetime_str;
162162
static my_time_t start_datetime= 0, stop_datetime= 0;
163-
static my_time_t last_processed_datetime= MY_TIME_T_MAX;
164163
static bool stop_datetime_given= false;
165164

165+
typedef struct _last_processed_ev_t
166+
{
167+
ulonglong position;
168+
my_time_t datetime;
169+
} last_processed_ev_t;
170+
static last_processed_ev_t last_processed_ev= {0, MY_TIME_T_MAX};
171+
166172
static ulonglong rec_count= 0;
167173
static MYSQL* mysql = NULL;
168174
static const char* dirname_for_local_load= 0;
@@ -1369,7 +1375,19 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
13691375
end:
13701376
rec_count++;
13711377
end_skip_count:
1372-
last_processed_datetime= ev_when;
1378+
/*
1379+
Update the last_processed_ev, unless the event is a fake event (i.e. format
1380+
description (ev pointer is reset to 0) or rotate event (ev->when is 0)), or
1381+
the event is encrypted (i.e. type is Unknown).
1382+
*/
1383+
if (ev &&
1384+
!(ev_type == UNKNOWN_EVENT &&
1385+
((Unknown_log_event *) ev)->what == Unknown_log_event::ENCRYPTED) &&
1386+
!(ev_type == ROTATE_EVENT && !ev->when))
1387+
{
1388+
last_processed_ev.position= pos + ev->data_written;
1389+
last_processed_ev.datetime= ev_when;
1390+
}
13731391

13741392
DBUG_PRINT("info", ("end event processing"));
13751393
/*
@@ -2661,6 +2679,9 @@ static Exit_status handle_event_text_mode(PRINT_EVENT_INFO *print_event_info,
26612679
if (old_off != BIN_LOG_HEADER_SIZE)
26622680
*len= 1; // fake event, don't increment old_off
26632681
}
2682+
DBUG_ASSERT(old_off + ev->data_written == old_off + (*len - 1) ||
2683+
(*len == 1 &&
2684+
(type == ROTATE_EVENT || type == FORMAT_DESCRIPTION_EVENT)));
26642685
Exit_status retval= process_event(print_event_info, ev, old_off, logname);
26652686
if (retval != OK_CONTINUE)
26662687
DBUG_RETURN(retval);
@@ -3035,6 +3056,8 @@ static Exit_status check_header(IO_CACHE* file,
30353056
the new one, so we should not do it ourselves in this
30363057
case.
30373058
*/
3059+
DBUG_ASSERT(tmp_pos + new_description_event->data_written ==
3060+
my_b_tell(file));
30383061
Exit_status retval= process_event(print_event_info,
30393062
new_description_event, tmp_pos,
30403063
logname);
@@ -3188,20 +3211,17 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
31883211
}
31893212
// else read_error == 0 means EOF, that's OK, we break in this case
31903213

3191-
/*
3192-
Emit a warning in the event that we finished processing input
3193-
before reaching the boundary indicated by --stop-position.
3194-
*/
3195-
if (((longlong)stop_position != stop_position_default) &&
3196-
stop_position > my_b_tell(file))
3197-
{
3198-
retval = OK_STOP;
3199-
warning("Did not reach stop position %llu before "
3200-
"end of input", stop_position);
3201-
}
3202-
32033214
goto end;
32043215
}
3216+
3217+
/*
3218+
The real location that we have read up to in the file should align with
3219+
the size of the event, unless the event is encrypted.
3220+
*/
3221+
DBUG_ASSERT(
3222+
((ev->get_type_code() == UNKNOWN_EVENT &&
3223+
((Unknown_log_event *) ev)->what == Unknown_log_event::ENCRYPTED)) ||
3224+
old_off + ev->data_written == my_b_tell(file));
32053225
if ((retval= process_event(print_event_info, ev, old_off, logname)) !=
32063226
OK_CONTINUE)
32073227
goto end;
@@ -3380,9 +3400,17 @@ int main(int argc, char** argv)
33803400
start_position= BIN_LOG_HEADER_SIZE;
33813401
}
33823402

3383-
if (stop_datetime_given && stop_datetime > last_processed_datetime)
3403+
/*
3404+
Emit a warning if we finished processing input before reaching the stop
3405+
boundaries indicated by --stop-datetime or --stop-position.
3406+
*/
3407+
if (stop_datetime_given && stop_datetime > last_processed_ev.datetime)
33843408
warning("Did not reach stop datetime '%s' before end of input",
33853409
stop_datetime_str);
3410+
if ((static_cast<longlong>(stop_position) != stop_position_default) &&
3411+
stop_position > last_processed_ev.position)
3412+
warning("Did not reach stop position %llu before end of input",
3413+
stop_position);
33863414

33873415
/*
33883416
If enable flashback, need to print the events from the end to the

cmake/3rdparty_info.cmake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This file is used for SBOM generation.
2+
3+
# It consists of the list of 3rd party products
4+
# which can be compiled together with MariaDB server
5+
# and their licenses, copyright notices, and CPE prefixes
6+
# this is the vendor:product part of CPE identifier from
7+
# https://nvd.nist.gov/products/cpe
8+
9+
# We use both git submodules, and CMake external projects
10+
# dependencies (as well we zlib, which is part of the code)
11+
# so the information is here for all these types
12+
13+
SET("zlib.license" "Zlib")
14+
SET("zlib.copyright" "Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler")
15+
SET("zlib.cpe-prefix" "zlib:zlib")
16+
SET("minizip.license" "Zlib")
17+
SET("minizip.copyright" "Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler")
18+
SET("minizip.cpe-prefix" "zlib:zlib")
19+
SET("fmt.license" "MIT")
20+
SET("fmt.copyright" "Copyright (C) 2012 - present, Victor Zverovich")
21+
SET("fmt.cpe-prefix" "fmt:fmt")
22+
SET("pcre2.license" "BSD-3-Clause")
23+
SET("pcre2.cpe-prefix" "pcre:pcre2")
24+
SET("wolfssl.license" "GPL-2.0")
25+
SET("wolfssl.copyright" "Copyright (C) 2006-2024 wolfSSL Inc.")
26+
SET("wolfssl.cpe-prefix" "wolfssl:wolfssl")
27+
SET("boost.license" "BSL-1.0")
28+
SET("boost.cpe-prefix" "boost:boost")
29+
SET("mariadb-connector-c.license" "LGPL-2.1")
30+
SET("mariadb-connector-c.cpe-prefix" "mariadb:connector\\\\/c")
31+
SET("rocksdb.license" "GPL-2.0")
32+
SET("wsrep-lib.license" "GPL-2.0")
33+
SET("wsrep-api.license" "GPL-2.0")
34+
SET("mariadb-columnstore-engine.license" "GPL-2.0")
35+
SET("libmarias3.license" "LGPL-2.1")
36+
SET("thrift.license" "Apache-2.0")
37+
SET("thrift.cpe-prefix" "apache:thrift")

cmake/cpack_rpm.cmake

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ IF(WITH_WSREP)
264264
"galera-4" "rsync" "grep" "gawk" "iproute"
265265
"coreutils" "findutils" "tar")
266266
SETA(CPACK_RPM_server_PACKAGE_RECOMMENDS "lsof" "socat" "pv")
267-
SETA(CPACK_RPM_test_PACKAGE_REQUIRES "socat")
267+
SETA(CPACK_RPM_test_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}" "socat")
268268
ENDIF()
269269

270270
SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh)
@@ -311,7 +311,7 @@ ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7")
311311
ALTERNATIVE_NAME("server" "mariadb-server")
312312
ALTERNATIVE_NAME("server" "mysql-compat-server")
313313
ALTERNATIVE_NAME("test" "mariadb-test")
314-
ELSEIF(RPM MATCHES "(rhel|centos|rocky)[89]")
314+
ELSEIF(RPM MATCHES "(rhel|centos|rocky)")
315315
SET(epoch 3:)
316316
ALTERNATIVE_NAME("backup" "mariadb-backup")
317317
ALTERNATIVE_NAME("client" "mariadb")
@@ -343,53 +343,6 @@ ENDIF()
343343

344344
SET(PYTHON_SHEBANG "/usr/bin/python3" CACHE STRING "python shebang")
345345

346-
# If we want to build build MariaDB-shared-compat,
347-
# extract compat libraries from MariaDB-shared-5.3 rpm
348-
FILE(GLOB compat53 RELATIVE ${CMAKE_SOURCE_DIR}
349-
"${CMAKE_SOURCE_DIR}/../MariaDB-shared-5.3.*.rpm")
350-
FILE(GLOB compat101 RELATIVE ${CMAKE_SOURCE_DIR}
351-
"${CMAKE_SOURCE_DIR}/../MariaDB-shared-10.1.*.rpm")
352-
IF(compat53 AND compat101)
353-
FOREACH(compat_rpm "${compat53}" "${compat101}")
354-
MESSAGE(STATUS "Using ${compat_rpm} to build MariaDB-compat")
355-
INSTALL(CODE "EXECUTE_PROCESS(
356-
COMMAND rpm2cpio ${CMAKE_SOURCE_DIR}/${compat_rpm}
357-
COMMAND cpio --extract --make-directories */libmysqlclient*.so.* -
358-
WORKING_DIRECTORY \$ENV{DESTDIR})
359-
EXECUTE_PROCESS(
360-
COMMAND chmod -R a+rX .
361-
WORKING_DIRECTORY \$ENV{DESTDIR})"
362-
COMPONENT Compat)
363-
ENDFOREACH()
364-
365-
EXECUTE_PROCESS(
366-
COMMAND rpm -q --provides -p "${CMAKE_SOURCE_DIR}/${compat101}"
367-
ERROR_QUIET
368-
OUTPUT_VARIABLE compat_provides)
369-
EXECUTE_PROCESS(
370-
COMMAND rpm -q --obsoletes -p "${CMAKE_SOURCE_DIR}/${compat101}"
371-
ERROR_QUIET
372-
OUTPUT_VARIABLE compat_obsoletes)
373-
374-
STRING(REPLACE "\n" " " compat_provides "${compat_provides}")
375-
STRING(REPLACE "\n" " " compat_obsoletes "${compat_obsoletes}")
376-
STRING(REGEX REPLACE "[^ ]+\\([^ ]+ *" "" compat_obsoletes "${compat_obsoletes}")
377-
SETA(CPACK_RPM_compat_PACKAGE_PROVIDES "${compat_provides}")
378-
SETA(CPACK_RPM_compat_PACKAGE_OBSOLETES "${compat_obsoletes}")
379-
380-
SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} Compat)
381-
382-
# RHEL6/CentOS6 install Postfix by default, and it requires
383-
# libmysqlclient.so.16 that pulls in mysql-libs-5.1.x
384-
# And the latter conflicts with our rpms.
385-
# Make sure that for these distributions all our rpms require
386-
# MariaDB-compat, that will replace mysql-libs-5.1
387-
IF(RPM MATCHES "(rhel|centos)[67]")
388-
SET(CPACK_RPM_common_PACKAGE_REQUIRES "MariaDB-compat")
389-
SET(CPACK_RPM_compat_PACKAGE_CONFLICTS "mariadb-libs < 1:10.1.0")
390-
ENDIF()
391-
ENDIF()
392-
393346
################
394347
IF(CMAKE_VERSION VERSION_GREATER "3.9.99")
395348

cmake/generate_sbom.cmake

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,23 @@ ENDMACRO()
3636

3737
# Get CPE ID ( https://en.wikipedia.org/wiki/Common_Platform_Enumeration )
3838
# for given project name and version
39-
# Only "known" CPEs are handled here, e.g currently no CPE for rocksdb
39+
# CPE prefix are stored with other auxilliary info in the 3rdparty_info.cmake
40+
# file
4041
FUNCTION(SBOM_GET_CPE name version var)
41-
SET(cpe_prefix_map
42-
"zlib" "zlib:zlib"
43-
"mariadb-connector-c" "mariadb:connector\\\\/c"
44-
"wolfssl" "wolfssl:wolfssl"
45-
"minizip" "zlib:zlib"
46-
"pcre2" "pcre:pcre2"
47-
"fmt" "fmt:fmt"
48-
"boost" "boost:boost"
49-
"thrift" "apache:thrift"
50-
)
51-
LIST(FIND cpe_prefix_map "${name}" idx_cpe_mapping)
52-
# Version needs to have at least one dot character in it.
53-
# Otherwise, we assume it is a git hash, and do not generate CPE
54-
STRING(FIND "${version}" "." idx_version_dot)
55-
IF((idx_cpe_mapping GREATER -1) AND (idx_version_dot GREATER -1))
56-
MATH(EXPR next_idx "${idx_cpe_mapping}+1")
57-
LIST(GET cpe_prefix_map ${next_idx} cpe_name_and_vendor)
58-
STRING(REGEX REPLACE "[^0-9\\.]" "" cleaned_version "${version}")
59-
SET(${var} "cpe:2.3:a:${cpe_name_and_vendor}:${cleaned_version}:*:*:*:*:*:*:*" PARENT_SCOPE)
60-
ELSE()
61-
SET(${var} "" PARENT_SCOPE)
42+
SET(${var} "" PARENT_SCOPE)
43+
STRING(FIND "${version}" "." dot_idx)
44+
IF(${dot_idx} EQUAL -1)
45+
# Version does not have dot inside.
46+
# mostly likely it is just a git hash
47+
RETURN()
48+
ENDIF()
49+
SET(cpe_name_and_vendor "${${repo_name_lower}.cpe-prefix}")
50+
IF(NOT cpe_name_and_vendor)
51+
RETURN()
6252
ENDIF()
53+
54+
STRING(REGEX REPLACE "[^0-9\\.]" "" cleaned_version "${version}")
55+
SET(${var} "cpe:2.3:a:${cpe_name_and_vendor}:${cleaned_version}:*:*:*:*:*:*:*" PARENT_SCOPE)
6356
ENDFUNCTION()
6457

6558
# Add dependency on CMake ExternalProject.
@@ -97,8 +90,8 @@ ENDMACRO()
9790
# Perhaps it can always be "MariaDB", but security team recommendation is different
9891
# more towards "author"
9992
FUNCTION (sbom_get_supplier repo_name repo_user varname)
100-
IF("${repo_name_SUPPLIER}")
101-
SET(${varname} "${repo_name_SUPPLIER}" PARENT_SCOPE)
93+
IF("${${repo_name}_SUPPLIER}")
94+
SET(${varname} "${${repo_name}_SUPPLIER}" PARENT_SCOPE)
10295
ELSEIF (repo_name MATCHES "zlib|minizip")
10396
# stuff that is checked into out repos
10497
SET(${varname} "MariaDB" PARENT_SCOPE)
@@ -230,6 +223,7 @@ FUNCTION(GENERATE_SBOM)
230223
\"ref\": \"${CPACK_PACKAGE_NAME}\",
231224
\"dependsOn\": [" )
232225

226+
INCLUDE(3rdparty_info)
233227
SET(first ON)
234228
FOREACH(dep ${ALL_THIRD_PARTY})
235229
# Extract the part after the last "/" from URL
@@ -277,6 +271,14 @@ FUNCTION(GENERATE_SBOM)
277271
IF(cpe)
278272
SET(cpe "\n \"cpe\": \"${cpe}\",")
279273
ENDIF()
274+
SET(license "${${repo_name_lower}.license}")
275+
IF(NOT license)
276+
MESSAGE(FATAL_ERROR "no license for 3rd party dependency ${repo_name_lower}.")
277+
ENDIF()
278+
SET(copyright "${${repo_name_lower}.copyright}")
279+
IF(NOT copyright)
280+
SET(copyright NOASSERTION)
281+
ENDIF()
280282
STRING(APPEND sbom_components "
281283
{
282284
\"bom-ref\": \"${bom_ref}\",
@@ -286,7 +288,15 @@ FUNCTION(GENERATE_SBOM)
286288
\"purl\": \"${purl}\",${cpe}
287289
\"supplier\": {
288290
\"name\": \"${supplier}\"
289-
}
291+
},
292+
\"licenses\": [
293+
{
294+
\"license\": {
295+
\"id\": \"${license}\"
296+
}
297+
}
298+
],
299+
\"copyright\": \"${copyright}\"
290300
}")
291301
STRING(APPEND sbom_dependencies "
292302
\"${bom_ref}\"")
@@ -302,5 +312,6 @@ FUNCTION(GENERATE_SBOM)
302312
IF(NOT DEFINED CPACK_PACKAGE_VERSION)
303313
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
304314
ENDIF()
315+
STRING(TIMESTAMP CURRENT_YEAR "%Y")
305316
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/sbom.json.in ${CMAKE_BINARY_DIR}/sbom.json)
306317
ENDFUNCTION()

0 commit comments

Comments
 (0)