Merge 10.2 into 10.3

This commit is contained in:
Marko Mäkelä 2020-03-13 12:30:29 +02:00
commit 5fe87ac413
18 changed files with 285 additions and 106 deletions

View File

@ -1006,6 +1006,64 @@ static int install_used_engines(void)
return 0;
}
static int check_slave_repositories(void)
{
DYNAMIC_STRING ds_result;
int row_count= 0;
int error= 0;
const char *query = "SELECT COUNT(*) AS c1 FROM mysql.slave_master_info";
if (init_dynamic_string(&ds_result, "", 512, 512))
die("Out of memory");
run_query(query, &ds_result, TRUE);
if (ds_result.length)
{
row_count= atoi((char *)ds_result.str);
if (row_count)
{
fprintf(stderr,"Slave info repository compatibility check:"
" Found data in `mysql`.`slave_master_info` table.\n");
fprintf(stderr,"Warning: Content of `mysql`.`slave_master_info` table"
" will be ignored as MariaDB supports file based info "
"repository.\n");
error= 1;
}
}
dynstr_free(&ds_result);
query = "SELECT COUNT(*) AS c1 FROM mysql.slave_relay_log_info";
if (init_dynamic_string(&ds_result, "", 512, 512))
die("Out of memory");
run_query(query, &ds_result, TRUE);
if (ds_result.length)
{
row_count= atoi((char *)ds_result.str);
if (row_count)
{
fprintf(stderr, "Slave info repository compatibility check:"
" Found data in `mysql`.`slave_relay_log_info` table.\n");
fprintf(stderr, "Warning: Content of `mysql`.`slave_relay_log_info` "
"table will be ignored as MariaDB supports file based "
"repository.\n");
error= 1;
}
}
dynstr_free(&ds_result);
if (error)
{
fprintf(stderr,"Slave server may not possess the correct replication "
"metadata.\n");
fprintf(stderr, "Execution of CHANGE MASTER as per "
"`mysql`.`slave_master_info` and `mysql`.`slave_relay_log_info` "
"table content is recommended.\n");
}
return 0;
}
/*
Update all system tables in MySQL Server to current
@ -1217,7 +1275,8 @@ int main(int argc, char **argv)
run_mysqlcheck_views() ||
run_sql_fix_privilege_tables() ||
run_mysqlcheck_fixnames() ||
run_mysqlcheck_upgrade(FALSE))
run_mysqlcheck_upgrade(FALSE) ||
check_slave_repositories())
die("Upgrade failed" );
verbose("Phase %d/%d: Running 'FLUSH PRIVILEGES'", ++phase, phases_total);

View File

@ -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
@ -182,7 +182,7 @@ enum Exit_status {
*/
static Annotate_rows_log_event *annotate_event= NULL;
void free_annotate_event()
static void free_annotate_event()
{
if (annotate_event)
{
@ -928,7 +928,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
@ -939,21 +939,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

@ -1 +1 @@
Subproject commit 8e9c3116105d9a998a60991b7f4ba910d454d4b1
Subproject commit f9a50468cd7f35f2e22dc874c185e34b78766a2e

View File

@ -0,0 +1,33 @@
include/master-slave.inc
[connection master]
********************************************************************
* Test case1: Upgrade when repository tables have data. *
* mysql_upgrade script should report warnings. *
********************************************************************
connection master;
Slave info repository compatibility check: Found data in `mysql`.`slave_master_info` table.
Warning: Content of `mysql`.`slave_master_info` table will be ignored as MariaDB supports file based info repository.
Slave info repository compatibility check: Found data in `mysql`.`slave_relay_log_info` table.
Warning: Content of `mysql`.`slave_relay_log_info` table will be ignored as MariaDB supports file based repository.
Slave server may not possess the correct replication metadata.
Execution of CHANGE MASTER as per `mysql`.`slave_master_info` and `mysql`.`slave_relay_log_info` table content is recommended.
connection slave;
Slave info repository compatibility check: Found data in `mysql`.`slave_master_info` table.
Warning: Content of `mysql`.`slave_master_info` table will be ignored as MariaDB supports file based info repository.
Slave info repository compatibility check: Found data in `mysql`.`slave_relay_log_info` table.
Warning: Content of `mysql`.`slave_relay_log_info` table will be ignored as MariaDB supports file based repository.
Slave server may not possess the correct replication metadata.
Execution of CHANGE MASTER as per `mysql`.`slave_master_info` and `mysql`.`slave_relay_log_info` table content is recommended.
connection master;
TRUNCATE TABLE `mysql`.`slave_master_info`;
TRUNCATE TABLE `mysql`.`slave_relay_log_info`;
********************************************************************
* Test case2: Upgrade when repository tables are empty. *
* mysql_upgrade script should not report any warning. *
********************************************************************
connection master;
connection slave;
"====== Clean up ======"
connection master;
DROP TABLE `mysql`.`slave_master_info`, `mysql`.`slave_relay_log_info`;
include/rpl_end.inc

View File

@ -0,0 +1,127 @@
# ==== Purpose ====
#
# While upgrading from "mysql" to "mariadb" if slave info repositories are
# configured to be tables then appropriate warnings should be reported.
#
# ==== Implementation ====
#
# Steps:
# 1 - On MariaDB server create `mysql`.`slave_master_info` and
# `mysql.slave_relay_log_info` tables to simulate upgrade from "mysql"
# to "mariadb" server. Insert data into these tables.
# 2 - Execute "mysql_upgrade" script and verify that appropriate warning
# is reported. i.e Warning is to alert user that the data present in
# repository tables will be ignored.
# 3 - Truncate these tables. This simulates repositories being file and
# the tables are empty.
# 4 - Execute "mysql_upgrade" script and verify that no warnings are
# reported.
#
# ==== References ====
#
# MDEV-10047: table-based master info repository
#
--source include/have_innodb.inc
--source include/mysql_upgrade_preparation.inc
--source include/have_binlog_format_mixed.inc
--source include/master-slave.inc
--write_file $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql
--disable_query_log
--disable_result_log
SET SQL_LOG_BIN=0;
# Table structure extracted from MySQL-5.6.47
CREATE TABLE `mysql`.`slave_master_info` (
`Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file.',
`Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log currently being read from the master.',
`Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last read event.',
`Host` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'The host name of the master.',
`User_name` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',
`User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',
`Port` int(10) unsigned NOT NULL COMMENT 'The network port used to connect to the master.',
`Connect_retry` int(10) unsigned NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',
`Enabled_ssl` tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.',
`Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',
`Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',
`Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',
`Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',
`Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',
`Ssl_verify_server_cert` tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.',
`Heartbeat` float NOT NULL,
`Bind` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',
`Ignored_server_ids` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored, followed by the actual server IDs',
`Uuid` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',
`Retry_count` bigint(20) unsigned NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.',
`Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',
`Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',
`Enabled_auto_position` tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',
PRIMARY KEY (`Host`,`Port`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information';
INSERT INTO `mysql`.`slave_master_info` VALUES (23,'master-bin.000001', 120, 'localhost', 'root'," ", 13000, 60, 0," "," "," "," "," ",0 , 60," ", " ", '28e10fdd-6289-11ea-aab9-207918567a34',10," "," ", 0 );
# Table structure extracted from MySQL-5.6.47
CREATE TABLE `mysql`.`slave_relay_log_info` (
`Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file or rows in the table. Used to version table definitions.',
`Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the current relay log file.',
`Relay_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The relay log position of the last executed event.',
`Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log file from which the events in the relay log file were read.',
`Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last executed event.',
`Sql_delay` int(11) NOT NULL COMMENT 'The number of seconds that the slave must lag behind the master.',
`Number_of_workers` int(10) unsigned NOT NULL,
`Id` int(10) unsigned NOT NULL COMMENT 'Internal Id that uniquely identifies this record.',
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Relay Log Information';
INSERT INTO `mysql`.`slave_relay_log_info` VALUES (7,'./slave-relay-bin.000001',4 ," ",0, 0 ,0 , 1);
SET SQL_LOG_BIN=1;
--enable_query_log
--enable_result_log
EOF
--echo ********************************************************************
--echo * Test case1: Upgrade when repository tables have data. *
--echo * mysql_upgrade script should report warnings. *
--echo ********************************************************************
--connection master
--source $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql
--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log 2>&1
--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log
--connection slave
--source $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql
--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log 2>&1
--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log
--connection master
let $datadir= `select @@datadir`;
remove_file $datadir/mysql_upgrade_info;
TRUNCATE TABLE `mysql`.`slave_master_info`;
TRUNCATE TABLE `mysql`.`slave_relay_log_info`;
--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log
--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log
--echo ********************************************************************
--echo * Test case2: Upgrade when repository tables are empty. *
--echo * mysql_upgrade script should not report any warning. *
--echo ********************************************************************
--connection master
--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log 2>&1
--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log
--connection slave
--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log 2>&1
--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log
--echo "====== Clean up ======"
--connection master
let $datadir= `select @@datadir`;
remove_file $datadir/mysql_upgrade_info;
DROP TABLE `mysql`.`slave_master_info`, `mysql`.`slave_relay_log_info`;
--remove_file $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql
--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log
--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log
--source include/rpl_end.inc

View File

@ -730,7 +730,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;

View File

@ -5168,7 +5168,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->select_limit_cnt);
join->select_lex->increase_derived_records(rows);
}

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
Copyright (c) 2009, 2013 Monty Program Ab.
Copyright (c) 2009, 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
@ -476,7 +476,7 @@ bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime,
if (neg)
value= -value;
if (value > LONGLONG_MAX)
if (value > static_cast<double>(LONGLONG_MAX))
value= static_cast<double>(LONGLONG_MAX);
longlong nr= static_cast<ulonglong>(floor(value));

View File

@ -4013,7 +4013,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;
}

View File

@ -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
@ -784,7 +784,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)
{
@ -842,7 +842,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);

View File

@ -8004,31 +8004,24 @@ i_s_dict_fill_sys_tablespaces(
OK(fields[SYS_TABLESPACES_ZIP_PAGE_SIZE]->store(
page_size.physical(), 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 "
@ -8046,7 +8039,8 @@ i_s_dict_fill_sys_tablespaces(
break;
}
ut_free(filepath);
file_done:
s->release();
}
if (file.m_total_size == static_cast<os_offset_t>(~0)) {

View File

@ -1400,7 +1400,7 @@ buf_page_encrypt_before_write(
NOTE! The definition appears here only for other modules of this
directory (buf) to see it. Do not use from outside! */
typedef struct {
struct buf_tmp_buffer_t {
private:
int32 reserved; /*!< true if this slot is reserved
*/
@ -1430,7 +1430,7 @@ public:
return !my_atomic_fas32_explicit(&reserved, true,
MY_MEMORY_ORDER_RELAXED);
}
} buf_tmp_buffer_t;
};
/** The common buffer control block structure
for compressed and uncompressed frames */

View File

@ -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

View File

@ -2,7 +2,7 @@
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
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
@ -524,15 +524,11 @@ page_zip_calc_checksum(
#endif
);
/**********************************************************************//**
Verify a compressed page's checksum.
@return TRUE if the stored checksum is valid according to the value of
innodb_checksum_algorithm */
ibool
page_zip_verify_checksum(
/*=====================*/
const void* data, /*!< in: compressed page */
ulint size); /*!< in: size of compressed page */
/** 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
/**********************************************************************//**

View File

@ -5060,59 +5060,31 @@ page_zip_calc_checksum(
return(0);
}
/**********************************************************************//**
Verify a compressed page's checksum.
@return TRUE if the stored checksum is valid according to the value of
innodb_checksum_algorithm */
ibool
page_zip_verify_checksum(
/*=====================*/
const void* data, /*!< in: compressed page */
ulint size) /*!< in: size of compressed page */
/** 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));
/* 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);
}
return(TRUE);
}
#else
for (ulint i = 0; i < size; i++) {
if (*((const char*) data + i) != 0) {
return(FALSE);
}
}
/* Empty page */
return(TRUE);
#endif /* UNIV_INNOCHECKSUM */
}
const srv_checksum_algorithm_t curr_algo =
static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) {
return(TRUE);
return true;
}
for (size_t i = 0; i < size; i++) {
if (static_cast<const byte*>(data)[i] != 0) {
goto not_all_zeroes;
}
}
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);
#ifdef UNIV_INNOCHECKSUM
@ -5127,7 +5099,6 @@ page_zip_verify_checksum(
}
if (!strict_verify) {
const uint32_t crc32 = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32);

View File

@ -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

View File

@ -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] == '#')

View File

@ -1,4 +1,5 @@
/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
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, version 2.0,
@ -612,6 +613,7 @@ 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));
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;