summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-03-17 07:58:41 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-03-17 07:58:41 +0200
commitc7ba92372b8e21c42eb5df20f080c941fc84a144 (patch)
tree7e74d58b0a47b556a1b411ed0ad14e38384d6991
parent023d9867327c0c5dfe95173c0731940fe6df74ab (diff)
parent097e2f9d0aa0dc7f1c4a7cff52260944db28e3c8 (diff)
downloadmariadb-git-c7ba92372b8e21c42eb5df20f080c941fc84a144.tar.gz
Merge 10.4 into 10.5
-rw-r--r--client/mysqlbinlog.cc14
-rw-r--r--mysql-test/suite/plugins/t/server_audit.test3
-rw-r--r--mysql-test/suite/sys_vars/r/alter_algorithm_basic.result89
-rw-r--r--mysql-test/suite/sys_vars/t/alter_algorithm_basic.test58
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_select.cc2
-rw-r--r--storage/innobase/buf/buf0buf.cc3
-rw-r--r--storage/innobase/dict/dict0load.cc6
-rw-r--r--storage/innobase/handler/i_s.cc26
-rw-r--r--storage/innobase/include/dict0load.h10
-rw-r--r--storage/innobase/include/page0zip.h11
-rw-r--r--storage/innobase/page/page0zip.cc60
-rw-r--r--storage/maria/ma_page.c3
-rw-r--r--storage/myisam/mi_range.c3
-rw-r--r--storage/myisammrg/myrg_open.c13
-rw-r--r--storage/perfschema/pfs_instr_class.cc3
-rw-r--r--strings/json_lib.c10
17 files changed, 220 insertions, 96 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index eb50eff5a1d..05983b57f4e 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2009, 2019, MariaDB
+ Copyright (c) 2009, 2020, MariaDB
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
@@ -184,7 +184,7 @@ enum Exit_status {
*/
static Annotate_rows_log_event *annotate_event= NULL;
-void free_annotate_event()
+static void free_annotate_event()
{
if (annotate_event)
{
@@ -930,7 +930,7 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
}
}
- /*
+ /*
end of statement check:
i) destroy/free ignored maps
ii) if skip event
@@ -941,21 +941,21 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
*/
if (is_stmt_end)
{
- /*
+ /*
Now is safe to clear ignored map (clear_tables will also
delete original table map events stored in the map).
*/
if (print_event_info->m_table_map_ignored.count() > 0)
print_event_info->m_table_map_ignored.clear_tables();
- /*
+ /*
If there is a kept Annotate event and all corresponding
rbr-events were filtered away, the Annotate event was not
freed and it is just the time to do it.
*/
- free_annotate_event();
+ free_annotate_event();
- /*
+ /*
One needs to take into account an event that gets
filtered but was last event in the statement. If this is
the case, previous rows events that were written into
diff --git a/mysql-test/suite/plugins/t/server_audit.test b/mysql-test/suite/plugins/t/server_audit.test
index 67b855871a3..9833b972725 100644
--- a/mysql-test/suite/plugins/t/server_audit.test
+++ b/mysql-test/suite/plugins/t/server_audit.test
@@ -157,6 +157,9 @@ set global server_audit_logging= off;
set global server_audit_incl_users='root';
set global server_audit_logging= on;
disconnect cn1;
+let $count_sessions=1;
+source include/wait_until_count_sessions.inc;
+
drop user user1@localhost;
set global server_audit_events='';
diff --git a/mysql-test/suite/sys_vars/r/alter_algorithm_basic.result b/mysql-test/suite/sys_vars/r/alter_algorithm_basic.result
new file mode 100644
index 00000000000..39cfad4d35c
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/alter_algorithm_basic.result
@@ -0,0 +1,89 @@
+SET @start_global_value = @@global.alter_algorithm;
+SET GLOBAL alter_algorithm=1.1;
+ERROR 42000: Incorrect argument type to variable 'alter_algorithm'
+SET GLOBAL alter_algorithm=-1;
+ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '-1'
+SET GLOBAL alter_algorithm=weird;
+ERROR 42000: Variable 'alter_algorithm' can't be set to the value of 'weird'
+SET GLOBAL alter_algorithm=4;
+SELECT @@global.alter_algorithm;
+@@global.alter_algorithm
+INSTANT
+SET GLOBAL alter_algorithm=3;
+SELECT @@global.alter_algorithm;
+@@global.alter_algorithm
+NOCOPY
+SET GLOBAL alter_algorithm=0;
+SELECT @@global.alter_algorithm;
+@@global.alter_algorithm
+DEFAULT
+SET GLOBAL alter_algorithm=1;
+SELECT @@global.alter_algorithm;
+@@global.alter_algorithm
+COPY
+SET GLOBAL alter_algorithm=2;
+SELECT @@global.alter_algorithm;
+@@global.alter_algorithm
+INPLACE
+SET GLOBAL alter_algorithm=5;
+ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '5'
+SELECT @@global.alter_algorithm;
+@@global.alter_algorithm
+INPLACE
+SET GLOBAL alter_algorithm=NOCOPY;
+SET alter_algorithm=1.1;
+ERROR 42000: Incorrect argument type to variable 'alter_algorithm'
+SET alter_algorithm=-1;
+ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '-1'
+SET alter_algorithm=weird;
+ERROR 42000: Variable 'alter_algorithm' can't be set to the value of 'weird'
+SET alter_algorithm=4;
+SELECT @@alter_algorithm;
+@@alter_algorithm
+INSTANT
+SET alter_algorithm=3;
+SELECT @@alter_algorithm;
+@@alter_algorithm
+NOCOPY
+SET alter_algorithm=0;
+SELECT @@alter_algorithm;
+@@alter_algorithm
+DEFAULT
+SET alter_algorithm=1;
+SELECT @@alter_algorithm;
+@@alter_algorithm
+COPY
+SET alter_algorithm=2;
+SELECT @@alter_algorithm;
+@@alter_algorithm
+INPLACE
+SET alter_algorithm=5;
+ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '5'
+SELECT @@alter_algorithm;
+@@alter_algorithm
+INPLACE
+SET SESSION alter_algorithm=INSTANT;
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+Variable_name Value
+alter_algorithm INSTANT
+SET SESSION alter_algorithm=DEFAULT;
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+Variable_name Value
+alter_algorithm NOCOPY
+SET SESSION alter_algorithm='DEFAULT';
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+Variable_name Value
+alter_algorithm DEFAULT
+SET SESSION alter_algorithm=DEFAULT;
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+Variable_name Value
+alter_algorithm NOCOPY
+SET GLOBAL alter_algorithm=DEFAULT;
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+Variable_name Value
+alter_algorithm NOCOPY
+SET SESSION alter_algorithm=DEFAULT;
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+Variable_name Value
+alter_algorithm DEFAULT
+SET GLOBAL alter_algorithm = @start_global_value;
diff --git a/mysql-test/suite/sys_vars/t/alter_algorithm_basic.test b/mysql-test/suite/sys_vars/t/alter_algorithm_basic.test
new file mode 100644
index 00000000000..69a5320a98c
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/alter_algorithm_basic.test
@@ -0,0 +1,58 @@
+SET @start_global_value = @@global.alter_algorithm;
+
+--error ER_WRONG_TYPE_FOR_VAR
+SET GLOBAL alter_algorithm=1.1;
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL alter_algorithm=-1;
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL alter_algorithm=weird;
+SET GLOBAL alter_algorithm=4;
+SELECT @@global.alter_algorithm;
+SET GLOBAL alter_algorithm=3;
+SELECT @@global.alter_algorithm;
+SET GLOBAL alter_algorithm=0;
+SELECT @@global.alter_algorithm;
+SET GLOBAL alter_algorithm=1;
+SELECT @@global.alter_algorithm;
+SET GLOBAL alter_algorithm=2;
+SELECT @@global.alter_algorithm;
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL alter_algorithm=5;
+SELECT @@global.alter_algorithm;
+
+SET GLOBAL alter_algorithm=NOCOPY;
+
+--error ER_WRONG_TYPE_FOR_VAR
+SET alter_algorithm=1.1;
+--error ER_WRONG_VALUE_FOR_VAR
+SET alter_algorithm=-1;
+--error ER_WRONG_VALUE_FOR_VAR
+SET alter_algorithm=weird;
+SET alter_algorithm=4;
+SELECT @@alter_algorithm;
+SET alter_algorithm=3;
+SELECT @@alter_algorithm;
+SET alter_algorithm=0;
+SELECT @@alter_algorithm;
+SET alter_algorithm=1;
+SELECT @@alter_algorithm;
+SET alter_algorithm=2;
+SELECT @@alter_algorithm;
+--error ER_WRONG_VALUE_FOR_VAR
+SET alter_algorithm=5;
+SELECT @@alter_algorithm;
+
+SET SESSION alter_algorithm=INSTANT;
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+SET SESSION alter_algorithm=DEFAULT;
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+SET SESSION alter_algorithm='DEFAULT';
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+SET SESSION alter_algorithm=DEFAULT;
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+SET GLOBAL alter_algorithm=DEFAULT;
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+SET SESSION alter_algorithm=DEFAULT;
+SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+
+SET GLOBAL alter_algorithm = @start_global_value;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 07efe8ed8f7..babe51b9fc9 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -794,7 +794,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
query_name_consts= 0;
semisync_info= 0;
db_charset= global_system_variables.collation_database;
- bzero(ha_data, sizeof(ha_data));
+ bzero((void*) ha_data, sizeof(ha_data));
mysys_var=0;
binlog_evt_union.do_union= FALSE;
enable_slow_log= 0;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 3543f699268..35b5665d1d0 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5575,7 +5575,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
for (i= 0; i < join->table_count ; i++)
if (double rr= join->best_positions[i].records_read)
records= COST_MULT(records, rr);
- ha_rows rows= records > HA_ROWS_MAX ? HA_ROWS_MAX : (ha_rows) records;
+ ha_rows rows= records > (double) HA_ROWS_MAX ? HA_ROWS_MAX : (ha_rows) records;
set_if_smaller(rows, unit->lim.get_select_limit());
join->select_lex->increase_derived_records(rows);
}
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index dc3233c4948..5625e0ab2cc 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -3483,7 +3483,8 @@ buf_zip_decompress(
frame, size, SRV_CHECKSUM_ALGORITHM_INNODB)
<< ", none: "
<< page_zip_calc_checksum(
- frame, size, SRV_CHECKSUM_ALGORITHM_NONE);
+ frame, size, SRV_CHECKSUM_ALGORITHM_NONE)
+ << " (algorithm: " << srv_checksum_algorithm << ")";
goto err_exit;
}
diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc
index f193cec5aa8..7f933cde0f6 100644
--- a/storage/innobase/dict/dict0load.cc
+++ b/storage/innobase/dict/dict0load.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2019, MariaDB Corporation.
+Copyright (c) 2016, 2020, 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
@@ -780,7 +780,7 @@ err_len:
@param[in] space_id Tablespace ID
@return First filepath (caller must invoke ut_free() on it)
@retval NULL if no SYS_DATAFILES entry was found. */
-char*
+static char*
dict_get_first_path(
ulint space_id)
{
@@ -838,7 +838,7 @@ dict_get_first_path(
ut_ad(len > 0);
ut_ad(len < OS_FILE_MAX_PATH);
- if (len > 0 && len != UNIV_SQL_NULL) {
+ if (len > 0 && len < UNIV_SQL_NULL) {
filepath = mem_strdupl(
reinterpret_cast<const char*>(field),
len);
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 0f74e85c088..ed560eb52b3 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -6559,31 +6559,24 @@ i_s_dict_fill_sys_tablespaces(
OK(fields[SYS_TABLESPACES_ZIP_PAGE_SIZE]->store(
fil_space_t::physical_size(cflags), true));
- char* filepath = NULL;
- if (FSP_FLAGS_HAS_DATA_DIR(cflags)) {
- mutex_enter(&dict_sys.mutex);
- filepath = dict_get_first_path(space);
- mutex_exit(&dict_sys.mutex);
- }
-
- if (filepath == NULL) {
- filepath = fil_make_filepath(NULL, name, IBD, false);
- }
-
os_file_stat_t stat;
os_file_size_t file;
memset(&file, 0xff, sizeof(file));
memset(&stat, 0x0, sizeof(stat));
- if (filepath != NULL) {
+ if (fil_space_t* s = fil_space_acquire_silent(space)) {
+ const char *filepath = s->chain.start
+ ? s->chain.start->name : NULL;
+ if (!filepath) {
+ goto file_done;
+ }
file = os_file_get_size(filepath);
/* Get the file system (or Volume) block size. */
- dberr_t err = os_file_get_status(filepath, &stat, false, false);
-
- switch(err) {
+ switch (dberr_t err = os_file_get_status(filepath, &stat,
+ false, false)) {
case DB_FAIL:
ib::warn()
<< "File '" << filepath << "', failed to get "
@@ -6601,7 +6594,8 @@ i_s_dict_fill_sys_tablespaces(
break;
}
- ut_free(filepath);
+file_done:
+ s->release();
}
if (file.m_total_size == os_offset_t(~0)) {
diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h
index 69379e44b78..f067571ca5b 100644
--- a/storage/innobase/include/dict0load.h
+++ b/storage/innobase/include/dict0load.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2019, MariaDB Corporation.
+Copyright (c) 2017, 2020, 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
@@ -79,14 +79,6 @@ dict_get_first_table_name_in_db(
/*============================*/
const char* name); /*!< in: database name which ends to '/' */
-/** Get the first filepath from SYS_DATAFILES for a given space_id.
-@param[in] space_id Tablespace ID
-@return First filepath (caller must invoke ut_free() on it)
-@retval NULL if no SYS_DATAFILES entry was found. */
-char*
-dict_get_first_path(
- ulint space_id);
-
/** Make sure the data_file_name is saved in dict_table_t if needed.
Try to read it from the fil_system first, then from SYS_DATAFILES.
@param[in] table Table object
diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h
index 459f4b9cc77..acee1c49d1a 100644
--- a/storage/innobase/include/page0zip.h
+++ b/storage/innobase/include/page0zip.h
@@ -371,12 +371,11 @@ page_zip_calc_checksum(
ulint size,
srv_checksum_algorithm_t algo);
-/** Verify a compressed page's checksum.
-@param[in] data compressed page
-@param[in] size size of compressed page
-@return whether the stored checksum is valid according to the value of
-innodb_checksum_algorithm */
-bool page_zip_verify_checksum(const void* data, ulint size);
+/** Validate the checksum on a ROW_FORMAT=COMPRESSED page.
+@param data ROW_FORMAT=COMPRESSED page
+@param size size of the page, in bytes
+@return whether the stored checksum matches innodb_checksum_algorithm */
+bool page_zip_verify_checksum(const void *data, size_t size);
#ifndef UNIV_INNOCHECKSUM
/**********************************************************************//**
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index 1e0f00d8e90..b7ce0f05c24 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -4663,55 +4663,30 @@ page_zip_calc_checksum(
return(0);
}
-/** Verify a compressed page's checksum.
-@param[in] data compressed page
-@param[in] size size of compressed page
-@return whether the stored checksum is valid according to the value of
-innodb_checksum_algorithm */
-bool page_zip_verify_checksum(const void* data, ulint size)
+/** Validate the checksum on a ROW_FORMAT=COMPRESSED page.
+@param data ROW_FORMAT=COMPRESSED page
+@param size size of the page, in bytes
+@return whether the stored checksum matches innodb_checksum_algorithm */
+bool page_zip_verify_checksum(const void *data, size_t size)
{
- const uint32_t stored = mach_read_from_4(
- static_cast<const byte*>(data) + FIL_PAGE_SPACE_OR_CHKSUM);
-
- compile_time_assert(!(FIL_PAGE_LSN % 8));
+ const srv_checksum_algorithm_t curr_algo =
+ static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
- /* Check if page is empty */
- if (stored == 0
- && *reinterpret_cast<const ib_uint64_t*>(static_cast<const char*>(
- data)
- + FIL_PAGE_LSN) == 0) {
- /* make sure that the page is really empty */
-#ifdef UNIV_INNOCHECKSUM
- ulint i;
- for (i = 0; i < size; i++) {
- if (*((const char*) data + i) != 0)
- break;
- }
- if (i >= size) {
- if (log_file) {
- fprintf(log_file, "Page::%llu is empty and"
- " uncorrupted\n", cur_page_num);
- }
+ if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) {
+ return true;
+ }
- return(TRUE);
- }
-#else
- for (ulint i = 0; i < size; i++) {
- if (*((const char*) data + i) != 0) {
- return(FALSE);
- }
+ for (size_t i = 0; i < size; i++) {
+ if (static_cast<const byte*>(data)[i] != 0) {
+ goto not_all_zeroes;
}
- /* Empty page */
- return(TRUE);
-#endif /* UNIV_INNOCHECKSUM */
}
- const srv_checksum_algorithm_t curr_algo =
- static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
+ return true;
- if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) {
- return(TRUE);
- }
+not_all_zeroes:
+ const uint32_t stored = mach_read_from_4(
+ static_cast<const byte*>(data) + FIL_PAGE_SPACE_OR_CHKSUM);
uint32_t calc = page_zip_calc_checksum(data, size, curr_algo);
@@ -4727,7 +4702,6 @@ bool page_zip_verify_checksum(const void* data, ulint size)
}
if (!strict_verify) {
-
const uint32_t crc32 = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32);
diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c
index 41278597b0c..13f5b7d698b 100644
--- a/storage/maria/ma_page.c
+++ b/storage/maria/ma_page.c
@@ -1,4 +1,5 @@
/* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+ Copyright (c) 2020, 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
@@ -112,7 +113,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info,
if (lock != PAGECACHE_LOCK_LEFT_UNLOCKED)
{
- DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE || PAGECACHE_LOCK_READ);
+ DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE || lock == PAGECACHE_LOCK_READ);
page_link.unlock= (lock == PAGECACHE_LOCK_WRITE ?
PAGECACHE_LOCK_WRITE_UNLOCK :
PAGECACHE_LOCK_READ_UNLOCK);
diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c
index 25c79b9789f..7292f3c83b8 100644
--- a/storage/myisam/mi_range.c
+++ b/storage/myisam/mi_range.c
@@ -1,5 +1,6 @@
/*
Copyright (c) 2000, 2011, Oracle and/or its affiliates
+ Copyright (c) 2010, 2020, 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
@@ -104,7 +105,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx,
: (double) info->state->records);
res= (end_pos < start_pos ? (ha_rows) 0 :
(end_pos == start_pos ? (ha_rows) 1 : (ha_rows) (end_pos-start_pos)));
- if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR)
+ if (start_pos == (double) HA_POS_ERROR || end_pos == (double) HA_POS_ERROR)
res=HA_POS_ERROR;
else
{
diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c
index e19ce8f7cf3..d9ea4b754f2 100644
--- a/storage/myisammrg/myrg_open.c
+++ b/storage/myisammrg/myrg_open.c
@@ -1,5 +1,6 @@
/*
Copyright (c) 2000, 2011, Oracle and/or its affiliates
+ Copyright (c) 2010, 2020, 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
@@ -39,7 +40,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
uint files= 0, i, UNINIT_VAR(key_parts), min_keys= 0;
size_t length, dir_length;
ulonglong file_offset=0;
- char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end;
+ char name_buff[FN_REFLEN*2],buff[FN_REFLEN];
MYRG_INFO *m_info=0;
File fd;
IO_CACHE file;
@@ -63,8 +64,9 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
dir_length=dirname_part(name_buff, name, &name_buff_length);
while ((length=my_b_gets(&file,buff,FN_REFLEN-1)))
{
- if ((end=buff+length)[-1] == '\n')
- end[-1]='\0';
+ char *end= &buff[length - 1];
+ if (*end == '\n')
+ *end= '\0';
if (buff[0] && buff[0] != '#')
files++;
}
@@ -72,8 +74,9 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
my_b_seek(&file, 0);
while ((length=my_b_gets(&file,buff,FN_REFLEN-1)))
{
- if ((end=buff+length)[-1] == '\n')
- *--end='\0';
+ char *end= &buff[length - 1];
+ if (*end == '\n')
+ *end= '\0';
if (!buff[0])
continue; /* Skip empty lines */
if (buff[0] == '#')
diff --git a/storage/perfschema/pfs_instr_class.cc b/storage/perfschema/pfs_instr_class.cc
index 491dd5bacea..3b59375c7fc 100644
--- a/storage/perfschema/pfs_instr_class.cc
+++ b/storage/perfschema/pfs_instr_class.cc
@@ -1007,7 +1007,8 @@ static void init_instr_class(PFS_instr_class *klass,
{
DBUG_ASSERT(name_length <= PFS_MAX_INFO_NAME_LENGTH);
memset(klass, 0, sizeof(PFS_instr_class));
- memcpy(klass->m_name, name, name_length);
+ strncpy(klass->m_name, name, name_length);
+ klass->m_name[PFS_MAX_INFO_NAME_LENGTH - 1]= '\0';
klass->m_name_length= name_length;
klass->m_flags= flags;
klass->m_enabled= true;
diff --git a/strings/json_lib.c b/strings/json_lib.c
index 1e9c947a85d..42bec2c3f79 100644
--- a/strings/json_lib.c
+++ b/strings/json_lib.c
@@ -1885,7 +1885,15 @@ static enum json_types smart_read_value(json_engine_t *je,
*value_len= (int) ((char *) je->s.c_str - *value);
}
- return (enum json_types)je->value_type;
+ compile_time_assert((int) JSON_VALUE_OBJECT == (int) JSV_OBJECT);
+ compile_time_assert((int) JSON_VALUE_ARRAY == (int) JSV_ARRAY);
+ compile_time_assert((int) JSON_VALUE_STRING == (int) JSV_STRING);
+ compile_time_assert((int) JSON_VALUE_NUMBER == (int) JSV_NUMBER);
+ compile_time_assert((int) JSON_VALUE_TRUE == (int) JSV_TRUE);
+ compile_time_assert((int) JSON_VALUE_FALSE == (int) JSV_FALSE);
+ compile_time_assert((int) JSON_VALUE_NULL == (int) JSV_NULL);
+
+ return (enum json_types) je->value_type;
err_return:
return JSV_BAD_JSON;