Skip to content
Permalink
Browse files
InnoDB: Remove ut_snprintf() and the use of my_snprintf(); use snprin…
…tf()
  • Loading branch information
dr-m committed Nov 13, 2017
1 parent 17bd6ed commit c19ef50
Show file tree
Hide file tree
Showing 25 changed files with 221 additions and 282 deletions.
@@ -252,9 +252,8 @@ datadir_iter_next_database(datadir_iter_t *it)
it->dbpath = static_cast<char*>(
malloc(it->dbpath_len));
}
ut_snprintf(it->dbpath, it->dbpath_len,
"%s/%s", it->datadir_path,
it->dbinfo.name);
snprintf(it->dbpath, it->dbpath_len, "%s/%s",
it->datadir_path, it->dbinfo.name);
os_normalize_path(it->dbpath);

if (it->dbinfo.type == OS_FILE_TYPE_FILE) {
@@ -1034,8 +1033,8 @@ move_file(ds_ctxt_t *datasink,
char dst_dir_abs[FN_REFLEN];
size_t dirname_length;

ut_snprintf(dst_file_path_abs, sizeof(dst_file_path_abs),
"%s/%s", dst_dir, dst_file_path);
snprintf(dst_file_path_abs, sizeof(dst_file_path_abs),
"%s/%s", dst_dir, dst_file_path);

dirname_part(dst_dir_abs, dst_file_path_abs, &dirname_length);

@@ -1252,8 +1251,8 @@ backup_files(const char *from, bool prep_mode)
} else if (!prep_mode) {
/* backup fake file into empty directory */
char path[FN_REFLEN];
ut_snprintf(path, sizeof(path),
"%s/db.opt", node.filepath);
snprintf(path, sizeof(path),
"%s/db.opt", node.filepath);
if (!(ret = backup_file_printf(
trim_dotslash(path), "%s", ""))) {
msg("Failed to create file %s\n", path);
@@ -589,7 +589,7 @@ select_incremental_lsn_from_history(lsn_t *incremental_lsn)
mysql_real_escape_string(mysql_connection, buf,
opt_incremental_history_name,
(unsigned long)strlen(opt_incremental_history_name));
ut_snprintf(query, sizeof(query),
snprintf(query, sizeof(query),
"SELECT innodb_to_lsn "
"FROM PERCONA_SCHEMA.xtrabackup_history "
"WHERE name = '%s' "
@@ -602,7 +602,7 @@ select_incremental_lsn_from_history(lsn_t *incremental_lsn)
mysql_real_escape_string(mysql_connection, buf,
opt_incremental_history_uuid,
(unsigned long)strlen(opt_incremental_history_uuid));
ut_snprintf(query, sizeof(query),
snprintf(query, sizeof(query),
"SELECT innodb_to_lsn "
"FROM PERCONA_SCHEMA.xtrabackup_history "
"WHERE uuid = '%s' "
@@ -766,7 +766,7 @@ kill_long_queries(MYSQL *connection, time_t timeout)
is_select_query(info))) {
msg_ts("Killing query %s (duration %d sec): %s\n",
id, (int)duration, info);
ut_snprintf(kill_stmt, sizeof(kill_stmt),
snprintf(kill_stmt, sizeof(kill_stmt),
"KILL %s", id);
xb_mysql_query(connection, kill_stmt, false, false);
}
@@ -1288,8 +1288,8 @@ write_current_binlog_file(MYSQL *connection)
goto cleanup;
}

ut_snprintf(filepath, sizeof(filepath), "%s%c%s",
log_bin_dir, FN_LIBCHAR, log_bin_file);
snprintf(filepath, sizeof(filepath), "%s%c%s",
log_bin_dir, FN_LIBCHAR, log_bin_file);
result = copy_file(ds_data, filepath, log_bin_file, 0);
}

@@ -1574,8 +1574,8 @@ char *make_argv(char *buf, size_t len, int argc, char **argv)
if (strncmp(*argv, "--password", strlen("--password")) == 0) {
arg = "--password=...";
}
left-= ut_snprintf(buf + len - left, left,
"%s%c", arg, argc > 1 ? ' ' : 0);
left-= snprintf(buf + len - left, left,
"%s%c", arg, argc > 1 ? ' ' : 0);
++argv; --argc;
}

@@ -441,7 +441,7 @@ log_online_open_bitmap_file_read_only(

xb_ad(name[0] != '\0');

ut_snprintf(bitmap_file->name, FN_REFLEN, "%s%s", srv_data_home, name);
snprintf(bitmap_file->name, FN_REFLEN, "%s%s", srv_data_home, name);
bitmap_file->file = os_file_create_simple_no_error_handling(
0, bitmap_file->name,
OS_FILE_OPEN, OS_FILE_READ_ONLY, true, &success);
@@ -2685,10 +2685,10 @@ xb_load_single_table_tablespace(
name = static_cast<char*>(ut_malloc_nokey(pathlen));

if (dirname != NULL) {
ut_snprintf(name, pathlen, "%s/%s", dirname, filname);
snprintf(name, pathlen, "%s/%s", dirname, filname);
name[pathlen - 5] = 0;
} else {
ut_snprintf(name, pathlen, "%s", filname);
snprintf(name, pathlen, "%s", filname);
name[pathlen - 5] = 0;
}

@@ -2806,8 +2806,8 @@ static dberr_t enumerate_ibd_files(process_single_tablespace_func_t callback)

dbpath = static_cast<char*>(ut_malloc_nokey(dbpath_len));
}
ut_snprintf(dbpath, dbpath_len,
"%s/%s", fil_path_to_mysql_datadir, dbinfo.name);
snprintf(dbpath, dbpath_len,
"%s/%s", fil_path_to_mysql_datadir, dbinfo.name);
os_normalize_path(dbpath);

if (check_if_skip_database_by_path(dbpath)) {
@@ -206,8 +206,8 @@ buf_dump_generate_path(
{
char buf[FN_REFLEN];

ut_snprintf(buf, sizeof(buf), "%s%c%s", get_buf_dump_dir(),
OS_PATH_SEPARATOR, srv_buf_dump_filename);
snprintf(buf, sizeof(buf), "%s%c%s", get_buf_dump_dir(),
OS_PATH_SEPARATOR, srv_buf_dump_filename);

os_file_type_t type;
bool exists = false;
@@ -233,14 +233,14 @@ buf_dump_generate_path(
if (srv_data_home_full[strlen(srv_data_home_full) - 1]
== OS_PATH_SEPARATOR) {

ut_snprintf(path, path_size, "%s%s",
srv_data_home_full,
srv_buf_dump_filename);
snprintf(path, path_size, "%s%s",
srv_data_home_full,
srv_buf_dump_filename);
} else {
ut_snprintf(path, path_size, "%s%c%s",
srv_data_home_full,
OS_PATH_SEPARATOR,
srv_buf_dump_filename);
snprintf(path, path_size, "%s%c%s",
srv_data_home_full,
OS_PATH_SEPARATOR,
srv_buf_dump_filename);
}
}
}
@@ -269,8 +269,8 @@ buf_dump(

buf_dump_generate_path(full_filename, sizeof(full_filename));

ut_snprintf(tmp_filename, sizeof(tmp_filename),
"%s.incomplete", full_filename);
snprintf(tmp_filename, sizeof(tmp_filename),
"%s.incomplete", full_filename);

buf_dump_status(STATUS_INFO, "Dumping buffer pool(s) to %s",
full_filename);
@@ -6512,7 +6512,7 @@ dict_table_schema_check(
}

if (should_print) {
ut_snprintf(errstr, errstr_sz,
snprintf(errstr, errstr_sz,
"Table %s not found.",
ut_format_name(req_schema->table_name,
buf, sizeof(buf)));
@@ -6526,7 +6526,7 @@ dict_table_schema_check(
fil_space_get(table->space) == NULL) {
/* missing tablespace */

ut_snprintf(errstr, errstr_sz,
snprintf(errstr, errstr_sz,
"Tablespace for table %s is missing.",
ut_format_name(req_schema->table_name,
buf, sizeof(buf)));
@@ -6537,13 +6537,13 @@ dict_table_schema_check(
ulint n_sys_cols = dict_table_get_n_sys_cols(table);
if ((ulint) table->n_def - n_sys_cols != req_schema->n_cols) {
/* the table has a different number of columns than required */
ut_snprintf(errstr, errstr_sz,
"%s has " ULINTPF " columns but should have "
ULINTPF ".",
ut_format_name(req_schema->table_name,
buf, sizeof(buf)),
table->n_def - n_sys_cols,
req_schema->n_cols);
snprintf(errstr, errstr_sz,
"%s has " ULINTPF " columns but should have "
ULINTPF ".",
ut_format_name(req_schema->table_name, buf,
sizeof buf),
table->n_def - n_sys_cols,
req_schema->n_cols);

return(DB_ERROR);
}
@@ -6559,7 +6559,7 @@ dict_table_schema_check(

if (j == table->n_def) {

ut_snprintf(errstr, errstr_sz,
snprintf(errstr, errstr_sz,
"required column %s"
" not found in table %s.",
req_schema->columns[i].name,
@@ -6578,7 +6578,7 @@ dict_table_schema_check(

CREATE_TYPES_NAMES();

ut_snprintf(errstr, errstr_sz,
snprintf(errstr, errstr_sz,
"Column %s in table %s is %s"
" but should be %s (length mismatch).",
req_schema->columns[i].name,
@@ -6602,7 +6602,7 @@ dict_table_schema_check(
{
CREATE_TYPES_NAMES();

ut_snprintf(errstr, errstr_sz,
snprintf(errstr, errstr_sz,
"Column %s in table %s is %s"
" but should be %s (type mismatch).",
req_schema->columns[i].name,
@@ -6621,7 +6621,7 @@ dict_table_schema_check(

CREATE_TYPES_NAMES();

ut_snprintf(errstr, errstr_sz,
snprintf(errstr, errstr_sz,
"Column %s in table %s is %s"
" but should be %s (flags mismatch).",
req_schema->columns[i].name,
@@ -6634,7 +6634,7 @@ dict_table_schema_check(
}

if (req_schema->n_foreign != table->foreign_set.size()) {
ut_snprintf(
snprintf(
errstr, errstr_sz,
"Table %s has " ULINTPF " foreign key(s) pointing"
" to other tables, but it must have " ULINTPF ".",
@@ -6646,7 +6646,7 @@ dict_table_schema_check(
}

if (req_schema->n_referenced != table->referenced_set.size()) {
ut_snprintf(
snprintf(
errstr, errstr_sz,
"There are " ULINTPF " foreign key(s) pointing to %s, "
"but there must be " ULINTPF ".",
@@ -6720,7 +6720,7 @@ dict_fs2utf8(
&errors);

if (errors != 0) {
ut_snprintf(table_utf8, table_utf8_size, "%s%s",
snprintf(table_utf8, table_utf8_size, "%s%s",
srv_mysql50_table_name_prefix, table);
}
}
@@ -1067,7 +1067,7 @@ dict_mem_create_temporary_tablename(
size = dblen + (sizeof(TEMP_FILE_PREFIX) + 3 + 20 + 1 + 10);
name = static_cast<char*>(mem_heap_alloc(heap, size));
memcpy(name, dbtab, dblen);
ut_snprintf(name + dblen, size - dblen,
snprintf(name + dblen, size - dblen,
TEMP_FILE_PREFIX_INNODB UINT64PF "-" UINT32PF,
id, dict_temp_file_num);

0 comments on commit c19ef50

Please sign in to comment.