Skip to content

Commit

Permalink
Merge mariadb-10.5.19 into 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Feb 6, 2023
2 parents f6da6b2 + f8a85af commit ff12a5b
Show file tree
Hide file tree
Showing 116 changed files with 3,291 additions and 653 deletions.
1 change: 1 addition & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ MariaDB Corporation https://www.mariadb.com (2013)
Microsoft https://microsoft.com/ (2017)
ServiceNow https://servicenow.com (2019)
SIT https://sit.org (2022)
Tencent Cloud https://cloud.tencent.com (2017)
Development Bank of Singapore https://dbs.com (2016)
IBM https://www.ibm.com (2017)
Automattic https://automattic.com (2019)
Expand Down
3 changes: 3 additions & 0 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3606,7 +3606,10 @@ print_table_data(MYSQL_RES *result)
{
print_field_types(result);
if (!mysql_num_rows(result))
{
my_afree((uchar*) num_flag);
return;
}
mysql_field_seek(result,0);
}
separator.copy("+",1,charset_info);
Expand Down
84 changes: 40 additions & 44 deletions client/mysql_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,14 @@ static int file_exists(char * filename)
@retval int error = 1, success = 0
*/

static int search_dir(const char * base_path, const char *tool_name,
static int search_dir(const char *base_path, const char *tool_name,
const char *subdir, char *tool_path)
{
char new_path[FN_REFLEN];
char source_path[FN_REFLEN];

strcpy(source_path, base_path);
strcat(source_path, subdir);
safe_strcpy(source_path, sizeof(source_path), base_path);
safe_strcat(source_path, sizeof(source_path), subdir);
fn_format(new_path, tool_name, source_path, "", MY_UNPACK_FILENAME);
if (file_exists(new_path))
{
Expand Down Expand Up @@ -632,7 +632,7 @@ static int load_plugin_data(char *plugin_name, char *config_file)
FILE *file_ptr;
char path[FN_REFLEN];
char line[1024];
char *reason= 0;
const char *reason= 0;
char *res;
int i= -1;

Expand All @@ -643,14 +643,14 @@ static int load_plugin_data(char *plugin_name, char *config_file)
}
if (!file_exists(opt_plugin_ini))
{
reason= (char *)"File does not exist.";
reason= "File does not exist.";
goto error;
}

file_ptr= fopen(opt_plugin_ini, "r");
if (file_ptr == NULL)
{
reason= (char *)"Cannot open file.";
reason= "Cannot open file.";
goto error;
}

Expand All @@ -660,17 +660,20 @@ static int load_plugin_data(char *plugin_name, char *config_file)
/* Read plugin components */
while (i < 16)
{
size_t line_len;

res= fgets(line, sizeof(line), file_ptr);
line_len= strlen(line);

/* strip /n */
if (line[strlen(line)-1] == '\n')
{
line[strlen(line)-1]= '\0';
}
if (line[line_len - 1] == '\n')
line[line_len - 1]= '\0';

if (res == NULL)
{
if (i < 1)
{
reason= (char *)"Bad format in plugin configuration file.";
reason= "Bad format in plugin configuration file.";
fclose(file_ptr);
goto error;
}
Expand All @@ -683,14 +686,19 @@ static int load_plugin_data(char *plugin_name, char *config_file)
if (i == -1) /* if first pass, read this line as so_name */
{
/* Add proper file extension for soname */
strcat(line, FN_SOEXT);
if (safe_strcpy(line + line_len - 1, sizeof(line), FN_SOEXT))
{
reason= "Plugin name too long.";
fclose(file_ptr);
goto error;
}
/* save so_name */
plugin_data.so_name= my_strdup(PSI_NOT_INSTRUMENTED, line, MYF(MY_WME|MY_ZEROFILL));
i++;
}
else
{
if (strlen(line) > 0)
if (line_len > 0)
{
plugin_data.components[i]= my_strdup(PSI_NOT_INSTRUMENTED, line, MYF(MY_WME));
i++;
Expand Down Expand Up @@ -779,14 +787,13 @@ static int check_options(int argc, char **argv, char *operation)
/* read the plugin config file and check for match against argument */
else
{
if (strlen(argv[i]) + 4 + 1 > FN_REFLEN)
if (safe_strcpy(plugin_name, sizeof(plugin_name), argv[i]) ||
safe_strcpy(config_file, sizeof(config_file), argv[i]) ||
safe_strcat(config_file, sizeof(config_file), ".ini"))
{
fprintf(stderr, "ERROR: argument is too long.\n");
return 1;
}
strcpy(plugin_name, argv[i]);
strcpy(config_file, argv[i]);
strcat(config_file, ".ini");
}
}

Expand Down Expand Up @@ -855,35 +862,30 @@ static int check_options(int argc, char **argv, char *operation)
static int process_options(int argc, char *argv[], char *operation)
{
int error= 0;
int i= 0;

/* Parse and execute command-line options */
if ((error= handle_options(&argc, &argv, my_long_options, get_one_option)))
goto exit;
return error;

/* If the print defaults option used, exit. */
if (opt_print_defaults)
{
error= -1;
goto exit;
}
return -1;

/* Add a trailing directory separator if not present */
if (opt_basedir)
{
i= (int)strlength(opt_basedir);
if (opt_basedir[i-1] != FN_LIBCHAR || opt_basedir[i-1] != FN_LIBCHAR2)
size_t basedir_len= strlength(opt_basedir);
if (opt_basedir[basedir_len - 1] != FN_LIBCHAR ||
opt_basedir[basedir_len - 1] != FN_LIBCHAR2)
{
char buff[FN_REFLEN];
memset(buff, 0, sizeof(buff));
if (basedir_len + 2 > FN_REFLEN)
return -1;

strncpy(buff, opt_basedir, sizeof(buff) - 1);
#ifdef __WIN__
strncat(buff, "/", sizeof(buff) - strlen(buff) - 1);
#else
strncat(buff, FN_DIRSEP, sizeof(buff) - strlen(buff) - 1);
#endif
buff[sizeof(buff) - 1]= 0;
memcpy(buff, opt_basedir, basedir_len);
buff[basedir_len]= '/';
buff[basedir_len + 1]= '\0';

my_free(opt_basedir);
opt_basedir= my_strdup(PSI_NOT_INSTRUMENTED, buff, MYF(MY_FAE));
}
Expand All @@ -895,22 +897,17 @@ static int process_options(int argc, char *argv[], char *operation)
generated when the defaults were read from the file, exit.
*/
if (!opt_no_defaults && ((error= get_default_values())))
{
error= -1;
goto exit;
}
return -1;

/*
Check to ensure required options are present and validate the operation.
Note: this method also validates the plugin specified by attempting to
read a configuration file named <plugin_name>.ini from the --plugin-dir
or --plugin-ini location if the --plugin-ini option presented.
*/
strcpy(operation, "");
if ((error = check_options(argc, argv, operation)))
{
goto exit;
}
operation[0]= '\0';
if ((error= check_options(argc, argv, operation)))
return error;

if (opt_verbose)
{
Expand All @@ -922,8 +919,7 @@ static int process_options(int argc, char *argv[], char *operation)
printf("# lc_messages_dir = %s\n", opt_lc_messages_dir);
}

exit:
return error;
return 0;
}


Expand Down
2 changes: 1 addition & 1 deletion client/mysqldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,7 @@ static uint dump_events_for_db(char *db)
if (mysql_query_with_error_report(mysql, &event_list_res, "show events"))
DBUG_RETURN(0);

strcpy(delimiter, ";");
safe_strcpy(delimiter, sizeof(delimiter), ";");
if (mysql_num_rows(event_list_res) > 0)
{
if (opt_xml)
Expand Down
15 changes: 9 additions & 6 deletions client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6167,7 +6167,9 @@ int do_done(struct st_command *command)
if (*cur_block->delim)
{
/* Restore "old" delimiter after false if block */
strcpy (delimiter, cur_block->delim);
if (safe_strcpy(delimiter, sizeof(delimiter), cur_block->delim))
die("Delimiter too long, truncated");

delimiter_length= strlen(delimiter);
}
/* Pop block from stack, goto next line */
Expand Down Expand Up @@ -6422,10 +6424,12 @@ void do_block(enum block_cmd cmd, struct st_command* command)
if (cur_block->ok)
{
cur_block->delim[0]= '\0';
} else
}
else
{
/* Remember "old" delimiter if entering a false if block */
strcpy (cur_block->delim, delimiter);
if (safe_strcpy(cur_block->delim, sizeof(cur_block->delim), delimiter))
die("Delimiter too long, truncated");
}

DBUG_PRINT("info", ("OK: %d", cur_block->ok));
Expand Down Expand Up @@ -11769,9 +11773,8 @@ static int setenv(const char *name, const char *value, int overwrite)
char *envvar= (char *)malloc(buflen);
if(!envvar)
return ENOMEM;
strcpy(envvar, name);
strcat(envvar, "=");
strcat(envvar, value);

snprintf(envvar, buflen, "%s=%s", name, value);
putenv(envvar);
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions cmake/install_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ IF(WIN32)
OPTION(SIGNCODE "Sign executables and dlls with digital certificate" OFF)
MARK_AS_ADVANCED(SIGNCODE)
IF(SIGNCODE)
SET(SIGNTOOL_PARAMETERS
/a /t http://timestamp.globalsign.com/?signature=sha2
SET(SIGNTOOL_PARAMETERS
/a /fd SHA256 /t http://timestamp.globalsign.com/?signature=sha2
CACHE STRING "parameters for signtool (list)")
IF(NOT SIGNTOOL_EXECUTABLE)
FILE(GLOB path_list
Expand Down
2 changes: 1 addition & 1 deletion dbug/dbug.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ static int DbugParse(CODE_STATE *cs, const char *control)
stack->delay= stack->next->delay;
stack->maxdepth= stack->next->maxdepth;
stack->sub_level= stack->next->sub_level;
strcpy(stack->name, stack->next->name);
safe_strcpy(stack->name, sizeof(stack->name), stack->next->name);
stack->out_file= stack->next->out_file;
stack->out_file->used++;
if (stack->next == &init_settings)
Expand Down
8 changes: 2 additions & 6 deletions extra/innochecksum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -837,19 +837,15 @@ parse_page(
{
unsigned long long id;
uint16_t undo_page_type;
char str[20]={'\0'};
const char *str;
ulint n_recs;
uint32_t page_no, left_page_no, right_page_no;
ulint data_bytes;
bool is_leaf;
ulint size_range_id;

/* Check whether page is doublewrite buffer. */
if(skip_page) {
strcpy(str, "Double_write_buffer");
} else {
strcpy(str, "-");
}
str = skip_page ? "Double_write_buffer" : "-";

switch (fil_page_get_type(page)) {

Expand Down
49 changes: 48 additions & 1 deletion extra/mariabackup/backup_copy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA
#include "backup_copy.h"
#include "backup_mysql.h"
#include <btr0btr.h>
#ifdef _WIN32
#include <direct.h> /* rmdir */
#endif

#define ROCKSDB_BACKUP_DIR "#rocksdb"

Expand Down Expand Up @@ -1618,7 +1621,49 @@ bool backup_finish()
return(true);
}

bool

/*
Drop all empty database directories in the base backup
that do not exists in the icremental backup.
This effectively re-plays all DROP DATABASE statements happened
in between base backup and incremental backup creation time.
Note, only checking if base_dir/db/ is empty is not enough,
because inc_dir/db/db.opt might have been dropped for some reasons,
which may also result into empty base_dir/db/.
Only the fact that at the same time:
- base_dir/db/ exists
- inc_dir/db/ does not exist
means that DROP DATABASE happened.
*/
static void
ibx_incremental_drop_databases(const char *base_dir,
const char *inc_dir)
{
datadir_node_t node;
datadir_node_init(&node);
datadir_iter_t *it = datadir_iter_new(base_dir);

while (datadir_iter_next(it, &node)) {
if (node.is_empty_dir) {
char path[FN_REFLEN];
snprintf(path, sizeof(path), "%s/%s",
inc_dir, node.filepath_rel);
if (!directory_exists(path, false)) {
msg("Removing %s", node.filepath);
rmdir(node.filepath);
}
}

}
datadir_iter_free(it);
datadir_node_free(&node);
}


static bool
ibx_copy_incremental_over_full()
{
const char *ext_list[] = {"frm", "isl", "MYD", "MYI", "MAD", "MAI",
Expand Down Expand Up @@ -1701,6 +1746,8 @@ ibx_copy_incremental_over_full()
}
copy_or_move_dir(path, ROCKSDB_BACKUP_DIR, true, true);
}
ibx_incremental_drop_databases(xtrabackup_target_dir,
xtrabackup_incremental_dir);
}


Expand Down
7 changes: 5 additions & 2 deletions extra/mariabackup/xbcloud.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1676,8 +1676,11 @@ container_list_add_object(container_list *list, const char *name,
list->object_count += object_count_step;
}
assert(list->idx <= list->object_count);
strcpy(list->objects[list->idx].name, name);
strcpy(list->objects[list->idx].hash, hash);
safe_strcpy(list->objects[list->idx].name,
sizeof(list->objects[list->idx].name), name);
safe_strcpy(list->objects[list->idx].hash,
sizeof(list->objects[list->idx].hash), hash);

list->objects[list->idx].bytes = bytes;
++list->idx;
}
Expand Down
Loading

0 comments on commit ff12a5b

Please sign in to comment.