summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2023-03-10 09:35:50 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2023-03-10 09:35:50 +0200
commitf169dfb41adcb637732507ed56d3038003170a15 (patch)
tree233560fbdc966f7674618431a8ef75375831651a
parent25c048066a9557d1aa506220316c6fa57be5da91 (diff)
parent08267ba0c88d2f3ba1bacee9bb9a1e4da921a60a (diff)
downloadmariadb-git-f169dfb41adcb637732507ed56d3038003170a15.tar.gz
Merge 10.5 into 10.6
-rw-r--r--debian/libmariadb-dev.install1
-rw-r--r--include/CMakeLists.txt3
-rw-r--r--include/my_alloca.h45
-rw-r--r--include/my_global.h8
-rw-r--r--include/my_sys.h14
-rw-r--r--include/mysql/service_encryption.h11
-rw-r--r--plugin/cracklib_password_check/cracklib_password_check.c2
-rw-r--r--plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp5
-rw-r--r--plugin/handler_socket/libhsclient/allocator.hpp1
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/temporary_tables.cc13
-rw-r--r--storage/innobase/handler/ha_innodb.cc14
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc27
-rw-r--r--storage/innobase/rem/rem0rec.cc183
-rw-r--r--storage/innobase/srv/srv0start.cc2
15 files changed, 172 insertions, 159 deletions
diff --git a/debian/libmariadb-dev.install b/debian/libmariadb-dev.install
index 1e52e2acfdc..a0737fee00c 100644
--- a/debian/libmariadb-dev.install
+++ b/debian/libmariadb-dev.install
@@ -14,6 +14,7 @@ usr/include/mariadb/mariadb_version.h
usr/include/mariadb/my_config.h
usr/include/mariadb/my_global.h
usr/include/mariadb/my_sys.h
+usr/include/mariadb/my_alloca.h
usr/include/mariadb/mysql.h
usr/include/mariadb/mysql/
usr/include/mariadb/mysql/client_plugin.h
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 1024821e569..a82d1143649 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -37,6 +37,7 @@ SET(HEADERS
ma_dyncol.h
my_list.h
my_alloc.h
+ my_alloca.h
typelib.h
my_dbug.h
m_string.h
@@ -111,7 +112,9 @@ ${footer}
ENDMACRO()
INSTALL_COMPAT_HEADER(my_global.h "")
+INSTALL_COMPAT_HEADER(my_alloca.h "")
INSTALL_COMPAT_HEADER(my_config.h "")
+INSTALL_COMPAT_HEADER(my_alloca.h "")
INSTALL_COMPAT_HEADER(my_sys.h "")
INSTALL_COMPAT_HEADER(mysql_version.h "
#include <mariadb_version.h>
diff --git a/include/my_alloca.h b/include/my_alloca.h
new file mode 100644
index 00000000000..761c2adb890
--- /dev/null
+++ b/include/my_alloca.h
@@ -0,0 +1,45 @@
+/* Copyright (c) 2023, 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
+ 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 Street, Fifth Floor, Boston, MA 02110-1335 USA */
+
+#ifndef MY_ALLOCA_INCLUDED
+#define MY_ALLOCA_INCLUDED
+
+#ifdef _WIN32
+#include <malloc.h> /*for alloca*/
+/*
+ MSVC may define "alloca" when compiling in /Ze mode
+ (with extensions from Microsoft), but otherwise only
+ the _alloca function is defined:
+*/
+#ifndef alloca
+#define alloca _alloca
+#endif
+#else
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+#endif
+
+#if defined(HAVE_ALLOCA)
+/*
+ If the GCC/LLVM compiler from the MinGW is used,
+ alloca may not be defined when using the MSVC CRT:
+*/
+#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && !defined(alloca)
+#define alloca __builtin_alloca
+#endif /* GNUC */
+#endif
+
+#endif /* MY_ALLOCA_INCLUDED */
diff --git a/include/my_global.h b/include/my_global.h
index 2789ecc0bd0..e89249ec890 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -322,13 +322,6 @@ C_MODE_END
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
-#undef HAVE_ALLOCA
-#undef HAVE_ALLOCA_H
-#endif
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
#include <errno.h> /* Recommended by debian */
/* We need the following to go around a problem with openssl on solaris */
@@ -485,6 +478,7 @@ typedef unsigned short ushort;
#endif
#include <my_compiler.h>
+#include <my_alloca.h>
/*
Wen using the embedded library, users might run into link problems,
diff --git a/include/my_sys.h b/include/my_sys.h
index 892dde0fe82..d60153149ec 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -28,9 +28,7 @@ C_MODE_START
#include <m_ctype.h> /* for CHARSET_INFO */
#include <stdarg.h>
#include <typelib.h>
-#ifdef _WIN32
-#include <malloc.h> /*for alloca*/
-#endif
+#include <my_alloca.h>
#include <mysql/plugin.h>
#include <mysql/service_my_print_error.h>
@@ -193,16 +191,6 @@ my_bool my_test_if_thinly_provisioned(File handle);
extern my_bool my_may_have_atomic_write;
#if defined(HAVE_ALLOCA) && !defined(HAVE_valgrind)
-#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
-#pragma alloca
-#endif /* _AIX */
-#if defined(__MWERKS__)
-#undef alloca
-#define alloca _alloca
-#endif /* __MWERKS__ */
-#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
-#define alloca __builtin_alloca
-#endif /* GNUC */
#define my_alloca(SZ) alloca((size_t) (SZ))
#define my_afree(PTR) ((void)0)
#define MAX_ALLOCA_SZ 4096
diff --git a/include/mysql/service_encryption.h b/include/mysql/service_encryption.h
index 69d205a27e8..280b9c69e35 100644
--- a/include/mysql/service_encryption.h
+++ b/include/mysql/service_encryption.h
@@ -24,22 +24,19 @@
*provider* (encryption plugin).
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#ifndef MYSQL_ABI_CHECK
+#include <my_alloca.h>
#ifdef _WIN32
-#include <malloc.h>
#ifndef __cplusplus
#define inline __inline
#endif
#else
#include <stdlib.h>
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
#endif
#endif
+
+#ifdef __cplusplus
+extern "C" {
#endif
/* returned from encryption_key_get_latest_version() */
diff --git a/plugin/cracklib_password_check/cracklib_password_check.c b/plugin/cracklib_password_check/cracklib_password_check.c
index 470e6e5280f..5a7c7f3f234 100644
--- a/plugin/cracklib_password_check/cracklib_password_check.c
+++ b/plugin/cracklib_password_check/cracklib_password_check.c
@@ -13,7 +13,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-#include <my_global.h>
+#include <my_alloca.h>
#include <mysql/plugin_password_validation.h>
#include <crack.h>
#include <string.h>
diff --git a/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp b/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp
index 9863602af7a..f6bbe9004c2 100644
--- a/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp
+++ b/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp
@@ -6,7 +6,7 @@
* See COPYRIGHT.txt for details.
*/
-#include <my_global.h>
+#include <my_alloca.h>
#include <netinet/in.h>
#include <errno.h>
#include <poll.h>
@@ -17,9 +17,6 @@
#if __linux__
#include <sys/epoll.h>
#endif
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
#include "hstcpsvr_worker.hpp"
#include "string_buffer.hpp"
diff --git a/plugin/handler_socket/libhsclient/allocator.hpp b/plugin/handler_socket/libhsclient/allocator.hpp
index dd3a28ba7bd..9df6a1ab752 100644
--- a/plugin/handler_socket/libhsclient/allocator.hpp
+++ b/plugin/handler_socket/libhsclient/allocator.hpp
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
+#include <my_alloca.h>
#if 0
extern "C" {
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 7f72306189a..bce30b3fa6d 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -5302,7 +5302,7 @@ private:
bool use_temporary_table(TABLE *table, TABLE **out_table);
void close_temporary_table(TABLE *table);
bool log_events_and_free_tmp_shares();
- void free_tmp_table_share(TMP_TABLE_SHARE *share, bool delete_table);
+ bool free_tmp_table_share(TMP_TABLE_SHARE *share, bool delete_table);
void free_temporary_table(TABLE *table);
bool lock_temporary_tables();
void unlock_temporary_tables();
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc
index 8236d157b73..8555aa1a7f5 100644
--- a/sql/temporary_tables.cc
+++ b/sql/temporary_tables.cc
@@ -670,7 +670,7 @@ bool THD::drop_temporary_table(TABLE *table, bool *is_trans, bool delete_table)
temporary_tables->remove(share);
/* Free the TABLE_SHARE and/or delete the files. */
- free_tmp_table_share(share, delete_table);
+ result= free_tmp_table_share(share, delete_table);
end:
if (locked)
@@ -1455,20 +1455,21 @@ bool THD::log_events_and_free_tmp_shares()
@param share [IN] TABLE_SHARE to free
@param delete_table [IN] Whether to delete the table files?
- @return void
+ @return false Success
+ true Error
*/
-void THD::free_tmp_table_share(TMP_TABLE_SHARE *share, bool delete_table)
+bool THD::free_tmp_table_share(TMP_TABLE_SHARE *share, bool delete_table)
{
+ bool error= false;
DBUG_ENTER("THD::free_tmp_table_share");
if (delete_table)
{
- rm_temporary_table(share->db_type(), share->path.str);
+ error= rm_temporary_table(share->db_type(), share->path.str);
}
free_table_share(share);
my_free(share);
-
- DBUG_VOID_RETURN;
+ DBUG_RETURN(error);
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index db39874d067..aa2fb7c38eb 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -19488,10 +19488,22 @@ static MYSQL_SYSVAR_BOOL(numa_interleave, srv_numa_interleave,
NULL, NULL, FALSE);
#endif /* HAVE_LIBNUMA */
+static void innodb_change_buffering_update(THD *thd, struct st_mysql_sys_var*,
+ void*, const void *save)
+{
+ ulong i= *static_cast<const ulong*>(save);
+ if (i != IBUF_USE_NONE && !ibuf.index)
+ push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_NOT_KEYFILE,
+ "InnoDB: The change buffer is corrupted.");
+ else
+ innodb_change_buffering= i;
+}
+
static MYSQL_SYSVAR_ENUM(change_buffering, innodb_change_buffering,
PLUGIN_VAR_RQCMDARG,
"Buffer changes to secondary indexes.",
- NULL, NULL, IBUF_USE_NONE, &innodb_change_buffering_typelib);
+ nullptr, innodb_change_buffering_update,
+ IBUF_USE_NONE, &innodb_change_buffering_typelib);
static MYSQL_SYSVAR_UINT(change_buffer_max_size,
srv_change_buffer_max_size,
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index b87c5b052ae..2cdbbd88330 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -403,8 +403,13 @@ ibuf_init_at_db_start(void)
if (!header_page) {
err_exit:
- sql_print_error("InnoDB: The change buffer is corrupted");
+ sql_print_error("InnoDB: The change buffer is corrupted"
+ " or has been removed on upgrade"
+ " to MariaDB 11.0 or later");
mtr.commit();
+ if (innodb_change_buffering == IBUF_USE_NONE) {
+ err = DB_SUCCESS;
+ }
return err;
}
@@ -1978,6 +1983,7 @@ void
ibuf_free_excess_pages(void)
/*========================*/
{
+ if (UNIV_UNLIKELY(!ibuf.index)) return;
/* Free at most a few pages at a time, so that we do not delay the
requested service too much */
@@ -2419,6 +2425,7 @@ will be merged from ibuf trees to the pages read
@retval 0 if ibuf.empty */
ulint ibuf_contract()
{
+ if (UNIV_UNLIKELY(!ibuf.index)) return 0;
mtr_t mtr;
btr_cur_t cur;
ulint sum_sizes;
@@ -2468,6 +2475,7 @@ ibuf_merge_space(
/*=============*/
ulint space) /*!< in: tablespace id to merge */
{
+ if (UNIV_UNLIKELY(!ibuf.index)) return 0;
mtr_t mtr;
btr_pcur_t pcur;
@@ -2933,13 +2941,14 @@ void
ibuf_update_max_tablespace_id(void)
/*===============================*/
{
+ if (UNIV_UNLIKELY(!ibuf.index)) return;
const rec_t* rec;
const byte* field;
ulint len;
btr_pcur_t pcur;
mtr_t mtr;
- ut_a(!dict_table_is_comp(ibuf.index->table));
+ ut_ad(!ibuf.index->table->not_redundant());
ibuf_mtr_start(&mtr);
@@ -4418,6 +4427,8 @@ in DISCARD TABLESPACE, IMPORT TABLESPACE, or read-ahead.
@param[in] space missing or to-be-discarded tablespace */
void ibuf_delete_for_discarded_space(ulint space)
{
+ if (UNIV_UNLIKELY(!ibuf.index)) return;
+
btr_pcur_t pcur;
const rec_t* ibuf_rec;
mtr_t mtr;
@@ -4531,6 +4542,7 @@ ibuf_print(
/*=======*/
FILE* file) /*!< in: file where to print */
{
+ if (UNIV_UNLIKELY(!ibuf.index)) return;
mysql_mutex_lock(&ibuf_mutex);
fprintf(file,
@@ -4570,8 +4582,6 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
mtr_t mtr;
- mysql_mutex_lock(&ibuf_mutex);
-
/* The two bitmap pages (allocation bitmap and ibuf bitmap) repeat
every page_size pages. For example if page_size is 16 KiB, then the
two bitmap pages repeat every 16 KiB * 16384 = 256 MiB. In the loop
@@ -4580,18 +4590,14 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
for (uint32_t page_no = 0; page_no < size; page_no += physical_size) {
if (trx_is_interrupted(trx)) {
- mysql_mutex_unlock(&ibuf_mutex);
return(DB_INTERRUPTED);
}
mtr_start(&mtr);
- ibuf_enter(&mtr);
buf_block_t* bitmap_page = ibuf_bitmap_get_map_page(
page_id_t(space->id, page_no), zip_size, &mtr);
if (!bitmap_page) {
- mysql_mutex_unlock(&ibuf_mutex);
- ibuf_exit(&mtr);
mtr.commit();
return DB_CORRUPTION;
}
@@ -4614,7 +4620,6 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
physical_size)));
}
#endif /* UNIV_DEBUG */
- ibuf_exit(&mtr);
mtr_commit(&mtr);
continue;
}
@@ -4629,8 +4634,6 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
cur_page_id, zip_size,
IBUF_BITMAP_IBUF, &mtr)) {
- mysql_mutex_unlock(&ibuf_mutex);
- ibuf_exit(&mtr);
mtr_commit(&mtr);
ib_errf(trx->mysql_thd,
@@ -4664,11 +4667,9 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
}
}
- ibuf_exit(&mtr);
mtr_commit(&mtr);
}
- mysql_mutex_unlock(&ibuf_mutex);
return(DB_SUCCESS);
}
diff --git a/storage/innobase/rem/rem0rec.cc b/storage/innobase/rem/rem0rec.cc
index da6447c390e..98cf2dda900 100644
--- a/storage/innobase/rem/rem0rec.cc
+++ b/storage/innobase/rem/rem0rec.cc
@@ -217,14 +217,12 @@ rec_get_n_extern_new(
stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or
more, or when the field is stored externally. */
- if (DATA_BIG_COL(col)) {
- if (len & 0x80) {
- /* 1exxxxxxx xxxxxxxx */
- if (len & 0x40) {
- n_extern++;
- }
- lens--;
+ if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
+ /* 1exxxxxxx xxxxxxxx */
+ if (len & 0x40) {
+ n_extern++;
}
+ lens--;
}
}
} while (++i < n);
@@ -244,6 +242,10 @@ enum rec_leaf_format {
REC_LEAF_INSTANT
};
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 11
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wconversion" /* GCC 5 to 10 need this */
+#endif
/** Determine the offset to each field in a leaf-page record
in ROW_FORMAT=COMPACT,DYNAMIC,COMPRESSED.
This is a special case of rec_init_offsets() and rec_get_offsets_func().
@@ -361,8 +363,7 @@ start:
do {
if (mblob) {
if (i == index->first_user_field()) {
- offs = static_cast<rec_offs>(offs
- + FIELD_REF_SIZE);
+ offs += FIELD_REF_SIZE;
len = combine(offs, STORED_OFFPAGE);
any |= REC_OFFS_EXTERNAL;
field--;
@@ -433,27 +434,23 @@ start:
stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or
more, or when the field is stored externally. */
- if ((len & 0x80) && DATA_BIG_COL(col)) {
+ if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
/* 1exxxxxxx xxxxxxxx */
- len = static_cast<rec_offs>(len << 8
- | *lens--);
- offs = static_cast<rec_offs>(offs
- + get_value(len));
- if (UNIV_UNLIKELY(len & 0x4000)) {
- ut_ad(index->is_primary());
- any |= REC_OFFS_EXTERNAL;
- len = combine(offs, STORED_OFFPAGE);
- } else {
- len = offs;
- }
-
+ len <<= 8;
+ len |= *lens--;
+ static_assert(STORED_OFFPAGE == 0x4000, "");
+ static_assert(REC_OFFS_EXTERNAL == 0x4000, "");
+ const rec_offs ext = len & REC_OFFS_EXTERNAL;
+ offs += get_value(len);
+ len = offs | ext;
+ any |= ext;
+ ut_ad(!ext || index->is_primary());
continue;
}
- len = offs = static_cast<rec_offs>(offs + len);
+ len = offs += len;
} else {
- len = offs = static_cast<rec_offs>(offs
- + field->fixed_len);
+ len = offs += field->fixed_len;
}
} while (field++, rec_offs_base(offsets)[++i] = len,
i < rec_offs_n_fields(offsets));
@@ -679,8 +676,7 @@ rec_init_offsets(
do {
rec_offs len;
if (UNIV_UNLIKELY(i == n_node_ptr_field)) {
- len = offs = static_cast<rec_offs>(
- offs + REC_NODE_PTR_SIZE);
+ len = offs += REC_NODE_PTR_SIZE;
goto resolved;
}
@@ -720,29 +716,25 @@ rec_init_offsets(
encoded in two bytes when it is 128 or
more, or when the field is stored
externally. */
- if (DATA_BIG_COL(col)) {
- if (len & 0x80) {
- /* 1exxxxxxx xxxxxxxx */
- len = static_cast<rec_offs>(
- len << 8 | *lens--);
-
- /* B-tree node pointers
- must not contain externally
- stored columns. Thus
- the "e" flag must be 0. */
- ut_a(!(len & 0x4000));
- offs = static_cast<rec_offs>(
- offs + get_value(len));
- len = offs;
-
- goto resolved;
- }
+ if (UNIV_UNLIKELY(len & 0x80)
+ && DATA_BIG_COL(col)) {
+ /* 1exxxxxxx xxxxxxxx */
+ len <<= 8;
+ len |= *lens--;
+
+ /* B-tree node pointers
+ must not contain externally
+ stored columns. Thus
+ the "e" flag must be 0. */
+ ut_a(!(len & 0x4000));
+ offs += len & 0x3fff;
+ len = offs;
+ goto resolved;
}
- len = offs = static_cast<rec_offs>(offs + len);
+ len = offs += len;
} else {
- len = offs = static_cast<rec_offs>(
- offs + field->fixed_len);
+ len = offs += field->fixed_len;
}
resolved:
rec_offs_base(offsets)[i + 1] = len;
@@ -759,35 +751,30 @@ resolved:
rec_offs any;
if (rec_get_1byte_offs_flag(rec)) {
- offs = static_cast<rec_offs>(offs + n_fields);
+ offs += static_cast<rec_offs>(n_fields);
any = offs;
/* Determine offsets to fields */
do {
offs = rec_1_get_field_end_info(rec, i);
if (offs & REC_1BYTE_SQL_NULL_MASK) {
- offs &= static_cast<rec_offs>(
- ~REC_1BYTE_SQL_NULL_MASK);
- set_type(offs, SQL_NULL);
+ offs ^= REC_1BYTE_SQL_NULL_MASK
+ | SQL_NULL;
}
rec_offs_base(offsets)[1 + i] = offs;
} while (++i < n);
} else {
- offs = static_cast<rec_offs>(offs + 2 * n_fields);
+ offs += static_cast<rec_offs>(2 * n_fields);
any = offs;
/* Determine offsets to fields */
do {
offs = rec_2_get_field_end_info(rec, i);
- if (offs & REC_2BYTE_SQL_NULL_MASK) {
- offs &= static_cast<rec_offs>(
- ~REC_2BYTE_SQL_NULL_MASK);
- set_type(offs, SQL_NULL);
- }
- if (offs & REC_2BYTE_EXTERN_MASK) {
- offs &= static_cast<rec_offs>(
- ~REC_2BYTE_EXTERN_MASK);
- set_type(offs, STORED_OFFPAGE);
- any |= REC_OFFS_EXTERNAL;
- }
+ static_assert(REC_2BYTE_SQL_NULL_MASK
+ == SQL_NULL, "");
+ static_assert(REC_2BYTE_EXTERN_MASK
+ == STORED_OFFPAGE, "");
+ static_assert(REC_OFFS_EXTERNAL
+ == STORED_OFFPAGE, "");
+ any |= (offs & REC_OFFS_EXTERNAL);
rec_offs_base(offsets)[1 + i] = offs;
} while (++i < n);
}
@@ -999,8 +986,7 @@ rec_get_offsets_reverse(
do {
rec_offs len;
if (UNIV_UNLIKELY(i == n_node_ptr_field)) {
- len = offs = static_cast<rec_offs>(
- offs + REC_NODE_PTR_SIZE);
+ len = offs += REC_NODE_PTR_SIZE;
goto resolved;
}
@@ -1037,30 +1023,23 @@ rec_get_offsets_reverse(
stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or
more, or when the field is stored externally. */
- if (DATA_BIG_COL(col)) {
- if (len & 0x80) {
- /* 1exxxxxxx xxxxxxxx */
- len = static_cast<rec_offs>(
- len << 8 | *lens++);
-
- offs = static_cast<rec_offs>(
- offs + get_value(len));
- if (UNIV_UNLIKELY(len & 0x4000)) {
- any_ext = REC_OFFS_EXTERNAL;
- len = combine(offs,
- STORED_OFFPAGE);
- } else {
- len = offs;
- }
-
- goto resolved;
- }
+ if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
+ /* 1exxxxxxx xxxxxxxx */
+ len &= 0x7f;
+ len <<= 8;
+ len |= *lens++;
+ static_assert(STORED_OFFPAGE == 0x4000, "");
+ static_assert(REC_OFFS_EXTERNAL == 0x4000, "");
+ rec_offs ext = len & REC_OFFS_EXTERNAL;
+ offs += get_value(len);
+ len = offs | ext;
+ any_ext |= ext;
+ goto resolved;
}
- len = offs = static_cast<rec_offs>(offs + len);
+ len = offs += len;
} else {
- len = offs = static_cast<rec_offs>(offs
- + field->fixed_len);
+ len = offs += field->fixed_len;
}
resolved:
rec_offs_base(offsets)[i + 1] = len;
@@ -1100,7 +1079,7 @@ rec_get_nth_field_offs_old(
return(os);
}
- next_os = next_os & ~REC_1BYTE_SQL_NULL_MASK;
+ next_os &= ~REC_1BYTE_SQL_NULL_MASK;
} else {
os = rec_2_get_field_start_offs(rec, n);
@@ -1112,8 +1091,7 @@ rec_get_nth_field_offs_old(
return(os);
}
- next_os = next_os & ~(REC_2BYTE_SQL_NULL_MASK
- | REC_2BYTE_EXTERN_MASK);
+ next_os &= ~(REC_2BYTE_SQL_NULL_MASK | REC_2BYTE_EXTERN_MASK);
}
*len = next_os - os;
@@ -1266,7 +1244,8 @@ rec_get_converted_size_comp_prefix_low(
} else if (dfield_is_ext(dfield)) {
ut_ad(DATA_BIG_COL(field->col));
extra_size += 2;
- } else if (len < 128 || !DATA_BIG_COL(field->col)) {
+ } else if (UNIV_LIKELY(len < 128)
+ || !DATA_BIG_COL(field->col)) {
extra_size++;
} else {
/* For variable-length columns, we look up the
@@ -1617,14 +1596,7 @@ start:
/* set the null flag if necessary */
if (dfield_is_null(field)) {
-#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 6
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wconversion" /* GCC 5 may need this here */
-#endif
*nulls |= static_cast<byte>(null_mask);
-#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 6
-# pragma GCC diagnostic pop
-#endif
null_mask <<= 1;
continue;
}
@@ -1733,6 +1705,9 @@ rec_convert_dtuple_to_rec_new(
REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT);
return buf;
}
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 11
+# pragma GCC diagnostic pop /* ignored "-Wconversion" */
+#endif
/*********************************************************//**
Builds a physical record out of a data tuple and
@@ -2095,14 +2070,12 @@ rec_copy_prefix_to_buf(
stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or
more, or when the column is stored externally. */
- if (DATA_BIG_COL(col)) {
- if (len & 0x80) {
- /* 1exxxxxx */
- len &= 0x3f;
- len <<= 8;
- len |= *lens--;
- UNIV_PREFETCH_R(lens);
- }
+ if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
+ /* 1exxxxxx */
+ len &= 0x3f;
+ len <<= 8;
+ len |= *lens--;
+ UNIV_PREFETCH_R(lens);
}
prefix_len += len;
}
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index e3525ab194f..61f0a269d58 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -2001,7 +2001,7 @@ void innodb_shutdown()
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
ut_ad(lock_sys.is_initialised() || !srv_was_started);
ut_ad(log_sys.is_initialised() || !srv_was_started);
- ut_ad(ibuf.index || !srv_was_started
+ ut_ad(ibuf.index || !innodb_change_buffering || !srv_was_started
|| srv_force_recovery >= SRV_FORCE_NO_DDL_UNDO);
dict_stats_deinit();