Merge branch '10.1' into 10.2

This commit is contained in:
Oleksandr Byelkin 2019-10-30 21:33:01 +01:00
commit 36f67a7dff
42 changed files with 353 additions and 226 deletions

View File

@ -226,11 +226,8 @@ typedef struct _db_code_state_ {
const char *file; /* Name of current user file */ const char *file; /* Name of current user file */
struct _db_stack_frame_ *framep; /* Pointer to current frame */ struct _db_stack_frame_ *framep; /* Pointer to current frame */
struct settings *stack; /* debugging settings */ struct settings *stack; /* debugging settings */
const char *jmpfunc; /* Remember current function for setjmp */
const char *jmpfile; /* Remember current file for setjmp */
int lineno; /* Current debugger output line number */ int lineno; /* Current debugger output line number */
uint level; /* Current function nesting level */ uint level; /* Current function nesting level */
int jmplevel; /* Remember nesting level at setjmp() */
/* /*
* The following variables are used to hold the state information * The following variables are used to hold the state information

View File

@ -131,8 +131,6 @@ max_binlog_size = 100M
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many! # Read the manual for more InnoDB related options. There are many!
default_storage_engine = InnoDB default_storage_engine = InnoDB
# you can't just change log file size, requires special procedure
#innodb_log_file_size = 50M
innodb_buffer_pool_size = 256M innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 8M innodb_log_buffer_size = 8M
innodb_file_per_table = 1 innodb_file_per_table = 1

View File

@ -567,7 +567,7 @@ Variable_name Value
auto_increment_increment 65535 auto_increment_increment 65535
auto_increment_offset 65535 auto_increment_offset 65535
INSERT INTO t1 VALUES (NULL),(NULL); INSERT INTO t1 VALUES (NULL),(NULL);
ERROR HY000: Failed to read auto-increment value from storage engine ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t1; SELECT * FROM t1;
c1 c1
1 1
@ -677,7 +677,7 @@ SELECT a,b FROM t;
a b a b
1 S1 1 S1
3 S2 3 S2
4 S2 5 S2
disconnect con1; disconnect con1;
connection default; connection default;
# Client 1: Insert a record with auto_increment_increment=1 # Client 1: Insert a record with auto_increment_increment=1
@ -688,14 +688,14 @@ t CREATE TABLE `t` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL, `b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1
INSERT INTO t(b) VALUES('S1'); INSERT INTO t(b) VALUES('S1');
SELECT a,b FROM t; SELECT a,b FROM t;
a b a b
1 S1 1 S1
3 S2 3 S2
4 S2 5 S2
5 S1 6 S1
DROP TABLE t; DROP TABLE t;
# Autoincrement behaviour with mixed insert. # Autoincrement behaviour with mixed insert.
CREATE TABLE t( CREATE TABLE t(
@ -733,22 +733,22 @@ t CREATE TABLE `t` (
`a` tinyint(4) NOT NULL AUTO_INCREMENT, `a` tinyint(4) NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL, `b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1 ) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=latin1
INSERT INTO t(b) VALUES('S4'); INSERT INTO t(b) VALUES('S4');
SELECT * FROM t; SELECT * FROM t;
a b a b
1 S0 1 S0
11 S1 11 S1
22 S3
23 S4
28 S2 28 S2
31 S3
32 S4
SHOW CREATE TABLE t; SHOW CREATE TABLE t;
Table Create Table Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` tinyint(4) NOT NULL AUTO_INCREMENT, `a` tinyint(4) NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL, `b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=latin1 ) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=latin1
DROP TABLE t; DROP TABLE t;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5; SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
@ -789,7 +789,7 @@ t2 CREATE TABLE `t2` (
`n` int(10) unsigned NOT NULL, `n` int(10) unsigned NOT NULL,
`o` enum('FALSE','TRUE') DEFAULT NULL, `o` enum('FALSE','TRUE') DEFAULT NULL,
PRIMARY KEY (`m`) PRIMARY KEY (`m`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1 ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1
INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
@ -1472,13 +1472,13 @@ SELECT * FROM t;
i i
1 1
301 301
351 601
SHOW CREATE TABLE t; SHOW CREATE TABLE t;
Table Create Table Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`i` int(11) NOT NULL AUTO_INCREMENT, `i` int(11) NOT NULL AUTO_INCREMENT,
KEY `i` (`i`) KEY `i` (`i`)
) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=latin1 ) ENGINE=InnoDB AUTO_INCREMENT=651 DEFAULT CHARSET=latin1
DROP TABLE t; DROP TABLE t;
SET auto_increment_increment = DEFAULT; SET auto_increment_increment = DEFAULT;
# #

View File

@ -349,7 +349,7 @@ INSERT INTO t1 VALUES (18446744073709551610); #-- 2^64 - 2
SELECT * FROM t1; SELECT * FROM t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976; SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976;
SHOW VARIABLES LIKE "auto_inc%"; SHOW VARIABLES LIKE "auto_inc%";
--error 1467 --error HA_ERR_AUTOINC_ERANGE
INSERT INTO t1 VALUES (NULL),(NULL); INSERT INTO t1 VALUES (NULL),(NULL);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;

View File

@ -1215,7 +1215,7 @@
VARIABLE_NAME INNODB_VERSION VARIABLE_NAME INNODB_VERSION
SESSION_VALUE NULL SESSION_VALUE NULL
-GLOBAL_VALUE 5.6.45 -GLOBAL_VALUE 5.6.45
+GLOBAL_VALUE 5.6.44-86.0 +GLOBAL_VALUE 5.6.45-86.1
GLOBAL_VALUE_ORIGIN COMPILE-TIME GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL DEFAULT_VALUE NULL
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL

View File

@ -685,7 +685,7 @@
VARIABLE_NAME INNODB_VERSION VARIABLE_NAME INNODB_VERSION
SESSION_VALUE NULL SESSION_VALUE NULL
-GLOBAL_VALUE 5.6.45 -GLOBAL_VALUE 5.6.45
+GLOBAL_VALUE 5.6.44-86.0 +GLOBAL_VALUE 5.6.45-86.1
GLOBAL_VALUE_ORIGIN COMPILE-TIME GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL DEFAULT_VALUE NULL
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL

View File

@ -7861,8 +7861,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
item->maybe_null= (fields_info->field_flags & MY_I_S_MAYBE_NULL); item->maybe_null= (fields_info->field_flags & MY_I_S_MAYBE_NULL);
field_count++; field_count++;
} }
TMP_TABLE_PARAM *tmp_table_param = TMP_TABLE_PARAM *tmp_table_param = new (thd->mem_root) TMP_TABLE_PARAM;
(TMP_TABLE_PARAM*) (thd->alloc(sizeof(TMP_TABLE_PARAM)));
tmp_table_param->init(); tmp_table_param->init();
tmp_table_param->table_charset= cs; tmp_table_param->table_charset= cs;
tmp_table_param->field_count= field_count; tmp_table_param->field_count= field_count;

View File

@ -73,6 +73,10 @@ ELSE(NOT UNIX)
tabwmi.cpp tabwmi.h tabmac.cpp tabmac.h macutil.cpp macutil.h) tabwmi.cpp tabwmi.h tabmac.cpp tabmac.h macutil.cpp macutil.h)
# Add exception handling to the CONNECT project) # Add exception handling to the CONNECT project)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
SET(IPHLPAPI_LIBRARY iphlpapi.lib) SET(IPHLPAPI_LIBRARY iphlpapi.lib)
IF(MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES Clang)) IF(MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES Clang))
# Connect does not work with clang-cl # Connect does not work with clang-cl

View File

@ -194,7 +194,7 @@ static void PROFILE_Save( FILE *file, PROFILESECTION *section )
} }
for (key = section->key; key; key = key->next) for (key = section->key; key; key = key->next)
if (key->name[0]) { if (key->name && key->name[0]) {
fprintf(file, "%s", SVP(key->name)); fprintf(file, "%s", SVP(key->name));
if (key->value) if (key->value)

View File

@ -431,6 +431,10 @@ int ha_heap::reset_auto_increment(ulonglong value)
int ha_heap::external_lock(THD *thd, int lock_type) int ha_heap::external_lock(THD *thd, int lock_type)
{ {
#ifndef DBUG_OFF
if (lock_type == F_UNLCK && file->s->changed && heap_check_heap(file, 0))
return HA_ERR_CRASHED;
#endif
return 0; // No external locking return 0; // No external locking
} }

View File

@ -35,12 +35,6 @@ int hp_close(register HP_INFO *info)
{ {
int error=0; int error=0;
DBUG_ENTER("hp_close"); DBUG_ENTER("hp_close");
#ifndef DBUG_OFF
if (info->s->changed && heap_check_heap(info,0))
{
error=my_errno=HA_ERR_CRASHED;
}
#endif
info->s->changed=0; info->s->changed=0;
if (info->open_list.data) if (info->open_list.data)
heap_open_list=list_delete(heap_open_list,&info->open_list); heap_open_list=list_delete(heap_open_list,&info->open_list);

View File

@ -0,0 +1,11 @@
UseTab: Always
TabWidth: 8
IndentWidth: 8
ContinuationIndentWidth: 8
BreakBeforeBinaryOperators: All
PointerAlignment: Left
BreakBeforeBraces: Custom
ColumnLimit: 79
BraceWrapping:
AfterFunction: true
AccessModifierOffset: -8

View File

@ -2667,11 +2667,10 @@ innobase_next_autoinc(
if (next_value == 0) { if (next_value == 0) {
ulonglong next; ulonglong next;
if (current >= offset) { if (current > offset) {
next = (current - offset) / step; next = (current - offset) / step;
} else { } else {
next = 0; next = (offset - current) / step;
block -= step;
} }
ut_a(max_value > next); ut_a(max_value > next);
@ -16834,6 +16833,37 @@ ha_innobase::get_auto_increment(
ut_ad(autoinc > 0); ut_ad(autoinc > 0);
} }
/** The following logic is needed to avoid duplicate key error
for autoincrement column.
(1) InnoDB gives the current autoincrement value with respect
to increment and offset value.
(2) Basically it does compute_next_insert_id() logic inside InnoDB
to avoid the current auto increment value changed by handler layer.
(3) It is restricted only for insert operations. */
if (increment > 1 && thd_sql_command(m_user_thd) != SQLCOM_ALTER_TABLE
&& autoinc < col_max_value) {
ulonglong prev_auto_inc = autoinc;
autoinc = ((autoinc - 1) + increment - offset)/ increment;
autoinc = autoinc * increment + offset;
/* If autoinc exceeds the col_max_value then reset
to old autoinc value. Because in case of non-strict
sql mode, boundary value is not considered as error. */
if (autoinc >= col_max_value) {
autoinc = prev_auto_inc;
}
ut_ad(autoinc > 0);
}
/* Called for the first time ? */ /* Called for the first time ? */
if (trx->n_autoinc_rows == 0) { if (trx->n_autoinc_rows == 0) {
@ -16871,27 +16901,6 @@ ha_innobase::get_auto_increment(
current = *first_value; current = *first_value;
if (m_prebuilt->autoinc_increment != increment) {
WSREP_DEBUG("autoinc decrease: %llu -> %llu\n"
"THD: %ld, current: %llu, autoinc: %llu",
m_prebuilt->autoinc_increment,
increment,
thd_get_thread_id(m_user_thd),
current, autoinc);
if (!wsrep_on(m_user_thd)) {
current = autoinc
- m_prebuilt->autoinc_increment;
current = innobase_next_autoinc(
current, 1, increment, offset, col_max_value);
}
dict_table_autoinc_initialize(
m_prebuilt->table, current);
*first_value = current;
}
/* Compute the last value in the interval */ /* Compute the last value in the interval */
next_value = innobase_next_autoinc( next_value = innobase_next_autoinc(
current, *nb_reserved_values, increment, offset, current, *nb_reserved_values, increment, offset,

View File

@ -90,6 +90,7 @@ CONFIGURE_FILE(tokudb.cnf.in tokudb.cnf @ONLY)
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-shadow") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-shadow")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla" DEBUG) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla" DEBUG)
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-implicit-fallthrough") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-implicit-fallthrough")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-cpp" DEBUG)
############################################ ############################################
MARK_AS_ADVANCED(BUILDNAME) MARK_AS_ADVANCED(BUILDNAME)

View File

@ -6,7 +6,7 @@ FUNCTION(TOKU_GET_DEPENDEND_OS_LIBS target result)
IF(deps) IF(deps)
FOREACH(lib ${deps}) FOREACH(lib ${deps})
# Filter out keywords for used for debug vs optimized builds # Filter out keywords for used for debug vs optimized builds
IF(NOT lib MATCHES "general" AND NOT lib MATCHES "debug" AND NOT lib MATCHES "optimized") IF(TARGET ${lib})
GET_TARGET_PROPERTY(lib_location ${lib} LOCATION) GET_TARGET_PROPERTY(lib_location ${lib} LOCATION)
IF(NOT lib_location) IF(NOT lib_location)
SET(ret ${ret} ${lib}) SET(ret ${ret} ${lib})

View File

@ -1,39 +1,5 @@
include(ExternalProject) include(ExternalProject)
if (CMAKE_PROJECT_NAME STREQUAL TokuDB)
## add jemalloc with an external project
set(JEMALLOC_SOURCE_DIR "${TokuDB_SOURCE_DIR}/third_party/jemalloc" CACHE FILEPATH "Where to find jemalloc sources.")
if (EXISTS "${JEMALLOC_SOURCE_DIR}/configure")
set(jemalloc_configure_opts "CC=${CMAKE_C_COMPILER}" "--with-jemalloc-prefix=" "--with-private-namespace=tokudb_jemalloc_internal_" "--enable-cc-silence")
option(JEMALLOC_DEBUG "Build jemalloc with --enable-debug." OFF)
if (JEMALLOC_DEBUG)
list(APPEND jemalloc_configure_opts --enable-debug)
endif ()
ExternalProject_Add(build_jemalloc
PREFIX jemalloc
SOURCE_DIR "${JEMALLOC_SOURCE_DIR}"
CONFIGURE_COMMAND
"${JEMALLOC_SOURCE_DIR}/configure" ${jemalloc_configure_opts}
"--prefix=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc"
)
add_library(jemalloc STATIC IMPORTED GLOBAL)
set_target_properties(jemalloc PROPERTIES IMPORTED_LOCATION
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc/lib/libjemalloc_pic.a")
add_dependencies(jemalloc build_jemalloc)
add_library(jemalloc_nopic STATIC IMPORTED GLOBAL)
set_target_properties(jemalloc_nopic PROPERTIES IMPORTED_LOCATION
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc/lib/libjemalloc.a")
add_dependencies(jemalloc_nopic build_jemalloc)
# detect when we are being built as a subproject
if (NOT DEFINED MYSQL_PROJECT_NAME_DOCSTRING)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc/lib" DESTINATION .
COMPONENT tokukv_libs_extra)
endif ()
endif ()
endif ()
## add lzma with an external project ## add lzma with an external project
set(xz_configure_opts --with-pic --enable-static) set(xz_configure_opts --with-pic --enable-static)
if (APPLE) if (APPLE)

View File

@ -26,7 +26,7 @@ if [ ! -d build ] ; then
-D RUN_LONG_TESTS=ON \ -D RUN_LONG_TESTS=ON \
-D TOKUDB_DATA=$tokudbdir/../tokudb.data \ -D TOKUDB_DATA=$tokudbdir/../tokudb.data \
.. ..
ninja build_jemalloc build_lzma build_snappy ninja build_lzma build_snappy
popd popd
fi fi

View File

@ -25,7 +25,7 @@ if [ ! -d build ] ; then
-D RUN_LONG_TESTS=ON \ -D RUN_LONG_TESTS=ON \
-D TOKUDB_DATA=$tokudbdir/../tokudb.data \ -D TOKUDB_DATA=$tokudbdir/../tokudb.data \
.. ..
ninja build_jemalloc build_lzma build_snappy ninja build_lzma build_snappy
popd popd
fi fi

View File

@ -25,7 +25,7 @@ if [ ! -d build ] ; then
-D RUN_LONG_TESTS=ON \ -D RUN_LONG_TESTS=ON \
-D TOKUDB_DATA=$tokudbdir/../tokudb.data \ -D TOKUDB_DATA=$tokudbdir/../tokudb.data \
.. ..
ninja build_jemalloc build_lzma build_snappy ninja build_lzma build_snappy
popd popd
fi fi

View File

@ -1077,7 +1077,8 @@ static inline int tokudb_generate_row(DB* dest_db,
} }
buff = (uchar *)dest_key->data; buff = (uchar *)dest_key->data;
assert_always(buff != NULL && max_key_len > 0); assert_always(buff != nullptr);
assert_always(max_key_len > 0);
} else { } else {
assert_unreachable(); assert_unreachable();
} }

View File

@ -387,7 +387,8 @@ inline void TOKUDB_SHARE::init_cardinality_counts(
assert_debug(_mutex.is_owned_by_me()); assert_debug(_mutex.is_owned_by_me());
// can not change number of keys live // can not change number of keys live
assert_always(_rec_per_key == NULL && _rec_per_keys == 0); assert_always(_rec_per_key == nullptr);
assert_always(_rec_per_keys == 0);
_rec_per_keys = rec_per_keys; _rec_per_keys = rec_per_keys;
_rec_per_key = rec_per_key; _rec_per_key = rec_per_key;
} }

View File

@ -953,9 +953,8 @@ static inline int tokudb_compare_two_hidden_keys(
const void* saved_key_data, const void* saved_key_data,
const uint32_t saved_key_size const uint32_t saved_key_size
) { ) {
assert_always( assert_always(new_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH);
(new_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH) && assert_always(saved_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH);
(saved_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH));
ulonglong a = hpk_char_to_num((uchar *) new_key_data); ulonglong a = hpk_char_to_num((uchar *) new_key_data);
ulonglong b = hpk_char_to_num((uchar *) saved_key_data); ulonglong b = hpk_char_to_num((uchar *) saved_key_data);
return a < b ? -1 : (a > b ? 1 : 0); return a < b ? -1 : (a > b ? 1 : 0);
@ -2533,7 +2532,8 @@ static uint32_t create_toku_secondary_key_pack_descriptor (
bool is_col_in_pk = false; bool is_col_in_pk = false;
if (bitmap_is_set(&kc_info->key_filters[pk_index],field_index)) { if (bitmap_is_set(&kc_info->key_filters[pk_index],field_index)) {
assert_always(!has_hpk && prim_key != NULL); assert_always(!has_hpk);
assert_always(prim_key != nullptr);
is_col_in_pk = true; is_col_in_pk = true;
} }
else { else {

View File

@ -54,16 +54,20 @@ static void test_int8() {
assert(over); assert(over);
else if (m < -max) else if (m < -max)
assert(over); assert(over);
else else {
assert(!over && n == m); assert(!over);
assert(n == m);
}
n = int_sub(x, y, 8, &over); n = int_sub(x, y, 8, &over);
m = x - y; m = x - y;
if (m > max-1) if (m > max-1)
assert(over); assert(over);
else if (m < -max) else if (m < -max)
assert(over); assert(over);
else else {
assert(!over && n == m); assert(!over);
asset(n == m);
}
} }
} }
} }
@ -82,16 +86,20 @@ static void test_int16() {
assert(over); assert(over);
else if (m < -max) else if (m < -max)
assert(over); assert(over);
else else {
assert(!over && n == m); assert(!over);
assert(n == m);
}
n = int_sub(x, y, 16, &over); n = int_sub(x, y, 16, &over);
m = x - y; m = x - y;
if (m > max-1) if (m > max-1)
assert(over); assert(over);
else if (m < -max) else if (m < -max)
assert(over); assert(over);
else else {
assert(!over && n == m); assert(!over);
assert(n == m);
}
} }
} }
} }
@ -104,20 +112,42 @@ static void test_int24() {
s = int_add(1, (1ULL<<23)-1, 24, &over); assert(over); s = int_add(1, (1ULL<<23)-1, 24, &over); assert(over);
s = int_add((1ULL<<23)-1, 1, 24, &over); assert(over); s = int_add((1ULL<<23)-1, 1, 24, &over); assert(over);
s = int_sub(-1, (1ULL<<23), 24, &over); assert(!over && s == (1ULL<<23)-1); s = int_sub(-1, (1ULL<<23), 24, &over);
assert(!over);
assert(s == (1ULL<<23)-1);
s = int_sub((1ULL<<23), 1, 24, &over); assert(over); s = int_sub((1ULL<<23), 1, 24, &over); assert(over);
s = int_add(0, 0, 24, &over); assert(!over && s == 0); s = int_add(0, 0, 24, &over);
s = int_sub(0, 0, 24, &over); assert(!over && s == 0); assert(!over);
s = int_add(0, -1, 24, &over); assert(!over && s == -1); assert(s == 0);
s = int_sub(0, 1, 24, &over); assert(!over && s == -1); s = int_sub(0, 0, 24, &over);
s = int_add(0, (1ULL<<23), 24, &over); assert(!over && (s & ((1ULL<<24)-1)) == (1ULL<<23)); assert(!over);
s = int_sub(0, (1ULL<<23)-1, 24, &over); assert(!over && (s & ((1ULL<<24)-1)) == (1ULL<<23)+1); assert(s == 0);
s = int_add(0, -1, 24, &over);
assert(!over);
assert(s == -1);
s = int_sub(0, 1, 24, &over);
assert(!over);
assert(s == -1);
s = int_add(0, (1ULL<<23), 24, &over);
assert(!over);
assert((s & ((1ULL<<24)-1)) == (1ULL<<23));
s = int_sub(0, (1ULL<<23)-1, 24, &over);
assert(!over);
assert((s & ((1ULL<<24)-1)) == (1ULL<<23)+1);
s = int_add(-1, 0, 24, &over); assert(!over && s == -1); s = int_add(-1, 0, 24, &over);
s = int_add(-1, 1, 24, &over); assert(!over && s == 0); assert(!over);
s = int_sub(-1, -1, 24, &over); assert(!over && s == 0); assert(s == -1);
s = int_sub(-1, (1ULL<<23)-1, 24, &over); assert(!over && (s & ((1ULL<<24)-1)) == (1ULL<<23)); s = int_add(-1, 1, 24, &over);
assert(!over);
assert(s == 0);
s = int_sub(-1, -1, 24, &over);
assert(!over);
assert(s == 0);
s = int_sub(-1, (1ULL<<23)-1, 24, &over);
assert(!over);
assert((s & ((1ULL<<24)-1)) == (1ULL<<23));
} }
static void test_int32() { static void test_int32() {
@ -128,20 +158,42 @@ static void test_int32() {
s = int_add(1, (1ULL<<31)-1, 32, &over); assert(over); s = int_add(1, (1ULL<<31)-1, 32, &over); assert(over);
s = int_add((1ULL<<31)-1, 1, 32, &over); assert(over); s = int_add((1ULL<<31)-1, 1, 32, &over); assert(over);
s = int_sub(-1, (1ULL<<31), 32, &over); assert(s == (1ULL<<31)-1 && !over); s = int_sub(-1, (1ULL<<31), 32, &over);
assert(s == (1ULL<<31)-1);
assert(!over);
s = int_sub((1ULL<<31), 1, 32, &over); assert(over); s = int_sub((1ULL<<31), 1, 32, &over); assert(over);
s = int_add(0, 0, 32, &over); assert(s == 0 && !over); s = int_add(0, 0, 32, &over);
s = int_sub(0, 0, 32, &over); assert(s == 0 && !over); assert(s == 0);
s = int_add(0, -1, 32, &over); assert(s == -1 && !over); assert(!over);
s = int_sub(0, 1, 32, &over); assert(s == -1 && !over); s = int_sub(0, 0, 32, &over);
s = int_add(0, (1ULL<<31), 32, &over); assert((s & ((1ULL<<32)-1)) == (1ULL<<31) && !over); assert(s == 0);
s = int_sub(0, (1ULL<<31)-1, 32, &over); assert((s & ((1ULL<<32)-1)) == (1ULL<<31)+1 && !over); assert(!over);
s = int_add(0, -1, 32, &over);
assert(s == -1);
assert(!over);
s = int_sub(0, 1, 32, &over);
assert(s == -1);
assert(!over);
s = int_add(0, (1ULL<<31), 32, &over);
assert((s & ((1ULL<<32)-1)) == (1ULL<<31));
assert(!over);
s = int_sub(0, (1ULL<<31)-1, 32, &over);
assert((s & ((1ULL<<32)-1)) == (1ULL<<31)+1);
assert(!over);
s = int_add(-1, 0, 32, &over); assert(s == -1 && !over); s = int_add(-1, 0, 32, &over);
s = int_add(-1, 1, 32, &over); assert(s == 0 && !over); assert(s == -1);
s = int_sub(-1, -1, 32, &over); assert(s == 0 && !over); assert(!over);
s = int_sub(-1, (1ULL<<31)-1, 32, &over); assert((s & ((1ULL<<32)-1)) == (1ULL<<31) && !over); s = int_add(-1, 1, 32, &over);
assert(s == 0);
assert(!over);
s = int_sub(-1, -1, 32, &over);
assert(s == 0);
assert(!over);
s = int_sub(-1, (1ULL<<31)-1, 32, &over);
assert((s & ((1ULL<<32)-1)) == (1ULL<<31));
assert(!over);
} }
static void test_int64() { static void test_int64() {
@ -152,20 +204,42 @@ static void test_int64() {
s = int_add(1, (1ULL<<63)-1, 64, &over); assert(over); s = int_add(1, (1ULL<<63)-1, 64, &over); assert(over);
s = int_add((1ULL<<63)-1, 1, 64, &over); assert(over); s = int_add((1ULL<<63)-1, 1, 64, &over); assert(over);
s = int_sub(-1, (1ULL<<63), 64, &over); assert(s == (1ULL<<63)-1 && !over); s = int_sub(-1, (1ULL<<63), 64, &over);
assert(s == (1ULL<<63)-1);
assert(!over);
s = int_sub((1ULL<<63), 1, 64, &over); assert(over); s = int_sub((1ULL<<63), 1, 64, &over); assert(over);
s = int_add(0, 0, 64, &over); assert(s == 0 && !over); s = int_add(0, 0, 64, &over);
s = int_sub(0, 0, 64, &over); assert(s == 0 && !over); assert(s == 0);
s = int_add(0, -1, 64, &over); assert(s == -1 && !over); assert(!over);
s = int_sub(0, 1, 64, &over); assert(s == -1 && !over); s = int_sub(0, 0, 64, &over);
s = int_add(0, (1ULL<<63), 64, &over); assert(s == (int64_t)(1ULL<<63) && !over); assert(s == 0);
s = int_sub(0, (1ULL<<63)-1, 64, &over); assert(s == (int64_t)((1ULL<<63)+1) && !over); assert(!over);
s = int_add(0, -1, 64, &over);
assert(s == -1);
assert(!over);
s = int_sub(0, 1, 64, &over);
assert(s == -1);
assert(!over);
s = int_add(0, (1ULL<<63), 64, &over);
assert(s == (int64_t)(1ULL<<63));
assert(!over);
s = int_sub(0, (1ULL<<63)-1, 64, &over);
assert(s == (int64_t)((1ULL<<63)+1));
assert(!over);
s = int_add(-1, 0, 64, &over); assert(s == -1 && !over); s = int_add(-1, 0, 64, &over);
s = int_add(-1, 1, 64, &over); assert(s == 0 && !over); assert(s == -1);
s = int_sub(-1, -1, 64, &over); assert(s == 0 && !over); assert(!over);
s = int_sub(-1, (1ULL<<63)-1, 64, &over); assert(s == (int64_t)(1ULL<<63) && !over); s = int_add(-1, 1, 64, &over);
assert(s == 0);
assert(!over);
s = int_sub(-1, -1, 64, &over);
assert(s == 0);
assert(!over);
s = int_sub(-1, (1ULL<<63)-1, 64, &over);
assert(s == (int64_t)(1ULL<<63));
assert(!over);
} }
static void test_int_sign(uint length_bits) { static void test_int_sign(uint length_bits) {

View File

@ -51,14 +51,18 @@ static void test_uint8() {
m = x + y; m = x + y;
if (m > (1ULL<<8)-1) if (m > (1ULL<<8)-1)
assert(over); assert(over);
else else {
assert(!over && n == (m % 256)); assert(!over);
assert(n == (m % 256));
}
n = uint_sub(x, y, 8, &over); n = uint_sub(x, y, 8, &over);
m = x - y; m = x - y;
if (m > x) if (m > x)
assert(over); assert(over);
else else {
assert(!over && n == (m % 256)); assert(!over);
assert(n == (m % 256));
}
} }
} }
} }
@ -75,14 +79,18 @@ static void test_uint16() {
m = x + y; m = x + y;
if (m > (1ULL<<16)-1) if (m > (1ULL<<16)-1)
assert(over); assert(over);
else else {
assert(!over && n == (m % (1ULL<<16))); assert(!over);
assert(n == (m % (1ULL<<16)));
}
n = uint_sub(x, y, 16, &over); n = uint_sub(x, y, 16, &over);
m = x - y; m = x - y;
if (m > x) if (m > x)
assert(over); assert(over);
else else {
assert(!over && n == (m % (1ULL<<16))); assert(!over);
assert(n == (m % (1ULL<<16)));
}
} }
} }
} }
@ -95,13 +103,23 @@ static void test_uint24() {
s = uint_add((1ULL<<24)-1, (1ULL<<24)-1, 24, &over); assert(over); s = uint_add((1ULL<<24)-1, (1ULL<<24)-1, 24, &over); assert(over);
s = uint_add((1ULL<<24)-1, 1, 24, &over); assert(over); s = uint_add((1ULL<<24)-1, 1, 24, &over); assert(over);
s = uint_add((1ULL<<24)-1, 0, 24, &over); assert(!over && s == (1ULL<<24)-1); s = uint_add((1ULL<<24)-1, 0, 24, &over);
s = uint_add(0, 1, 24, &over); assert(!over && s == 1); assert(!over);
s = uint_add(0, 0, 24, &over); assert(!over && s == 0); assert(s == (1ULL<<24)-1);
s = uint_sub(0, 0, 24, &over); assert(!over && s == 0); s = uint_add(0, 1, 24, &over);
assert(!over);
assert(s == 1);
s = uint_add(0, 0, 24, &over);
assert(!over);
assert(s == 0);
s = uint_sub(0, 0, 24, &over);
assert(!over);
assert(s == 0);
s = uint_sub(0, 1, 24, &over); assert(over); s = uint_sub(0, 1, 24, &over); assert(over);
s = uint_sub(0, (1ULL<<24)-1, 24, &over); assert(over); s = uint_sub(0, (1ULL<<24)-1, 24, &over); assert(over);
s = uint_sub((1ULL<<24)-1, (1ULL<<24)-1, 24, &over); assert(!over && s == 0); s = uint_sub((1ULL<<24)-1, (1ULL<<24)-1, 24, &over);
assert(!over);
assert(s == 0);
} }
static void test_uint32() { static void test_uint32() {
@ -112,13 +130,23 @@ static void test_uint32() {
s = uint_add((1ULL<<32)-1, (1ULL<<32)-1, 32, &over); assert(over); s = uint_add((1ULL<<32)-1, (1ULL<<32)-1, 32, &over); assert(over);
s = uint_add((1ULL<<32)-1, 1, 32, &over); assert(over); s = uint_add((1ULL<<32)-1, 1, 32, &over); assert(over);
s = uint_add((1ULL<<32)-1, 0, 32, &over); assert(!over && s == (1ULL<<32)-1); s = uint_add((1ULL<<32)-1, 0, 32, &over);
s = uint_add(0, 1, 32, &over); assert(!over && s == 1); assert(!over);
s = uint_add(0, 0, 32, &over); assert(!over && s == 0); assert(s == (1ULL<<32)-1);
s = uint_sub(0, 0, 32, &over); assert(!over && s == 0); s = uint_add(0, 1, 32, &over);
assert(!over);
assert(s == 1);
s = uint_add(0, 0, 32, &over);
assert(!over);
assert(s == 0);
s = uint_sub(0, 0, 32, &over);
assert(!over);
assert(s == 0);
s = uint_sub(0, 1, 32, &over); assert(over); s = uint_sub(0, 1, 32, &over); assert(over);
s = uint_sub(0, (1ULL<<32)-1, 32, &over); assert(over); s = uint_sub(0, (1ULL<<32)-1, 32, &over); assert(over);
s = uint_sub((1ULL<<32)-1, (1ULL<<32)-1, 32, &over); assert(!over && s == 0); s = uint_sub((1ULL<<32)-1, (1ULL<<32)-1, 32, &over);
assert(!over);
assert(s == 0);
} }
static void test_uint64() { static void test_uint64() {
@ -129,13 +157,23 @@ static void test_uint64() {
s = uint_add(~0ULL, ~0ULL, 64, &over); assert(over); s = uint_add(~0ULL, ~0ULL, 64, &over); assert(over);
s = uint_add(~0ULL, 1, 64, &over); assert(over); s = uint_add(~0ULL, 1, 64, &over); assert(over);
s = uint_add(~0ULL, 0, 64, &over); assert(!over && s == ~0ULL); s = uint_add(~0ULL, 0, 64, &over);
s = uint_add(0, 1, 64, &over); assert(!over && s == 1); assert(!over);
s = uint_add(0, 0, 64, &over); assert(!over && s == 0); assert(s == ~0ULL);
s = uint_sub(0, 0, 64, &over); assert(!over && s == 0); s = uint_add(0, 1, 64, &over);
assert(!over);
assert(s == 1);
s = uint_add(0, 0, 64, &over);
assert(!over);
assert(s == 0);
s = uint_sub(0, 0, 64, &over);
assert(!over);
assert(s == 0);
s = uint_sub(0, 1, 64, &over); assert(over); s = uint_sub(0, 1, 64, &over); assert(over);
s = uint_sub(0, ~0ULL, 64, &over); assert(over); s = uint_sub(0, ~0ULL, 64, &over); assert(over);
s = uint_sub(~0ULL, ~0ULL, 64, &over); assert(!over && s == 0); s = uint_sub(~0ULL, ~0ULL, 64, &over);
assert(!over);
assert(s == 0);
} }
int main() { int main() {

View File

@ -27,7 +27,6 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include <stdint.h> #include <stdint.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
#include <sys/types.h> #include <sys/types.h>
#include <tokudb_math.h> #include <tokudb_math.h>

View File

@ -32,9 +32,13 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
static void test_null() { static void test_null() {
tokudb::buffer b; tokudb::buffer b;
assert(b.data() == NULL && b.size() == 0 && b.limit() == 0); assert(b.data() == nullptr);
assert(b.size() == 0);
assert(b.limit() == 0);
b.append(NULL, 0); b.append(NULL, 0);
assert(b.data() == NULL && b.size() == 0 && b.limit() == 0); assert(b.data() == nullptr);
assert(b.size() == 0);
assert(b.limit() == 0);
} }
static void append_az(tokudb::buffer &b) { static void append_az(tokudb::buffer &b) {
@ -132,7 +136,8 @@ static void test_replace_grow() {
} }
for (size_t i = 0; i < a.size()/2; i++) { for (size_t i = 0; i < a.size()/2; i++) {
unsigned char *cp = (unsigned char *) a.data() + 2*i; unsigned char *cp = (unsigned char *) a.data() + 2*i;
assert(cp[0] == 'a'+i && cp[1] == 'a'+i); assert(cp[0] == 'a'+i);
assert(cp[1] == 'a'+i);
} }
} }

View File

@ -27,7 +27,6 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include <stdint.h> #include <stdint.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
#include <sys/types.h> #include <sys/types.h>
#include <tokudb_math.h> #include <tokudb_math.h>

View File

@ -52,7 +52,8 @@ static void test_vlq_uint32_error(void) {
in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, 1); in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, 1);
assert(in_s == 0); assert(in_s == 0);
in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, 2); in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, 2);
assert(in_s == 2 && n == 128); assert(in_s == 2);
assert(n == 128);
} }
static void test_80000000(void) { static void test_80000000(void) {
@ -63,7 +64,8 @@ static void test_80000000(void) {
out_s = tokudb::vlq_encode_ui<uint64_t>(v, b, sizeof b); out_s = tokudb::vlq_encode_ui<uint64_t>(v, b, sizeof b);
assert(out_s == 5); assert(out_s == 5);
in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s); in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s);
assert(in_s == 5 && n == v); assert(in_s == 5);
assert(n == v);
} }
static void test_100000000(void) { static void test_100000000(void) {
@ -74,7 +76,8 @@ static void test_100000000(void) {
out_s = tokudb::vlq_encode_ui<uint64_t>(v, b, sizeof b); out_s = tokudb::vlq_encode_ui<uint64_t>(v, b, sizeof b);
assert(out_s == 5); assert(out_s == 5);
in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s); in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s);
assert(in_s == 5 && n == v); assert(in_s == 5);
assert(n == v);
} }
int main(void) { int main(void) {

View File

@ -44,7 +44,8 @@ static void test_vlq_uint32(void) {
assert(out_s == 1); assert(out_s == 1);
uint32_t n; uint32_t n;
size_t in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, out_s); size_t in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, out_s);
assert(in_s == 1 && n == v); assert(in_s == 1);
assert(n == v);
} }
printf("%u\n", 1<<7); printf("%u\n", 1<<7);
@ -54,7 +55,8 @@ static void test_vlq_uint32(void) {
assert(out_s == 2); assert(out_s == 2);
uint32_t n; uint32_t n;
size_t in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, out_s); size_t in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, out_s);
assert(in_s == 2 && n == v); assert(in_s == 2);
assert(n == v);
} }
printf("%u\n", 1<<14); printf("%u\n", 1<<14);
@ -64,7 +66,8 @@ static void test_vlq_uint32(void) {
assert(out_s == 3); assert(out_s == 3);
uint32_t n; uint32_t n;
size_t in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, out_s); size_t in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, out_s);
assert(in_s == 3 && n == v); assert(in_s == 3);
assert(n == v);
} }
printf("%u\n", 1<<21); printf("%u\n", 1<<21);
@ -74,7 +77,8 @@ static void test_vlq_uint32(void) {
assert(out_s == 4); assert(out_s == 4);
uint32_t n; uint32_t n;
size_t in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, out_s); size_t in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, out_s);
assert(in_s == 4 && n == v); assert(in_s == 4);
assert(n == v);
} }
printf("%u\n", 1<<28); printf("%u\n", 1<<28);
@ -84,7 +88,8 @@ static void test_vlq_uint32(void) {
assert(out_s == 5); assert(out_s == 5);
uint32_t n; uint32_t n;
size_t in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, out_s); size_t in_s = tokudb::vlq_decode_ui<uint32_t>(&n, b, out_s);
assert(in_s == 5 && n == v); assert(in_s == 5);
assert(n == v);
} }
} }

View File

@ -46,7 +46,8 @@ static void test_vlq_uint64(uint64_t start, uint64_t stride) {
assert(out_s == 1); assert(out_s == 1);
uint64_t n; uint64_t n;
size_t in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s); size_t in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s);
assert(in_s == 1 && n == v); assert(in_s == 1);
assert(n == v);
} }
printf("%u\n", 1<<7); printf("%u\n", 1<<7);
@ -56,7 +57,8 @@ static void test_vlq_uint64(uint64_t start, uint64_t stride) {
assert(out_s == 2); assert(out_s == 2);
uint64_t n; uint64_t n;
size_t in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s); size_t in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s);
assert(in_s == 2 && n == v); assert(in_s == 2);
assert(n == v);
} }
printf("%u\n", 1<<14); printf("%u\n", 1<<14);
@ -66,7 +68,8 @@ static void test_vlq_uint64(uint64_t start, uint64_t stride) {
assert(out_s == 3); assert(out_s == 3);
uint64_t n; uint64_t n;
size_t in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s); size_t in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s);
assert(in_s == 3 && n == v); assert(in_s == 3);
assert(n == v);
} }
printf("%u\n", 1<<21); printf("%u\n", 1<<21);
@ -76,7 +79,8 @@ static void test_vlq_uint64(uint64_t start, uint64_t stride) {
assert(out_s == 4); assert(out_s == 4);
uint64_t n; uint64_t n;
size_t in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s); size_t in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s);
assert(in_s == 4 && n == v); assert(in_s == 4);
assert(n == v);
} }
printf("%u\n", 1<<28); printf("%u\n", 1<<28);
@ -90,7 +94,8 @@ static void test_vlq_uint64(uint64_t start, uint64_t stride) {
assert(out_s == 5); assert(out_s == 5);
uint64_t n; uint64_t n;
size_t in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s); size_t in_s = tokudb::vlq_decode_ui<uint64_t>(&n, b, out_s);
assert(in_s == 5 && n == v); assert(in_s == 5);
assert(n == v);
} }
} }

View File

@ -134,8 +134,8 @@ public:
char* data_offset = (char*)m_data + offset; char* data_offset = (char*)m_data + offset;
if (new_s != old_s) { if (new_s != old_s) {
size_t n = m_size - (offset + old_s); size_t n = m_size - (offset + old_s);
assert_always( assert_always(offset + new_s + n <= m_limit);
offset + new_s + n <= m_limit && offset + old_s + n <= m_limit); assert_always(offset + old_s + n <= m_limit);
memmove(data_offset + new_s, data_offset + old_s, n); memmove(data_offset + new_s, data_offset + old_s, n);
if (new_s > old_s) if (new_s > old_s)
m_size += new_s - old_s; m_size += new_s - old_s;

View File

@ -59,7 +59,8 @@ TOKUDB_UNUSED(static uint64_t uint_add(
bool* over)); bool* over));
static uint64_t uint_add(uint64_t x, uint64_t y, uint length_bits, bool *over) { static uint64_t uint_add(uint64_t x, uint64_t y, uint length_bits, bool *over) {
uint64_t mask = uint_mask(length_bits); uint64_t mask = uint_mask(length_bits);
assert_always((x & ~mask) == 0 && (y & ~mask) == 0); assert_always((x & ~mask) == 0);
assert_always((y & ~mask) == 0);
uint64_t s = (x + y) & mask; uint64_t s = (x + y) & mask;
*over = s < x; // check for overflow *over = s < x; // check for overflow
return s; return s;
@ -75,7 +76,8 @@ TOKUDB_UNUSED(static uint64_t uint_sub(
bool* over)); bool* over));
static uint64_t uint_sub(uint64_t x, uint64_t y, uint length_bits, bool *over) { static uint64_t uint_sub(uint64_t x, uint64_t y, uint length_bits, bool *over) {
uint64_t mask = uint_mask(length_bits); uint64_t mask = uint_mask(length_bits);
assert_always((x & ~mask) == 0 && (y & ~mask) == 0); assert_always((x & ~mask) == 0);
assert_always((y & ~mask) == 0);
uint64_t s = (x - y) & mask; uint64_t s = (x - y) & mask;
*over = s > x; // check for overflow *over = s > x; // check for overflow
return s; return s;

View File

@ -124,7 +124,8 @@ _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
byte block_hash_offset; byte block_hash_offset;
ut_ad(block); ut_ad(block);
ut_ad(trx && trx->take_stats); ut_ad(trx);
ut_ad(trx->take_stats);
if (!trx->distinct_page_access_hash) { if (!trx->distinct_page_access_hash) {
trx->distinct_page_access_hash trx->distinct_page_access_hash

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2000, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
@ -2141,12 +2141,13 @@ UNIV_INTERN
ulong ulong
thd_flush_log_at_trx_commit( thd_flush_log_at_trx_commit(
/*================================*/ /*================================*/
void* thd) THD* thd)
{ {
/* THDVAR cannot be used in xtrabackup, /* THDVAR cannot be used in xtrabackup,
plugin variables for innodb are not loaded, plugin variables for innodb are not loaded,
this makes xtrabackup crash when trying to use them. */ this makes xtrabackup crash when trying to use them. */
return (thd || !IS_XTRABACKUP())? THDVAR((THD*)thd, flush_log_at_trx_commit) : FALSE; return (thd || !IS_XTRABACKUP())
? THDVAR(thd, flush_log_at_trx_commit) : 0;
} }
/********************************************************************//** /********************************************************************//**
@ -2871,11 +2872,10 @@ innobase_next_autoinc(
if (next_value == 0) { if (next_value == 0) {
ulonglong next; ulonglong next;
if (current >= offset) { if (current > offset) {
next = (current - offset) / step; next = (current - offset) / step;
} else { } else {
next = 0; next = (offset - current) / step;
block -= step;
} }
ut_a(max_value > next); ut_a(max_value > next);
@ -16600,6 +16600,37 @@ ha_innobase::get_auto_increment(
ut_ad(autoinc > 0); ut_ad(autoinc > 0);
} }
/** The following logic is needed to avoid duplicate key error
for autoincrement column.
(1) InnoDB gives the current autoincrement value with respect
to increment and offset value.
(2) Basically it does compute_next_insert_id() logic inside InnoDB
to avoid the current auto increment value changed by handler layer.
(3) It is restricted only for insert operations. */
if (increment > 1 && thd_sql_command(user_thd) != SQLCOM_ALTER_TABLE
&& autoinc < col_max_value) {
ulonglong prev_auto_inc = autoinc;
autoinc = ((autoinc - 1) + increment - offset)/ increment;
autoinc = autoinc * increment + offset;
/* If autoinc exceeds the col_max_value then reset
to old autoinc value. Because in case of non-strict
sql mode, boundary value is not considered as error. */
if (autoinc >= col_max_value) {
autoinc = prev_auto_inc;
}
ut_ad(autoinc > 0);
}
/* Called for the first time ? */ /* Called for the first time ? */
if (trx->n_autoinc_rows == 0) { if (trx->n_autoinc_rows == 0) {
@ -16637,27 +16668,6 @@ ha_innobase::get_auto_increment(
current = *first_value; current = *first_value;
if (prebuilt->autoinc_increment != increment) {
WSREP_DEBUG("autoinc decrease: %llu -> %llu\n"
"THD: %ld, current: %llu, autoinc: %llu",
prebuilt->autoinc_increment,
increment,
thd_get_thread_id(ha_thd()),
current, autoinc);
if (!wsrep_on(ha_thd()))
{
current = autoinc - prebuilt->autoinc_increment;
}
current = innobase_next_autoinc(
current, 1, increment, offset, col_max_value);
dict_table_autoinc_initialize(prebuilt->table, current);
*first_value = current;
}
/* Compute the last value in the interval */ /* Compute the last value in the interval */
next_value = innobase_next_autoinc( next_value = innobase_next_autoinc(
current, *nb_reserved_values, increment, offset, current, *nb_reserved_values, increment, offset,
@ -18921,7 +18931,7 @@ innodb_sched_priority_master_update(
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_ARGUMENTS, ER_WRONG_ARGUMENTS,
"Failed to set the master thread " "Failed to set the master thread "
"priority to %lu, " "priority to %lu, "
"the nice is %lu and the current priority is %lu", priority, "the nice is %lu and the current priority is %lu", priority,
nice, actual_priority); nice, actual_priority);
} }
@ -21052,14 +21062,14 @@ static MYSQL_SYSVAR_BOOL(force_primary_key,
"Do not allow to create table without primary key (off by default)", "Do not allow to create table without primary key (off by default)",
NULL, NULL, FALSE); NULL, NULL, FALSE);
const char *corrupt_table_action_names[]= static const char *corrupt_table_action_names[]=
{ {
"assert", /* 0 */ "assert", /* 0 */
"warn", /* 1 */ "warn", /* 1 */
"salvage", /* 2 */ "salvage", /* 2 */
NullS NullS
}; };
TYPELIB corrupt_table_action_typelib= static TYPELIB corrupt_table_action_typelib=
{ {
array_elements(corrupt_table_action_names) - 1, "corrupt_table_action_typelib", array_elements(corrupt_table_action_names) - 1, "corrupt_table_action_typelib",
corrupt_table_action_names, NULL corrupt_table_action_names, NULL

View File

@ -104,8 +104,8 @@ btr_search_get_latch(
/*=================*/ /*=================*/
const dict_index_t* index) /*!< in: index */ const dict_index_t* index) /*!< in: index */
{ {
ut_ad(index->search_latch >= btr_search_latch_arr && ut_ad(index->search_latch >= btr_search_latch_arr);
index->search_latch < btr_search_latch_arr + ut_ad(index->search_latch < btr_search_latch_arr +
btr_search_index_num); btr_search_index_num);
return(index->search_latch); return(index->search_latch);

View File

@ -419,7 +419,7 @@ innobase_get_table_cache_size(void);
ulong ulong
thd_flush_log_at_trx_commit( thd_flush_log_at_trx_commit(
/*================================*/ /*================================*/
void* thd); THD* thd);
/**********************************************************************//** /**********************************************************************//**
Get the current setting of the lower_case_table_names global parameter from Get the current setting of the lower_case_table_names global parameter from

View File

@ -453,7 +453,8 @@ rw_lock_higher_prio_waiters_exist(
return(false); return(false);
} }
ut_ad(priority_lock && !high_priority); ut_ad(priority_lock);
ut_ad(!high_priority);
prio_rw_lock_t *prio_rw_lock = (prio_rw_lock_t *) lock; prio_rw_lock_t *prio_rw_lock = (prio_rw_lock_t *) lock;
return prio_rw_lock->high_priority_wait_ex_waiter > 0 return prio_rw_lock->high_priority_wait_ex_waiter > 0

View File

@ -45,10 +45,10 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MAJOR 5
#define INNODB_VERSION_MINOR 6 #define INNODB_VERSION_MINOR 6
#define INNODB_VERSION_BUGFIX 44 #define INNODB_VERSION_BUGFIX 45
#ifndef PERCONA_INNODB_VERSION #ifndef PERCONA_INNODB_VERSION
#define PERCONA_INNODB_VERSION 86.0 #define PERCONA_INNODB_VERSION 86.1
#endif #endif
/* Enable UNIV_LOG_ARCHIVE in XtraDB */ /* Enable UNIV_LOG_ARCHIVE in XtraDB */

View File

@ -207,6 +207,7 @@ functions to get some info from THD.
@param[in] trx requested trx @param[in] trx requested trx
@param[in] blocking blocking info array @param[in] blocking blocking info array
@param[in] blocking_count blocking info array size */ @param[in] blocking_count blocking info array size */
static
void void
print_lock_wait_timeout( print_lock_wait_timeout(
const trx_t &trx, const trx_t &trx,

View File

@ -91,7 +91,7 @@ static const char* bmp_file_name_stem = "ib_modified_log_";
/** File name template for bitmap files. The 1st format tag is a directory /** File name template for bitmap files. The 1st format tag is a directory
name, the 2nd tag is the stem, the 3rd tag is a file sequence number, the 4th name, the 2nd tag is the stem, the 3rd tag is a file sequence number, the 4th
tag is the start LSN for the file. */ tag is the start LSN for the file. */
static const char* bmp_file_name_template = "%s%s%lu_%llu.xdb"; static const char* bmp_file_name_template = "%s%s%lu_" LSN_PF ".xdb";
/* On server startup with empty database srv_start_lsn == 0, in /* On server startup with empty database srv_start_lsn == 0, in
which case the first LSN of actual log records will be this. */ which case the first LSN of actual log records will be this. */
@ -586,9 +586,8 @@ log_online_is_bitmap_file(
return ((file_info->type == OS_FILE_TYPE_FILE return ((file_info->type == OS_FILE_TYPE_FILE
|| file_info->type == OS_FILE_TYPE_LINK) || file_info->type == OS_FILE_TYPE_LINK)
&& (sscanf(file_info->name, "%[a-z_]%lu_%llu.xdb", stem, && (sscanf(file_info->name, "%[a-z_]%lu_" LSN_PF ".xdb", stem,
bitmap_file_seq_num, bitmap_file_seq_num, bitmap_file_start_lsn) == 3)
(unsigned long long *)bitmap_file_start_lsn) == 3)
&& (!strcmp(stem, bmp_file_name_stem))); && (!strcmp(stem, bmp_file_name_stem)));
} }

View File

@ -40,7 +40,6 @@ Created 5/11/1994 Heikki Tuuri
#include <ctype.h> #include <ctype.h>
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
# include "btr0types.h"
# include "trx0trx.h" # include "trx0trx.h"
# include "ha_prototypes.h" # include "ha_prototypes.h"
# include "mysql_com.h" /* NAME_LEN */ # include "mysql_com.h" /* NAME_LEN */

View File

@ -16,7 +16,8 @@ fi
# Make MySQL start/shutdown automatically when the machine does it. # Make MySQL start/shutdown automatically when the machine does it.
if [ $1 = 1 ] ; then if [ $1 = 1 ] ; then
if [ -x /usr/bin/systemctl ] ; then if [ -x /usr/bin/systemctl ] ; then
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
/usr/bin/systemctl preset mariadb.service >/dev/null 2>&1 || :
elif [ -x /sbin/chkconfig ] ; then elif [ -x /sbin/chkconfig ] ; then
/sbin/chkconfig --add mysql /sbin/chkconfig --add mysql
fi fi