Commit f169dfb4 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.5 into 10.6

parents 25c04806 08267ba0
...@@ -14,6 +14,7 @@ usr/include/mariadb/mariadb_version.h ...@@ -14,6 +14,7 @@ usr/include/mariadb/mariadb_version.h
usr/include/mariadb/my_config.h usr/include/mariadb/my_config.h
usr/include/mariadb/my_global.h usr/include/mariadb/my_global.h
usr/include/mariadb/my_sys.h usr/include/mariadb/my_sys.h
usr/include/mariadb/my_alloca.h
usr/include/mariadb/mysql.h usr/include/mariadb/mysql.h
usr/include/mariadb/mysql/ usr/include/mariadb/mysql/
usr/include/mariadb/mysql/client_plugin.h usr/include/mariadb/mysql/client_plugin.h
......
...@@ -37,6 +37,7 @@ SET(HEADERS ...@@ -37,6 +37,7 @@ SET(HEADERS
ma_dyncol.h ma_dyncol.h
my_list.h my_list.h
my_alloc.h my_alloc.h
my_alloca.h
typelib.h typelib.h
my_dbug.h my_dbug.h
m_string.h m_string.h
...@@ -111,7 +112,9 @@ ${footer} ...@@ -111,7 +112,9 @@ ${footer}
ENDMACRO() ENDMACRO()
INSTALL_COMPAT_HEADER(my_global.h "") INSTALL_COMPAT_HEADER(my_global.h "")
INSTALL_COMPAT_HEADER(my_alloca.h "")
INSTALL_COMPAT_HEADER(my_config.h "") INSTALL_COMPAT_HEADER(my_config.h "")
INSTALL_COMPAT_HEADER(my_alloca.h "")
INSTALL_COMPAT_HEADER(my_sys.h "") INSTALL_COMPAT_HEADER(my_sys.h "")
INSTALL_COMPAT_HEADER(mysql_version.h " INSTALL_COMPAT_HEADER(mysql_version.h "
#include <mariadb_version.h> #include <mariadb_version.h>
......
/* 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 */
...@@ -322,13 +322,6 @@ C_MODE_END ...@@ -322,13 +322,6 @@ C_MODE_END
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #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 */ #include <errno.h> /* Recommended by debian */
/* We need the following to go around a problem with openssl on solaris */ /* We need the following to go around a problem with openssl on solaris */
...@@ -485,6 +478,7 @@ typedef unsigned short ushort; ...@@ -485,6 +478,7 @@ typedef unsigned short ushort;
#endif #endif
#include <my_compiler.h> #include <my_compiler.h>
#include <my_alloca.h>
/* /*
Wen using the embedded library, users might run into link problems, Wen using the embedded library, users might run into link problems,
......
...@@ -28,9 +28,7 @@ C_MODE_START ...@@ -28,9 +28,7 @@ C_MODE_START
#include <m_ctype.h> /* for CHARSET_INFO */ #include <m_ctype.h> /* for CHARSET_INFO */
#include <stdarg.h> #include <stdarg.h>
#include <typelib.h> #include <typelib.h>
#ifdef _WIN32 #include <my_alloca.h>
#include <malloc.h> /*for alloca*/
#endif
#include <mysql/plugin.h> #include <mysql/plugin.h>
#include <mysql/service_my_print_error.h> #include <mysql/service_my_print_error.h>
...@@ -193,16 +191,6 @@ my_bool my_test_if_thinly_provisioned(File handle); ...@@ -193,16 +191,6 @@ my_bool my_test_if_thinly_provisioned(File handle);
extern my_bool my_may_have_atomic_write; extern my_bool my_may_have_atomic_write;
#if defined(HAVE_ALLOCA) && !defined(HAVE_valgrind) #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_alloca(SZ) alloca((size_t) (SZ))
#define my_afree(PTR) ((void)0) #define my_afree(PTR) ((void)0)
#define MAX_ALLOCA_SZ 4096 #define MAX_ALLOCA_SZ 4096
......
...@@ -24,22 +24,19 @@ ...@@ -24,22 +24,19 @@
*provider* (encryption plugin). *provider* (encryption plugin).
*/ */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef MYSQL_ABI_CHECK #ifndef MYSQL_ABI_CHECK
#include <my_alloca.h>
#ifdef _WIN32 #ifdef _WIN32
#include <malloc.h>
#ifndef __cplusplus #ifndef __cplusplus
#define inline __inline #define inline __inline
#endif #endif
#else #else
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif #endif
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif #endif
/* returned from encryption_key_get_latest_version() */ /* returned from encryption_key_get_latest_version() */
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ 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 <mysql/plugin_password_validation.h>
#include <crack.h> #include <crack.h>
#include <string.h> #include <string.h>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* See COPYRIGHT.txt for details. * See COPYRIGHT.txt for details.
*/ */
#include <my_global.h> #include <my_alloca.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <errno.h> #include <errno.h>
#include <poll.h> #include <poll.h>
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
#if __linux__ #if __linux__
#include <sys/epoll.h> #include <sys/epoll.h>
#endif #endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include "hstcpsvr_worker.hpp" #include "hstcpsvr_worker.hpp"
#include "string_buffer.hpp" #include "string_buffer.hpp"
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <my_alloca.h>
#if 0 #if 0
extern "C" { extern "C" {
......
...@@ -5302,7 +5302,7 @@ class THD: public THD_count, /* this must be first */ ...@@ -5302,7 +5302,7 @@ class THD: public THD_count, /* this must be first */
bool use_temporary_table(TABLE *table, TABLE **out_table); bool use_temporary_table(TABLE *table, TABLE **out_table);
void close_temporary_table(TABLE *table); void close_temporary_table(TABLE *table);
bool log_events_and_free_tmp_shares(); 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); void free_temporary_table(TABLE *table);
bool lock_temporary_tables(); bool lock_temporary_tables();
void unlock_temporary_tables(); void unlock_temporary_tables();
......
...@@ -670,7 +670,7 @@ bool THD::drop_temporary_table(TABLE *table, bool *is_trans, bool delete_table) ...@@ -670,7 +670,7 @@ bool THD::drop_temporary_table(TABLE *table, bool *is_trans, bool delete_table)
temporary_tables->remove(share); temporary_tables->remove(share);
/* Free the TABLE_SHARE and/or delete the files. */ /* 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: end:
if (locked) if (locked)
...@@ -1455,20 +1455,21 @@ bool THD::log_events_and_free_tmp_shares() ...@@ -1455,20 +1455,21 @@ bool THD::log_events_and_free_tmp_shares()
@param share [IN] TABLE_SHARE to free @param share [IN] TABLE_SHARE to free
@param delete_table [IN] Whether to delete the table files? @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"); DBUG_ENTER("THD::free_tmp_table_share");
if (delete_table) 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); free_table_share(share);
my_free(share); my_free(share);
DBUG_RETURN(error);
DBUG_VOID_RETURN;
} }
......
...@@ -19488,10 +19488,22 @@ static MYSQL_SYSVAR_BOOL(numa_interleave, srv_numa_interleave, ...@@ -19488,10 +19488,22 @@ static MYSQL_SYSVAR_BOOL(numa_interleave, srv_numa_interleave,
NULL, NULL, FALSE); NULL, NULL, FALSE);
#endif /* HAVE_LIBNUMA */ #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, static MYSQL_SYSVAR_ENUM(change_buffering, innodb_change_buffering,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG,
"Buffer changes to secondary indexes.", "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, static MYSQL_SYSVAR_UINT(change_buffer_max_size,
srv_change_buffer_max_size, srv_change_buffer_max_size,
......
...@@ -403,8 +403,13 @@ ibuf_init_at_db_start(void) ...@@ -403,8 +403,13 @@ ibuf_init_at_db_start(void)
if (!header_page) { if (!header_page) {
err_exit: 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(); mtr.commit();
if (innodb_change_buffering == IBUF_USE_NONE) {
err = DB_SUCCESS;
}
return err; return err;
} }
...@@ -1978,6 +1983,7 @@ void ...@@ -1978,6 +1983,7 @@ void
ibuf_free_excess_pages(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 /* Free at most a few pages at a time, so that we do not delay the
requested service too much */ requested service too much */
...@@ -2419,6 +2425,7 @@ will be merged from ibuf trees to the pages read ...@@ -2419,6 +2425,7 @@ will be merged from ibuf trees to the pages read
@retval 0 if ibuf.empty */ @retval 0 if ibuf.empty */
ulint ibuf_contract() ulint ibuf_contract()
{ {
if (UNIV_UNLIKELY(!ibuf.index)) return 0;
mtr_t mtr; mtr_t mtr;
btr_cur_t cur; btr_cur_t cur;
ulint sum_sizes; ulint sum_sizes;
...@@ -2468,6 +2475,7 @@ ibuf_merge_space( ...@@ -2468,6 +2475,7 @@ ibuf_merge_space(
/*=============*/ /*=============*/
ulint space) /*!< in: tablespace id to merge */ ulint space) /*!< in: tablespace id to merge */
{ {
if (UNIV_UNLIKELY(!ibuf.index)) return 0;
mtr_t mtr; mtr_t mtr;
btr_pcur_t pcur; btr_pcur_t pcur;
...@@ -2933,13 +2941,14 @@ void ...@@ -2933,13 +2941,14 @@ void
ibuf_update_max_tablespace_id(void) ibuf_update_max_tablespace_id(void)
/*===============================*/ /*===============================*/
{ {
if (UNIV_UNLIKELY(!ibuf.index)) return;
const rec_t* rec; const rec_t* rec;
const byte* field; const byte* field;
ulint len; ulint len;
btr_pcur_t pcur; btr_pcur_t pcur;
mtr_t mtr; mtr_t mtr;
ut_a(!dict_table_is_comp(ibuf.index->table)); ut_ad(!ibuf.index->table->not_redundant());
ibuf_mtr_start(&mtr); ibuf_mtr_start(&mtr);
...@@ -4418,6 +4427,8 @@ in DISCARD TABLESPACE, IMPORT TABLESPACE, or read-ahead. ...@@ -4418,6 +4427,8 @@ in DISCARD TABLESPACE, IMPORT TABLESPACE, or read-ahead.
@param[in] space missing or to-be-discarded tablespace */ @param[in] space missing or to-be-discarded tablespace */
void ibuf_delete_for_discarded_space(ulint space) void ibuf_delete_for_discarded_space(ulint space)
{ {
if (UNIV_UNLIKELY(!ibuf.index)) return;
btr_pcur_t pcur; btr_pcur_t pcur;
const rec_t* ibuf_rec; const rec_t* ibuf_rec;
mtr_t mtr; mtr_t mtr;
...@@ -4531,6 +4542,7 @@ ibuf_print( ...@@ -4531,6 +4542,7 @@ ibuf_print(
/*=======*/ /*=======*/
FILE* file) /*!< in: file where to print */ FILE* file) /*!< in: file where to print */
{ {
if (UNIV_UNLIKELY(!ibuf.index)) return;
mysql_mutex_lock(&ibuf_mutex); mysql_mutex_lock(&ibuf_mutex);
fprintf(file, fprintf(file,
...@@ -4570,8 +4582,6 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) ...@@ -4570,8 +4582,6 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
mtr_t mtr; mtr_t mtr;
mysql_mutex_lock(&ibuf_mutex);
/* The two bitmap pages (allocation bitmap and ibuf bitmap) repeat /* The two bitmap pages (allocation bitmap and ibuf bitmap) repeat
every page_size pages. For example if page_size is 16 KiB, then the 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 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) ...@@ -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) { for (uint32_t page_no = 0; page_no < size; page_no += physical_size) {
if (trx_is_interrupted(trx)) { if (trx_is_interrupted(trx)) {
mysql_mutex_unlock(&ibuf_mutex);
return(DB_INTERRUPTED); return(DB_INTERRUPTED);
} }
mtr_start(&mtr); mtr_start(&mtr);
ibuf_enter(&mtr);
buf_block_t* bitmap_page = ibuf_bitmap_get_map_page( buf_block_t* bitmap_page = ibuf_bitmap_get_map_page(
page_id_t(space->id, page_no), zip_size, &mtr); page_id_t(space->id, page_no), zip_size, &mtr);
if (!bitmap_page) { if (!bitmap_page) {
mysql_mutex_unlock(&ibuf_mutex);
ibuf_exit(&mtr);
mtr.commit(); mtr.commit();
return DB_CORRUPTION; return DB_CORRUPTION;
} }
...@@ -4614,7 +4620,6 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) ...@@ -4614,7 +4620,6 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
physical_size))); physical_size)));
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
ibuf_exit(&mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
continue; continue;
} }
...@@ -4629,8 +4634,6 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) ...@@ -4629,8 +4634,6 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
cur_page_id, zip_size, cur_page_id, zip_size,
IBUF_BITMAP_IBUF, &mtr)) { IBUF_BITMAP_IBUF, &mtr)) {
mysql_mutex_unlock(&ibuf_mutex);
ibuf_exit(&mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
ib_errf(trx->mysql_thd, ib_errf(trx->mysql_thd,
...@@ -4664,11 +4667,9 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) ...@@ -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); mtr_commit(&mtr);
} }
mysql_mutex_unlock(&ibuf_mutex);
return(DB_SUCCESS); return(DB_SUCCESS);
} }
......
...@@ -217,14 +217,12 @@ rec_get_n_extern_new( ...@@ -217,14 +217,12 @@ rec_get_n_extern_new(
stored in one byte for 0..127. The length stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or will be encoded in two bytes when it is 128 or
more, or when the field is stored externally. */ more, or when the field is stored externally. */
if (DATA_BIG_COL(col)) { if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
if (len & 0x80) { /* 1exxxxxxx xxxxxxxx */
/* 1exxxxxxx xxxxxxxx */ if (len & 0x40) {
if (len & 0x40) { n_extern++;
n_extern++;
}
lens--;
} }
lens--;
} }
} }
} while (++i < n); } while (++i < n);
...@@ -244,6 +242,10 @@ enum rec_leaf_format { ...@@ -244,6 +242,10 @@ enum rec_leaf_format {
REC_LEAF_INSTANT 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 /** Determine the offset to each field in a leaf-page record
in ROW_FORMAT=COMPACT,DYNAMIC,COMPRESSED. in ROW_FORMAT=COMPACT,DYNAMIC,COMPRESSED.
This is a special case of rec_init_offsets() and rec_get_offsets_func(). This is a special case of rec_init_offsets() and rec_get_offsets_func().
...@@ -361,8 +363,7 @@ rec_init_offsets_comp_ordinary( ...@@ -361,8 +363,7 @@ rec_init_offsets_comp_ordinary(
do { do {
if (mblob) { if (mblob) {
if (i == index->first_user_field()) { if (i == index->first_user_field()) {
offs = static_cast<rec_offs>(offs offs += FIELD_REF_SIZE;
+ FIELD_REF_SIZE);
len = combine(offs, STORED_OFFPAGE); len = combine(offs, STORED_OFFPAGE);
any |= REC_OFFS_EXTERNAL; any |= REC_OFFS_EXTERNAL;
field--; field--;
...@@ -433,27 +434,23 @@ rec_init_offsets_comp_ordinary( ...@@ -433,27 +434,23 @@ rec_init_offsets_comp_ordinary(
stored in one byte for 0..127. The length stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or will be encoded in two bytes when it is 128 or
more, or when the field is stored externally. */ 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 */ /* 1exxxxxxx xxxxxxxx */
len = static_cast<rec_offs>(len << 8 len <<= 8;
| *lens--); len |= *lens--;
offs = static_cast<rec_offs>(offs static_assert(STORED_OFFPAGE == 0x4000, "");
+ get_value(len)); static_assert(REC_OFFS_EXTERNAL == 0x4000, "");
if (UNIV_UNLIKELY(len & 0x4000)) { const rec_offs ext = len & REC_OFFS_EXTERNAL;
ut_ad(index->is_primary()); offs += get_value(len);
any |= REC_OFFS_EXTERNAL; len = offs | ext;
len = combine(offs, STORED_OFFPAGE); any |= ext;
} else { ut_ad(!ext || index->is_primary());
len = offs;
}
continue; continue;
} }
len = offs = static_cast<rec_offs>(offs + len); len = offs += len;
} else { } else {
len = offs = static_cast<rec_offs>(offs len = offs += field->fixed_len;
+ field->fixed_len);
} }
} while (field++, rec_offs_base(offsets)[++i] = len, } while (field++, rec_offs_base(offsets)[++i] = len,
i < rec_offs_n_fields(offsets)); i < rec_offs_n_fields(offsets));
...@@ -679,8 +676,7 @@ rec_init_offsets( ...@@ -679,8 +676,7 @@ rec_init_offsets(
do { do {
rec_offs len; rec_offs len;
if (UNIV_UNLIKELY(i == n_node_ptr_field)) { if (UNIV_UNLIKELY(i == n_node_ptr_field)) {
len = offs = static_cast<rec_offs>( len = offs += REC_NODE_PTR_SIZE;
offs + REC_NODE_PTR_SIZE);
goto resolved; goto resolved;
} }
...@@ -720,29 +716,25 @@ rec_init_offsets( ...@@ -720,29 +716,25 @@ rec_init_offsets(
encoded in two bytes when it is 128 or encoded in two bytes when it is 128 or
more, or when the field is stored more, or when the field is stored
externally. */ externally. */
if (DATA_BIG_COL(col)) { if (UNIV_UNLIKELY(len & 0x80)
if (len & 0x80) { && DATA_BIG_COL(col)) {
/* 1exxxxxxx xxxxxxxx */ /* 1exxxxxxx xxxxxxxx */
len = static_cast<rec_offs>( len <<= 8;
len << 8 | *lens--); len |= *lens--;
/* B-tree node pointers /* B-tree node pointers
must not contain externally must not contain externally
stored columns. Thus stored columns. Thus
the "e" flag must be 0. */ the "e" flag must be 0. */
ut_a(!(len & 0x4000)); ut_a(!(len & 0x4000));
offs = static_cast<rec_offs>( offs += len & 0x3fff;
offs + get_value(len)); len = offs;
len = offs; goto resolved;
goto resolved;
}
} }
len = offs = static_cast<rec_offs>(offs + len); len = offs += len;
} else { } else {
len = offs = static_cast<rec_offs>( len = offs += field->fixed_len;
offs + field->fixed_len);
} }
resolved: resolved:
rec_offs_base(offsets)[i + 1] = len; rec_offs_base(offsets)[i + 1] = len;
...@@ -759,35 +751,30 @@ rec_init_offsets( ...@@ -759,35 +751,30 @@ rec_init_offsets(
rec_offs any; rec_offs any;
if (rec_get_1byte_offs_flag(rec)) { if (rec_get_1byte_offs_flag(rec)) {
offs = static_cast<rec_offs>(offs + n_fields); offs += static_cast<rec_offs>(n_fields);
any = offs; any = offs;
/* Determine offsets to fields */ /* Determine offsets to fields */
do { do {
offs = rec_1_get_field_end_info(rec, i); offs = rec_1_get_field_end_info(rec, i);
if (offs & REC_1BYTE_SQL_NULL_MASK) { if (offs & REC_1BYTE_SQL_NULL_MASK) {
offs &= static_cast<rec_offs>( offs ^= REC_1BYTE_SQL_NULL_MASK
~REC_1BYTE_SQL_NULL_MASK); | SQL_NULL;
set_type(offs, SQL_NULL);
} }
rec_offs_base(offsets)[1 + i] = offs; rec_offs_base(offsets)[1 + i] = offs;
} while (++i < n); } while (++i < n);
} else { } else {
offs = static_cast<rec_offs>(offs + 2 * n_fields); offs += static_cast<rec_offs>(2 * n_fields);
any = offs; any = offs;
/* Determine offsets to fields */ /* Determine offsets to fields */
do { do {
offs = rec_2_get_field_end_info(rec, i); offs = rec_2_get_field_end_info(rec, i);
if (offs & REC_2BYTE_SQL_NULL_MASK) { static_assert(REC_2BYTE_SQL_NULL_MASK
offs &= static_cast<rec_offs>( == SQL_NULL, "");
~REC_2BYTE_SQL_NULL_MASK); static_assert(REC_2BYTE_EXTERN_MASK
set_type(offs, SQL_NULL); == STORED_OFFPAGE, "");
} static_assert(REC_OFFS_EXTERNAL
if (offs & REC_2BYTE_EXTERN_MASK) { == STORED_OFFPAGE, "");
offs &= static_cast<rec_offs>( any |= (offs & REC_OFFS_EXTERNAL);
~REC_2BYTE_EXTERN_MASK);
set_type(offs, STORED_OFFPAGE);
any |= REC_OFFS_EXTERNAL;
}
rec_offs_base(offsets)[1 + i] = offs; rec_offs_base(offsets)[1 + i] = offs;
} while (++i < n); } while (++i < n);
} }
...@@ -999,8 +986,7 @@ rec_get_offsets_reverse( ...@@ -999,8 +986,7 @@ rec_get_offsets_reverse(
do { do {
rec_offs len; rec_offs len;
if (UNIV_UNLIKELY(i == n_node_ptr_field)) { if (UNIV_UNLIKELY(i == n_node_ptr_field)) {
len = offs = static_cast<rec_offs>( len = offs += REC_NODE_PTR_SIZE;
offs + REC_NODE_PTR_SIZE);
goto resolved; goto resolved;
} }
...@@ -1037,30 +1023,23 @@ rec_get_offsets_reverse( ...@@ -1037,30 +1023,23 @@ rec_get_offsets_reverse(
stored in one byte for 0..127. The length stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or will be encoded in two bytes when it is 128 or
more, or when the field is stored externally. */ more, or when the field is stored externally. */
if (DATA_BIG_COL(col)) { if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
if (len & 0x80) { /* 1exxxxxxx xxxxxxxx */
/* 1exxxxxxx xxxxxxxx */ len &= 0x7f;
len = static_cast<rec_offs>( len <<= 8;
len << 8 | *lens++); len |= *lens++;
static_assert(STORED_OFFPAGE == 0x4000, "");
offs = static_cast<rec_offs>( static_assert(REC_OFFS_EXTERNAL == 0x4000, "");
offs + get_value(len)); rec_offs ext = len & REC_OFFS_EXTERNAL;
if (UNIV_UNLIKELY(len & 0x4000)) { offs += get_value(len);
any_ext = REC_OFFS_EXTERNAL; len = offs | ext;
len = combine(offs, any_ext |= ext;
STORED_OFFPAGE); goto resolved;
} else {
len = offs;
}
goto resolved;
}
} }
len = offs = static_cast<rec_offs>(offs + len); len = offs += len;
} else { } else {
len = offs = static_cast<rec_offs>(offs len = offs += field->fixed_len;
+ field->fixed_len);
} }
resolved: resolved:
rec_offs_base(offsets)[i + 1] = len; rec_offs_base(offsets)[i + 1] = len;
...@@ -1100,7 +1079,7 @@ rec_get_nth_field_offs_old( ...@@ -1100,7 +1079,7 @@ rec_get_nth_field_offs_old(
return(os); return(os);
} }
next_os = next_os & ~REC_1BYTE_SQL_NULL_MASK; next_os &= ~REC_1BYTE_SQL_NULL_MASK;
} else { } else {
os = rec_2_get_field_start_offs(rec, n); os = rec_2_get_field_start_offs(rec, n);
...@@ -1112,8 +1091,7 @@ rec_get_nth_field_offs_old( ...@@ -1112,8 +1091,7 @@ rec_get_nth_field_offs_old(
return(os); return(os);
} }
next_os = next_os & ~(REC_2BYTE_SQL_NULL_MASK next_os &= ~(REC_2BYTE_SQL_NULL_MASK | REC_2BYTE_EXTERN_MASK);
| REC_2BYTE_EXTERN_MASK);
} }
*len = next_os - os; *len = next_os - os;
...@@ -1266,7 +1244,8 @@ rec_get_converted_size_comp_prefix_low( ...@@ -1266,7 +1244,8 @@ rec_get_converted_size_comp_prefix_low(
} else if (dfield_is_ext(dfield)) { } else if (dfield_is_ext(dfield)) {
ut_ad(DATA_BIG_COL(field->col)); ut_ad(DATA_BIG_COL(field->col));
extra_size += 2; 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++; extra_size++;
} else { } else {
/* For variable-length columns, we look up the /* For variable-length columns, we look up the
...@@ -1617,14 +1596,7 @@ rec_convert_dtuple_to_rec_comp( ...@@ -1617,14 +1596,7 @@ rec_convert_dtuple_to_rec_comp(
/* set the null flag if necessary */ /* set the null flag if necessary */
if (dfield_is_null(field)) { 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); *nulls |= static_cast<byte>(null_mask);
#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 6
# pragma GCC diagnostic pop
#endif
null_mask <<= 1; null_mask <<= 1;
continue; continue;
} }
...@@ -1733,6 +1705,9 @@ rec_convert_dtuple_to_rec_new( ...@@ -1733,6 +1705,9 @@ rec_convert_dtuple_to_rec_new(
REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT); REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT);
return buf; 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 Builds a physical record out of a data tuple and
...@@ -2095,14 +2070,12 @@ rec_copy_prefix_to_buf( ...@@ -2095,14 +2070,12 @@ rec_copy_prefix_to_buf(
stored in one byte for 0..127. The length stored in one byte for 0..127. The length
will be encoded in two bytes when it is 128 or will be encoded in two bytes when it is 128 or
more, or when the column is stored externally. */ more, or when the column is stored externally. */
if (DATA_BIG_COL(col)) { if (UNIV_UNLIKELY(len & 0x80) && DATA_BIG_COL(col)) {
if (len & 0x80) { /* 1exxxxxx */
/* 1exxxxxx */ len &= 0x3f;
len &= 0x3f; len <<= 8;
len <<= 8; len |= *lens--;
len |= *lens--; UNIV_PREFETCH_R(lens);
UNIV_PREFETCH_R(lens);
}
} }
prefix_len += len; prefix_len += len;
} }
......
...@@ -2001,7 +2001,7 @@ void innodb_shutdown() ...@@ -2001,7 +2001,7 @@ void innodb_shutdown()
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO); || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
ut_ad(lock_sys.is_initialised() || !srv_was_started); ut_ad(lock_sys.is_initialised() || !srv_was_started);
ut_ad(log_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); || srv_force_recovery >= SRV_FORCE_NO_DDL_UNDO);
dict_stats_deinit(); dict_stats_deinit();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment