Remove the wrappers ut_time(), ut_difftime(), ib_time_t

This commit is contained in:
Marko Mäkelä 2019-07-24 21:43:19 +03:00
parent c663a9414b
commit 0c7c61019d
45 changed files with 162 additions and 277 deletions

View File

@ -1688,7 +1688,7 @@ buf_pool_init_instance(
buf_pool->zip_hash = hash_create(2 * buf_pool->curr_size); buf_pool->zip_hash = hash_create(2 * buf_pool->curr_size);
buf_pool->last_printout_time = ut_time(); buf_pool->last_printout_time = time(NULL);
} }
/* 2. Initialize flushing fields /* 2. Initialize flushing fields
-------------------------------- */ -------------------------------- */
@ -6160,7 +6160,7 @@ buf_refresh_io_stats(
/*=================*/ /*=================*/
buf_pool_t* buf_pool) /*!< in: buffer pool instance */ buf_pool_t* buf_pool) /*!< in: buffer pool instance */
{ {
buf_pool->last_printout_time = ut_time(); buf_pool->last_printout_time = time(NULL);
buf_pool->old_stat = buf_pool->stat; buf_pool->old_stat = buf_pool->stat;
} }

View File

@ -750,7 +750,7 @@ void
dict_mem_init(void) dict_mem_init(void)
{ {
/* Initialize a randomly distributed temporary file number */ /* Initialize a randomly distributed temporary file number */
ib_uint32_t now = static_cast<ib_uint32_t>(ut_time()); ib_uint32_t now = static_cast<ib_uint32_t>(time(NULL));
const byte* buf = reinterpret_cast<const byte*>(&now); const byte* buf = reinterpret_cast<const byte*>(&now);
ut_ad(ut_crc32 != NULL); ut_ad(ut_crc32 != NULL);

View File

@ -45,7 +45,7 @@ Created Jan 06, 2010 Vasil Dimov
#include "trx0trx.h" /* trx_create() */ #include "trx0trx.h" /* trx_create() */
#include "trx0roll.h" /* trx_rollback_to_savepoint() */ #include "trx0roll.h" /* trx_rollback_to_savepoint() */
#include "ut0rnd.h" /* ut_rnd_interval() */ #include "ut0rnd.h" /* ut_rnd_interval() */
#include "ut0ut.h" /* ut_format_name(), ut_time() */ #include "ut0ut.h" /* ut_format_name() */
#include <algorithm> #include <algorithm>
#include <map> #include <map>
@ -1000,7 +1000,7 @@ dict_stats_update_transient(
table->stat_sum_of_other_index_sizes = sum_of_index_sizes table->stat_sum_of_other_index_sizes = sum_of_index_sizes
- index->stat_index_size; - index->stat_index_size;
table->stats_last_recalc = ut_time(); table->stats_last_recalc = time(NULL);
table->stat_modified_counter = 0; table->stat_modified_counter = 0;
@ -2325,7 +2325,7 @@ dict_stats_update_persistent(
+= index->stat_index_size; += index->stat_index_size;
} }
table->stats_last_recalc = ut_time(); table->stats_last_recalc = time(NULL);
table->stat_modified_counter = 0; table->stat_modified_counter = 0;
@ -2535,7 +2535,7 @@ dict_stats_save(
/* MySQL's timestamp is 4 byte, so we use /* MySQL's timestamp is 4 byte, so we use
pars_info_add_int4_literal() which takes a lint arg, so "now" is pars_info_add_int4_literal() which takes a lint arg, so "now" is
lint */ lint */
now = (lint) ut_time(); now = (lint) time(NULL);
pinfo = pars_info_create(); pinfo = pars_info_create();
@ -3980,7 +3980,7 @@ dict_stats_save_defrag_summary(
dict_index_t* index) /*!< in: index */ dict_index_t* index) /*!< in: index */
{ {
dberr_t ret; dberr_t ret;
lint now = (lint) ut_time(); lint now = (lint) time(NULL);
if (dict_index_is_univ(index)) { if (dict_index_is_univ(index)) {
return DB_SUCCESS; return DB_SUCCESS;
} }
@ -4017,7 +4017,7 @@ dict_stats_save_defrag_stats(
return DB_SUCCESS; return DB_SUCCESS;
} }
lint now = (lint) ut_time(); lint now = (lint) time(NULL);
mtr_t mtr; mtr_t mtr;
ulint n_leaf_pages; ulint n_leaf_pages;
ulint n_leaf_reserved; ulint n_leaf_reserved;

View File

@ -437,14 +437,14 @@ dict_stats_process_entry_from_recalc_pool()
mutex_exit(&dict_sys->mutex); mutex_exit(&dict_sys->mutex);
/* ut_time() could be expensive, the current function /* time() could be expensive, the current function
is called once every time a table has been changed more than 10% and is called once every time a table has been changed more than 10% and
on a system with lots of small tables, this could become hot. If we on a system with lots of small tables, this could become hot. If we
find out that this is a problem, then the check below could eventually find out that this is a problem, then the check below could eventually
be replaced with something else, though a time interval is the natural be replaced with something else, though a time interval is the natural
approach. */ approach. */
if (ut_difftime(ut_time(), table->stats_last_recalc) if (difftime(time(NULL), table->stats_last_recalc)
< MIN_RECALC_INTERVAL) { < MIN_RECALC_INTERVAL) {
/* Stats were (re)calculated not long ago. To avoid /* Stats were (re)calculated not long ago. To avoid

View File

@ -1,6 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@ -858,7 +859,7 @@ eval_predefined(
dfield_get_data(que_node_get_val(arg1))); dfield_get_data(que_node_get_val(arg1)));
} else if (func == PARS_SYSDATE_TOKEN) { } else if (func == PARS_SYSDATE_TOKEN) {
int_val = (lint) ut_time(); int_val = (lint) time(NULL);
} else { } else {
eval_predefined_2(func_node); eval_predefined_2(func_node);

View File

@ -77,8 +77,8 @@ UNIV_INTERN ulong fts_min_token_size;
// FIXME: testing // FIXME: testing
ib_time_t elapsed_time = 0; static time_t elapsed_time;
ulint n_nodes = 0; static ulint n_nodes;
/** Error condition reported by fts_utf8_decode() */ /** Error condition reported by fts_utf8_decode() */
const ulint UTF8_ERROR = 0xFFFFFFFF; const ulint UTF8_ERROR = 0xFFFFFFFF;
@ -3798,7 +3798,7 @@ fts_write_node(
pars_info_t* info; pars_info_t* info;
dberr_t error; dberr_t error;
ib_uint32_t doc_count; ib_uint32_t doc_count;
ib_time_t start_time; time_t start_time;
doc_id_t last_doc_id; doc_id_t last_doc_id;
doc_id_t first_doc_id; doc_id_t first_doc_id;
char table_name[MAX_FULL_NAME_LEN]; char table_name[MAX_FULL_NAME_LEN];
@ -3845,9 +3845,9 @@ fts_write_node(
" :last_doc_id, :doc_count, :ilist);"); " :last_doc_id, :doc_count, :ilist);");
} }
start_time = ut_time(); start_time = time(NULL);
error = fts_eval_sql(trx, *graph); error = fts_eval_sql(trx, *graph);
elapsed_time += ut_time() - start_time; elapsed_time += time(NULL) - start_time;
++n_nodes; ++n_nodes;
return(error); return(error);
@ -4298,7 +4298,7 @@ fts_sync_begin(
n_nodes = 0; n_nodes = 0;
elapsed_time = 0; elapsed_time = 0;
sync->start_time = ut_time(); sync->start_time = time(NULL);
sync->trx = trx_allocate_for_background(); sync->trx = trx_allocate_for_background();
@ -4457,7 +4457,7 @@ fts_sync_commit(
"SYNC for table %s: SYNC time : %lu secs: " "SYNC for table %s: SYNC time : %lu secs: "
"elapsed %lf ins/sec", "elapsed %lf ins/sec",
sync->table->name, sync->table->name,
(ulong) (ut_time() - sync->start_time), (ulong) (time(NULL) - sync->start_time),
(double) n_nodes/ (double) elapsed_time); (double) n_nodes/ (double) elapsed_time);
} }

View File

@ -1648,7 +1648,7 @@ fts_optimize_get_index_start_time(
/*==============================*/ /*==============================*/
trx_t* trx, /*!< in: transaction */ trx_t* trx, /*!< in: transaction */
dict_index_t* index, /*!< in: FTS index */ dict_index_t* index, /*!< in: FTS index */
ib_time_t* start_time) /*!< out: time in secs */ time_t* start_time) /*!< out: time in secs */
{ {
return(fts_config_get_index_ulint( return(fts_config_get_index_ulint(
trx, index, FTS_OPTIMIZE_START_TIME, trx, index, FTS_OPTIMIZE_START_TIME,
@ -1664,7 +1664,7 @@ fts_optimize_set_index_start_time(
/*==============================*/ /*==============================*/
trx_t* trx, /*!< in: transaction */ trx_t* trx, /*!< in: transaction */
dict_index_t* index, /*!< in: FTS index */ dict_index_t* index, /*!< in: FTS index */
ib_time_t start_time) /*!< in: start time */ time_t start_time) /*!< in: start time */
{ {
return(fts_config_set_index_ulint( return(fts_config_set_index_ulint(
trx, index, FTS_OPTIMIZE_START_TIME, trx, index, FTS_OPTIMIZE_START_TIME,
@ -1918,7 +1918,7 @@ fts_optimize_index_completed(
dberr_t error; dberr_t error;
byte buf[sizeof(ulint)]; byte buf[sizeof(ulint)];
#ifdef FTS_OPTIMIZE_DEBUG #ifdef FTS_OPTIMIZE_DEBUG
ib_time_t end_time = ut_time(); time_t end_time = time(NULL);
error = fts_optimize_set_index_end_time(optim->trx, index, end_time); error = fts_optimize_set_index_end_time(optim->trx, index, end_time);
#endif #endif
@ -2337,14 +2337,14 @@ fts_optimize_indexes(
/* Start time will be 0 only for the first time or after /* Start time will be 0 only for the first time or after
completing the optimization of all FTS indexes. */ completing the optimization of all FTS indexes. */
if (start_time == 0) { if (start_time == 0) {
start_time = ut_time(); start_time = time(NULL);
error = fts_optimize_set_index_start_time( error = fts_optimize_set_index_start_time(
optim->trx, index, start_time); optim->trx, index, start_time);
} }
/* Check if this index needs to be optimized or not. */ /* Check if this index needs to be optimized or not. */
if (ut_difftime(end_time, start_time) < 0) { if (difftime(end_time, start_time) < 0) {
error = fts_optimize_index(optim, index); error = fts_optimize_index(optim, index);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
@ -2416,7 +2416,7 @@ fts_optimize_reset_start_time(
for (uint i = 0; i < ib_vector_size(fts->indexes); ++i) { for (uint i = 0; i < ib_vector_size(fts->indexes); ++i) {
dict_index_t* index; dict_index_t* index;
ib_time_t start_time = 0; time_t start_time = 0;
/* Reset the start time to 0 for this index. */ /* Reset the start time to 0 for this index. */
error = fts_optimize_set_index_start_time( error = fts_optimize_set_index_start_time(
@ -2471,7 +2471,7 @@ fts_optimize_table_bk(
&& table->fts->cache->deleted >= FTS_OPTIMIZE_THRESHOLD) { && table->fts->cache->deleted >= FTS_OPTIMIZE_THRESHOLD) {
error = fts_optimize_table(table); error = fts_optimize_table(table);
slot->last_run = ut_time(); slot->last_run = time(NULL);
if (error == DB_SUCCESS) { if (error == DB_SUCCESS) {
slot->running = false; slot->running = false;
@ -3001,7 +3001,7 @@ fts_optimize_init(void)
fts_optimize_wq = ib_wqueue_create(); fts_optimize_wq = ib_wqueue_create();
ut_a(fts_optimize_wq != NULL); ut_a(fts_optimize_wq != NULL);
last_check_sync_time = ut_time(); last_check_sync_time = time(NULL);
os_thread_create(fts_optimize_thread, fts_optimize_wq, NULL); os_thread_create(fts_optimize_thread, fts_optimize_wq, NULL);
} }

View File

@ -2,7 +2,7 @@
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@ -1181,7 +1181,7 @@ struct dict_table_t{
goes to zero. If it's -1, means there's DDL goes to zero. If it's -1, means there's DDL
on the table, DML from memcached will be on the table, DML from memcached will be
blocked. */ blocked. */
ib_time_t stats_last_recalc; time_t stats_last_recalc;
/*!< Timestamp of last recalc of the stats */ /*!< Timestamp of last recalc of the stats */
ib_uint32_t stat_persistent; ib_uint32_t stat_persistent;
/*!< The two bits below are set in the /*!< The two bits below are set in the

View File

@ -426,7 +426,7 @@ struct recv_sys_t{
log record, or there is a log parsing log record, or there is a log parsing
buffer overflow */ buffer overflow */
/** the time when progress was last reported */ /** the time when progress was last reported */
ib_time_t progress_time; time_t progress_time;
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
log_group_t* archive_group; log_group_t* archive_group;
/*!< in archive recovery: the log group whose /*!< in archive recovery: the log group whose
@ -444,7 +444,7 @@ struct recv_sys_t{
@param[in] time the current time @param[in] time the current time
@return whether progress should be reported @return whether progress should be reported
(the last report was at least 15 seconds ago) */ (the last report was at least 15 seconds ago) */
bool report(ib_time_t time) bool report(time_t time)
{ {
if (time - progress_time < 15) { if (time - progress_time < 15) {
return false; return false;

View File

@ -58,9 +58,9 @@ create the internal counter ID in "monitor_id_t". */
/** Structure containing the actual values of a monitor counter. */ /** Structure containing the actual values of a monitor counter. */
struct monitor_value_t { struct monitor_value_t {
ib_time_t mon_start_time; /*!< Start time of monitoring */ time_t mon_start_time; /*!< Start time of monitoring */
ib_time_t mon_stop_time; /*!< Stop time of monitoring */ time_t mon_stop_time; /*!< Stop time of monitoring */
ib_time_t mon_reset_time; /*!< Time counter resetted */ time_t mon_reset_time; /*!< Time of resetting the counter */
mon_type_t mon_value; /*!< Current counter Value */ mon_type_t mon_value; /*!< Current counter Value */
mon_type_t mon_max_value; /*!< Current Max value */ mon_type_t mon_max_value; /*!< Current Max value */
mon_type_t mon_min_value; /*!< Current Min value */ mon_type_t mon_min_value; /*!< Current Min value */

View File

@ -129,7 +129,7 @@ struct i_s_trx_row_t {
trx_id_t trx_id; /*!< transaction identifier */ trx_id_t trx_id; /*!< transaction identifier */
const char* trx_state; /*!< transaction state from const char* trx_state; /*!< transaction state from
trx_get_que_state_str() */ trx_get_que_state_str() */
ib_time_t trx_started; /*!< trx_t::start_time */ time_t trx_started; /*!< trx_t::start_time */
const i_s_locks_row_t* requested_lock_row; const i_s_locks_row_t* requested_lock_row;
/*!< pointer to a row /*!< pointer to a row
in innodb_locks if trx in innodb_locks if trx

View File

@ -53,9 +53,6 @@ Created 1/20/1994 Heikki Tuuri
/** Index name prefix in fast index creation, as a string constant */ /** Index name prefix in fast index creation, as a string constant */
#define TEMP_INDEX_PREFIX_STR "\377" #define TEMP_INDEX_PREFIX_STR "\377"
/** Time stamp */
typedef time_t ib_time_t;
/* In order to call a piece of code, when a function returns or when the /* In order to call a piece of code, when a function returns or when the
scope ends, use this utility class. It will invoke the given function scope ends, use this utility class. It will invoke the given function
object in its destructor. */ object in its destructor. */
@ -235,27 +232,6 @@ store the given number of bits.
#define UT_BITS_IN_BYTES(b) (((b) + 7) / 8) #define UT_BITS_IN_BYTES(b) (((b) + 7) / 8)
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
/**********************************************************//**
Returns system time. We do not specify the format of the time returned:
the only way to manipulate it is to use the function ut_difftime.
@return system time */
UNIV_INTERN
ib_time_t
ut_time(void);
/*=========*/
#ifndef UNIV_HOTBACKUP
/**********************************************************//**
Returns the number of milliseconds since some epoch. The
value may wrap around. It should only be used for heuristic
purposes.
@return ms since epoch */
UNIV_INTERN
ulint
ut_time_ms(void);
/*============*/
#endif /* !UNIV_HOTBACKUP */
/**********************************************************//** /**********************************************************//**
Returns the number of milliseconds since some epoch. The Returns the number of milliseconds since some epoch. The
value may wrap around. It should only be used for heuristic value may wrap around. It should only be used for heuristic
@ -265,17 +241,6 @@ UNIV_INTERN
ulint ulint
ut_time_ms(void); ut_time_ms(void);
/*============*/ /*============*/
/**********************************************************//**
Returns the difference of two times in seconds.
@return time2 - time1 expressed in seconds */
UNIV_INTERN
double
ut_difftime(
/*========*/
ib_time_t time2, /*!< in: time */
ib_time_t time1); /*!< in: time */
#endif /* !UNIV_INNOCHECKSUM */ #endif /* !UNIV_INNOCHECKSUM */
/**********************************************************//** /**********************************************************//**

View File

@ -2171,7 +2171,7 @@ lock_rec_create(
/* Set the bit corresponding to rec */ /* Set the bit corresponding to rec */
lock_rec_set_nth_bit(lock, heap_no); lock_rec_set_nth_bit(lock, heap_no);
lock->requested_time = ut_time(); lock->requested_time = time(NULL);
lock->wait_time = 0; lock->wait_time = 0;
index->table->n_rec_locks++; index->table->n_rec_locks++;
@ -3052,16 +3052,18 @@ lock_grant(
} }
} }
const time_t now = time(NULL);
/* Cumulate total lock wait time for statistics */ /* Cumulate total lock wait time for statistics */
if (lock_get_type_low(lock) & LOCK_TABLE) { if (lock_get_type_low(lock) & LOCK_TABLE) {
lock->trx->total_table_lock_wait_time += lock->trx->total_table_lock_wait_time +=
(ulint)difftime(ut_time(), lock->trx->lock.wait_started); (ulint)difftime(now, lock->trx->lock.wait_started);
} else { } else {
lock->trx->total_rec_lock_wait_time += lock->trx->total_rec_lock_wait_time +=
(ulint)difftime(ut_time(), lock->trx->lock.wait_started); (ulint)difftime(now, lock->trx->lock.wait_started);
} }
lock->wait_time = (ulint)difftime(ut_time(), lock->requested_time); lock->wait_time = (ulint)difftime(now, lock->requested_time);
if (!owns_trx_mutex) { if (!owns_trx_mutex) {
trx_mutex_exit(lock->trx); trx_mutex_exit(lock->trx);
@ -4961,7 +4963,7 @@ lock_table_create(
lock->type_mode = type_mode | LOCK_TABLE; lock->type_mode = type_mode | LOCK_TABLE;
lock->trx = trx; lock->trx = trx;
lock->requested_time = ut_time(); lock->requested_time = time(NULL);
lock->wait_time = 0; lock->wait_time = 0;
lock->un_member.tab_lock.table = table; lock->un_member.tab_lock.table = table;

View File

@ -60,7 +60,7 @@ lock_wait_table_print(void)
(ulong) slot->in_use, (ulong) slot->in_use,
(ulong) slot->suspended, (ulong) slot->suspended,
slot->wait_timeout, slot->wait_timeout,
(ulong) difftime(ut_time(), slot->suspend_time)); (ulong) difftime(time(NULL), slot->suspend_time));
} }
} }
@ -157,7 +157,7 @@ lock_wait_table_reserve_slot(
os_event_reset(slot->event); os_event_reset(slot->event);
slot->suspended = TRUE; slot->suspended = TRUE;
slot->suspend_time = ut_time(); slot->suspend_time = time(NULL);
slot->wait_timeout = wait_timeout; slot->wait_timeout = wait_timeout;
if (slot == lock_sys->last_slot) { if (slot == lock_sys->last_slot) {

View File

@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc. Copyright (c) 2009, Google Inc.
Copyright (c) 2014, 2018, MariaDB Corporation. Copyright (c) 2014, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
@ -2340,7 +2340,7 @@ loop:
start_lsn += len; start_lsn += len;
buf += len; buf += len;
if (recv_sys->report(ut_time())) { if (recv_sys->report(time(NULL))) {
ib_logf(IB_LOG_LEVEL_INFO, "Read redo log up to LSN=" LSN_PF, ib_logf(IB_LOG_LEVEL_INFO, "Read redo log up to LSN=" LSN_PF,
start_lsn); start_lsn);
service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,

View File

@ -423,7 +423,7 @@ recv_sys_init(
recv_sys->last_block_buf_start, OS_FILE_LOG_BLOCK_SIZE)); recv_sys->last_block_buf_start, OS_FILE_LOG_BLOCK_SIZE));
recv_sys->found_corrupt_log = FALSE; recv_sys->found_corrupt_log = FALSE;
recv_sys->progress_time = ut_time(); recv_sys->progress_time = time(NULL);
recv_max_page_lsn = 0; recv_max_page_lsn = 0;
@ -1702,7 +1702,7 @@ recv_recover_page_func(
mtr_commit(&mtr); mtr_commit(&mtr);
ib_time_t time = ut_time(); time_t now = time(NULL);
mutex_enter(&recv_sys->mutex); mutex_enter(&recv_sys->mutex);
@ -1714,7 +1714,7 @@ recv_recover_page_func(
ut_a(recv_sys->n_addrs > 0); ut_a(recv_sys->n_addrs > 0);
if (ulint n = --recv_sys->n_addrs) { if (ulint n = --recv_sys->n_addrs) {
if (recv_sys->report(time)) { if (recv_sys->report(now)) {
ib_logf(IB_LOG_LEVEL_INFO, ib_logf(IB_LOG_LEVEL_INFO,
"To recover: " ULINTPF " pages from log", n); "To recover: " ULINTPF " pages from log", n);
service_manager_extend_timeout( service_manager_extend_timeout(

View File

@ -2,7 +2,7 @@
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2013, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are by Percona Inc.. Those modifications are
@ -4208,7 +4208,7 @@ os_aio_init(
os_aio_validate(); os_aio_validate();
os_last_printout = ut_time(); os_last_printout = time(NULL);
if (srv_use_native_aio) { if (srv_use_native_aio) {
return(TRUE); return(TRUE);
@ -4521,7 +4521,7 @@ found:
} }
slot->reserved = TRUE; slot->reserved = TRUE;
slot->reservation_time = ut_time(); slot->reservation_time = time(NULL);
slot->message1 = message1; slot->message1 = message1;
slot->message2 = message2; slot->message2 = message2;
slot->file = file; slot->file = file;
@ -5600,7 +5600,7 @@ restart:
if (slot->reserved) { if (slot->reserved) {
age = (ulint) difftime( age = (ulint) difftime(
ut_time(), slot->reservation_time); time(NULL), slot->reservation_time);
if ((age >= 2 && age > biggest_age) if ((age >= 2 && age > biggest_age)
|| (age >= 2 && age == biggest_age || (age >= 2 && age == biggest_age
@ -6014,7 +6014,7 @@ os_aio_print(
} }
putc('\n', file); putc('\n', file);
current_time = ut_time(); current_time = time(NULL);
time_elapsed = 0.001 + difftime(current_time, os_last_printout); time_elapsed = 0.001 + difftime(current_time, os_last_printout);
fprintf(file, fprintf(file,

View File

@ -1716,10 +1716,11 @@ DECLARE_THREAD(srv_monitor_thread)(void*)
pfs_register_thread(srv_monitor_thread_key); pfs_register_thread(srv_monitor_thread_key);
#endif /* UNIV_PFS_THREAD */ #endif /* UNIV_PFS_THREAD */
srv_last_monitor_time = ut_time(); current_time = time(NULL);
last_table_monitor_time = ut_time(); srv_last_monitor_time = current_time;
last_tablespace_monitor_time = ut_time(); last_table_monitor_time = current_time;
last_monitor_time = ut_time(); last_tablespace_monitor_time = current_time;
last_monitor_time = current_time;
mutex_skipped = 0; mutex_skipped = 0;
last_srv_print_monitor = srv_print_innodb_monitor; last_srv_print_monitor = srv_print_innodb_monitor;
loop: loop:
@ -1730,12 +1731,12 @@ loop:
os_event_wait_time_low(srv_monitor_event, 5000000, sig_count); os_event_wait_time_low(srv_monitor_event, 5000000, sig_count);
current_time = ut_time(); current_time = time(NULL);
time_elapsed = difftime(current_time, last_monitor_time); time_elapsed = difftime(current_time, last_monitor_time);
if (time_elapsed > 15) { if (time_elapsed > 15) {
last_monitor_time = ut_time(); last_monitor_time = current_time;
if (srv_print_innodb_monitor) { if (srv_print_innodb_monitor) {
/* Reset mutex_skipped counter everytime /* Reset mutex_skipped counter everytime
@ -1782,7 +1783,7 @@ loop:
if (srv_print_innodb_tablespace_monitor if (srv_print_innodb_tablespace_monitor
&& difftime(current_time, && difftime(current_time,
last_tablespace_monitor_time) > 60) { last_tablespace_monitor_time) > 60) {
last_tablespace_monitor_time = ut_time(); last_tablespace_monitor_time = current_time;
fputs("========================" fputs("========================"
"========================\n", "========================\n",
@ -1808,7 +1809,7 @@ loop:
if (srv_print_innodb_table_monitor if (srv_print_innodb_table_monitor
&& difftime(current_time, last_table_monitor_time) > 60) { && difftime(current_time, last_table_monitor_time) > 60) {
last_table_monitor_time = ut_time(); last_table_monitor_time = current_time;
fprintf(stderr, "Warning: %s\n", fprintf(stderr, "Warning: %s\n",
DEPRECATED_MSG_INNODB_TABLE_MONITOR); DEPRECATED_MSG_INNODB_TABLE_MONITOR);
@ -2183,20 +2184,16 @@ static
void void
srv_shutdown_print_master_pending( srv_shutdown_print_master_pending(
/*==============================*/ /*==============================*/
ib_time_t* last_print_time, /*!< last time the function time_t* last_print_time, /*!< last time the function
print the message */ print the message */
ulint n_tables_to_drop, /*!< number of tables to ulint n_tables_to_drop, /*!< number of tables to
be dropped */ be dropped */
ulint n_bytes_merged) /*!< number of change buffer ulint n_bytes_merged) /*!< number of change buffer
just merged */ just merged */
{ {
ib_time_t current_time; time_t current_time = time(NULL);
double time_elapsed;
current_time = ut_time(); if (difftime(current_time, *last_print_time) > 60) {
time_elapsed = ut_difftime(current_time, *last_print_time);
if (time_elapsed > 60) {
*last_print_time = current_time; *last_print_time = current_time;
if (n_tables_to_drop) { if (n_tables_to_drop) {
@ -2231,7 +2228,7 @@ void
srv_master_do_active_tasks(void) srv_master_do_active_tasks(void)
/*============================*/ /*============================*/
{ {
ib_time_t cur_time = ut_time(); time_t cur_time = time(NULL);
ulonglong counter_time = microsecond_interval_timer(); ulonglong counter_time = microsecond_interval_timer();
ulint n_evicted = 0; ulint n_evicted = 0;
@ -2390,7 +2387,7 @@ srv_shutdown(bool ibuf_merge)
{ {
ulint n_bytes_merged = 0; ulint n_bytes_merged = 0;
ulint n_tables_to_drop; ulint n_tables_to_drop;
ib_time_t now = ut_time(); time_t now = time(NULL);
do { do {
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
@ -2539,10 +2536,10 @@ srv_purge_should_exit(ulint n_purged)
/* Slow shutdown was requested. */ /* Slow shutdown was requested. */
if (n_purged) { if (n_purged) {
#if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY #if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY
static ib_time_t progress_time; static time_t progress_time;
ib_time_t time = ut_time(); time_t now = time(NULL);
if (time - progress_time >= 15) { if (now - progress_time >= 15) {
progress_time = time; progress_time = now;
service_manager_extend_timeout( service_manager_extend_timeout(
INNODB_EXTEND_TIMEOUT_INTERVAL, INNODB_EXTEND_TIMEOUT_INTERVAL,
"InnoDB: to purge " ULINTPF " transactions", "InnoDB: to purge " ULINTPF " transactions",

View File

@ -2,7 +2,7 @@
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc. Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved. Copyright (c) 2013, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
@ -405,7 +405,7 @@ sync_array_reserve_cell(
event = sync_cell_get_event(cell); event = sync_cell_get_event(cell);
cell->signal_count = os_event_reset(event); cell->signal_count = os_event_reset(event);
cell->reservation_time = ut_time(); cell->reservation_time = time(NULL);
cell->thread = os_thread_get_curr_id(); cell->thread = os_thread_get_curr_id();

View File

@ -738,11 +738,11 @@ trx_roll_must_shutdown()
return true; return true;
} }
ib_time_t time = ut_time(); time_t now = time(NULL);
mutex_enter(&trx_sys->mutex); mutex_enter(&trx_sys->mutex);
mutex_enter(&recv_sys->mutex); mutex_enter(&recv_sys->mutex);
if (recv_sys->report(time)) { if (recv_sys->report(now)) {
ulint n_trx = 0; ulint n_trx = 0;
ulonglong n_rows = 0; ulonglong n_rows = 0;
for (const trx_t* t = UT_LIST_GET_FIRST(trx_sys->rw_trx_list); for (const trx_t* t = UT_LIST_GET_FIRST(trx_sys->rw_trx_list);

View File

@ -907,7 +907,7 @@ trx_start_low(
mutex_exit(&trx_sys->mutex); mutex_exit(&trx_sys->mutex);
trx->start_time = ut_time(); trx->start_time = time(NULL);
trx->start_time_micro = trx->mysql_thd trx->start_time_micro = trx->mysql_thd
? thd_query_start_micro(trx->mysql_thd) ? thd_query_start_micro(trx->mysql_thd)

View File

@ -44,21 +44,6 @@ Created 5/11/1994 Heikki Tuuri
# include "ha_prototypes.h" # include "ha_prototypes.h"
# include "mysql_com.h" /* NAME_LEN */ # include "mysql_com.h" /* NAME_LEN */
# include <string> # include <string>
#endif /* UNIV_HOTBACKUP */
/**********************************************************//**
Returns system time. We do not specify the format of the time returned:
the only way to manipulate it is to use the function ut_difftime.
@return system time */
UNIV_INTERN
ib_time_t
ut_time(void)
/*=========*/
{
return(time(NULL));
}
#ifndef UNIV_HOTBACKUP
/**********************************************************//** /**********************************************************//**
Returns the number of milliseconds since some epoch. The Returns the number of milliseconds since some epoch. The
value may wrap around. It should only be used for heuristic value may wrap around. It should only be used for heuristic
@ -72,20 +57,6 @@ ut_time_ms(void)
return static_cast<ulint>(my_interval_timer() / 1000000); return static_cast<ulint>(my_interval_timer() / 1000000);
} }
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
/**********************************************************//**
Returns the difference of two times in seconds.
@return time2 - time1 expressed in seconds */
UNIV_INTERN
double
ut_difftime(
/*========*/
ib_time_t time2, /*!< in: time */
ib_time_t time1) /*!< in: time */
{
return(difftime(time2, time1));
}
#endif /* !UNIV_INNOCHECKSUM */ #endif /* !UNIV_INNOCHECKSUM */
/**********************************************************//** /**********************************************************//**

View File

@ -1700,7 +1700,7 @@ buf_pool_init_instance(
buf_pool->zip_hash = hash_create(2 * buf_pool->curr_size); buf_pool->zip_hash = hash_create(2 * buf_pool->curr_size);
buf_pool->last_printout_time = ut_time(); buf_pool->last_printout_time = time(NULL);
} }
/* 2. Initialize flushing fields /* 2. Initialize flushing fields
-------------------------------- */ -------------------------------- */
@ -6200,7 +6200,7 @@ buf_refresh_io_stats(
/*=================*/ /*=================*/
buf_pool_t* buf_pool) /*!< in: buffer pool instance */ buf_pool_t* buf_pool) /*!< in: buffer pool instance */
{ {
buf_pool->last_printout_time = ut_time(); buf_pool->last_printout_time = time(NULL);
buf_pool->old_stat = buf_pool->stat; buf_pool->old_stat = buf_pool->stat;
} }

View File

@ -751,7 +751,7 @@ void
dict_mem_init(void) dict_mem_init(void)
{ {
/* Initialize a randomly distributed temporary file number */ /* Initialize a randomly distributed temporary file number */
ib_uint32_t now = static_cast<ib_uint32_t>(ut_time()); ib_uint32_t now = static_cast<ib_uint32_t>(time(NULL));
const byte* buf = reinterpret_cast<const byte*>(&now); const byte* buf = reinterpret_cast<const byte*>(&now);
ut_ad(ut_crc32 != NULL); ut_ad(ut_crc32 != NULL);

View File

@ -45,7 +45,7 @@ Created Jan 06, 2010 Vasil Dimov
#include "trx0trx.h" /* trx_create() */ #include "trx0trx.h" /* trx_create() */
#include "trx0roll.h" /* trx_rollback_to_savepoint() */ #include "trx0roll.h" /* trx_rollback_to_savepoint() */
#include "ut0rnd.h" /* ut_rnd_interval() */ #include "ut0rnd.h" /* ut_rnd_interval() */
#include "ut0ut.h" /* ut_format_name(), ut_time() */ #include "ut0ut.h" /* ut_format_name() */
#include <algorithm> #include <algorithm>
#include <map> #include <map>
@ -1000,7 +1000,7 @@ dict_stats_update_transient(
table->stat_sum_of_other_index_sizes = sum_of_index_sizes table->stat_sum_of_other_index_sizes = sum_of_index_sizes
- index->stat_index_size; - index->stat_index_size;
table->stats_last_recalc = ut_time(); table->stats_last_recalc = time(NULL);
table->stat_modified_counter = 0; table->stat_modified_counter = 0;
@ -2325,7 +2325,7 @@ dict_stats_update_persistent(
+= index->stat_index_size; += index->stat_index_size;
} }
table->stats_last_recalc = ut_time(); table->stats_last_recalc = time(NULL);
table->stat_modified_counter = 0; table->stat_modified_counter = 0;
@ -2535,7 +2535,7 @@ dict_stats_save(
/* MySQL's timestamp is 4 byte, so we use /* MySQL's timestamp is 4 byte, so we use
pars_info_add_int4_literal() which takes a lint arg, so "now" is pars_info_add_int4_literal() which takes a lint arg, so "now" is
lint */ lint */
now = (lint) ut_time(); now = (lint) time(NULL);
pinfo = pars_info_create(); pinfo = pars_info_create();
@ -3980,7 +3980,7 @@ dict_stats_save_defrag_summary(
dict_index_t* index) /*!< in: index */ dict_index_t* index) /*!< in: index */
{ {
dberr_t ret; dberr_t ret;
lint now = (lint) ut_time(); lint now = (lint) time(NULL);
if (dict_index_is_univ(index)) { if (dict_index_is_univ(index)) {
return DB_SUCCESS; return DB_SUCCESS;
} }
@ -4017,7 +4017,7 @@ dict_stats_save_defrag_stats(
return DB_SUCCESS; return DB_SUCCESS;
} }
lint now = (lint) ut_time(); lint now = (lint) time(NULL);
mtr_t mtr; mtr_t mtr;
ulint n_leaf_pages; ulint n_leaf_pages;
ulint n_leaf_reserved; ulint n_leaf_reserved;

View File

@ -437,14 +437,14 @@ dict_stats_process_entry_from_recalc_pool()
mutex_exit(&dict_sys->mutex); mutex_exit(&dict_sys->mutex);
/* ut_time() could be expensive, the current function /* time() could be expensive, the current function
is called once every time a table has been changed more than 10% and is called once every time a table has been changed more than 10% and
on a system with lots of small tables, this could become hot. If we on a system with lots of small tables, this could become hot. If we
find out that this is a problem, then the check below could eventually find out that this is a problem, then the check below could eventually
be replaced with something else, though a time interval is the natural be replaced with something else, though a time interval is the natural
approach. */ approach. */
if (ut_difftime(ut_time(), table->stats_last_recalc) if (difftime(time(NULL), table->stats_last_recalc)
< MIN_RECALC_INTERVAL) { < MIN_RECALC_INTERVAL) {
/* Stats were (re)calculated not long ago. To avoid /* Stats were (re)calculated not long ago. To avoid

View File

@ -1,6 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@ -858,7 +859,7 @@ eval_predefined(
dfield_get_data(que_node_get_val(arg1))); dfield_get_data(que_node_get_val(arg1)));
} else if (func == PARS_SYSDATE_TOKEN) { } else if (func == PARS_SYSDATE_TOKEN) {
int_val = (lint) ut_time(); int_val = (lint) time(NULL);
} else { } else {
eval_predefined_2(func_node); eval_predefined_2(func_node);

View File

@ -5128,7 +5128,7 @@ fil_load_single_table_tablespaces(ibool (*pred)(const char*, const char*))
ulint dbpath_len = 100; ulint dbpath_len = 100;
ulint files_read = 0; ulint files_read = 0;
ulint files_read_at_last_check = 0; ulint files_read_at_last_check = 0;
ib_time_t prev_report_time = ut_time(); time_t prev_report_time = time(NULL);
os_file_dir_t dir; os_file_dir_t dir;
os_file_dir_t dbdir; os_file_dir_t dbdir;
os_file_stat_t dbinfo; os_file_stat_t dbinfo;
@ -5228,11 +5228,10 @@ fil_load_single_table_tablespaces(ibool (*pred)(const char*, const char*))
files_read++; files_read++;
if (files_read - files_read_at_last_check > if (files_read - files_read_at_last_check >
CHECK_TIME_EVERY_N_FILES) { CHECK_TIME_EVERY_N_FILES) {
ib_time_t cur_time= ut_time(); time_t cur_time= time(NULL);
files_read_at_last_check= files_read; files_read_at_last_check= files_read;
double time_elapsed= ut_difftime(cur_time, if (cur_time - prev_report_time
prev_report_time); > 15) {
if (time_elapsed > 15) {
ib_logf(IB_LOG_LEVEL_INFO, ib_logf(IB_LOG_LEVEL_INFO,
"Processed %ld .ibd/.isl files", "Processed %ld .ibd/.isl files",
files_read); files_read);

View File

@ -77,8 +77,8 @@ UNIV_INTERN ulong fts_min_token_size;
// FIXME: testing // FIXME: testing
ib_time_t elapsed_time = 0; static time_t elapsed_time;
ulint n_nodes = 0; static ulint n_nodes;
/** Error condition reported by fts_utf8_decode() */ /** Error condition reported by fts_utf8_decode() */
const ulint UTF8_ERROR = 0xFFFFFFFF; const ulint UTF8_ERROR = 0xFFFFFFFF;
@ -3798,7 +3798,7 @@ fts_write_node(
pars_info_t* info; pars_info_t* info;
dberr_t error; dberr_t error;
ib_uint32_t doc_count; ib_uint32_t doc_count;
ib_time_t start_time; time_t start_time;
doc_id_t last_doc_id; doc_id_t last_doc_id;
doc_id_t first_doc_id; doc_id_t first_doc_id;
char table_name[MAX_FULL_NAME_LEN]; char table_name[MAX_FULL_NAME_LEN];
@ -3845,9 +3845,9 @@ fts_write_node(
" :last_doc_id, :doc_count, :ilist);"); " :last_doc_id, :doc_count, :ilist);");
} }
start_time = ut_time(); start_time = time(NULL);
error = fts_eval_sql(trx, *graph); error = fts_eval_sql(trx, *graph);
elapsed_time += ut_time() - start_time; elapsed_time += time(NULL) - start_time;
++n_nodes; ++n_nodes;
return(error); return(error);
@ -4298,7 +4298,7 @@ fts_sync_begin(
n_nodes = 0; n_nodes = 0;
elapsed_time = 0; elapsed_time = 0;
sync->start_time = ut_time(); sync->start_time = time(NULL);
sync->trx = trx_allocate_for_background(); sync->trx = trx_allocate_for_background();
@ -4457,7 +4457,7 @@ fts_sync_commit(
"SYNC for table %s: SYNC time : %lu secs: " "SYNC for table %s: SYNC time : %lu secs: "
"elapsed %lf ins/sec", "elapsed %lf ins/sec",
sync->table->name, sync->table->name,
(ulong) (ut_time() - sync->start_time), (ulong) (time(NULL) - sync->start_time),
(double) n_nodes/ (double) elapsed_time); (double) n_nodes/ (double) elapsed_time);
} }

View File

@ -1648,7 +1648,7 @@ fts_optimize_get_index_start_time(
/*==============================*/ /*==============================*/
trx_t* trx, /*!< in: transaction */ trx_t* trx, /*!< in: transaction */
dict_index_t* index, /*!< in: FTS index */ dict_index_t* index, /*!< in: FTS index */
ib_time_t* start_time) /*!< out: time in secs */ time_t* start_time) /*!< out: time in secs */
{ {
return(fts_config_get_index_ulint( return(fts_config_get_index_ulint(
trx, index, FTS_OPTIMIZE_START_TIME, trx, index, FTS_OPTIMIZE_START_TIME,
@ -1664,7 +1664,7 @@ fts_optimize_set_index_start_time(
/*==============================*/ /*==============================*/
trx_t* trx, /*!< in: transaction */ trx_t* trx, /*!< in: transaction */
dict_index_t* index, /*!< in: FTS index */ dict_index_t* index, /*!< in: FTS index */
ib_time_t start_time) /*!< in: start time */ time_t start_time) /*!< in: start time */
{ {
return(fts_config_set_index_ulint( return(fts_config_set_index_ulint(
trx, index, FTS_OPTIMIZE_START_TIME, trx, index, FTS_OPTIMIZE_START_TIME,
@ -1918,7 +1918,7 @@ fts_optimize_index_completed(
dberr_t error; dberr_t error;
byte buf[sizeof(ulint)]; byte buf[sizeof(ulint)];
#ifdef FTS_OPTIMIZE_DEBUG #ifdef FTS_OPTIMIZE_DEBUG
ib_time_t end_time = ut_time(); time_t end_time = time(NULL);
error = fts_optimize_set_index_end_time(optim->trx, index, end_time); error = fts_optimize_set_index_end_time(optim->trx, index, end_time);
#endif #endif
@ -2337,14 +2337,14 @@ fts_optimize_indexes(
/* Start time will be 0 only for the first time or after /* Start time will be 0 only for the first time or after
completing the optimization of all FTS indexes. */ completing the optimization of all FTS indexes. */
if (start_time == 0) { if (start_time == 0) {
start_time = ut_time(); start_time = time(NULL);
error = fts_optimize_set_index_start_time( error = fts_optimize_set_index_start_time(
optim->trx, index, start_time); optim->trx, index, start_time);
} }
/* Check if this index needs to be optimized or not. */ /* Check if this index needs to be optimized or not. */
if (ut_difftime(end_time, start_time) < 0) { if (difftime(end_time, start_time) < 0) {
error = fts_optimize_index(optim, index); error = fts_optimize_index(optim, index);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
@ -2416,7 +2416,7 @@ fts_optimize_reset_start_time(
for (uint i = 0; i < ib_vector_size(fts->indexes); ++i) { for (uint i = 0; i < ib_vector_size(fts->indexes); ++i) {
dict_index_t* index; dict_index_t* index;
ib_time_t start_time = 0; time_t start_time = 0;
/* Reset the start time to 0 for this index. */ /* Reset the start time to 0 for this index. */
error = fts_optimize_set_index_start_time( error = fts_optimize_set_index_start_time(
@ -2471,7 +2471,7 @@ fts_optimize_table_bk(
&& table->fts->cache->deleted >= FTS_OPTIMIZE_THRESHOLD) { && table->fts->cache->deleted >= FTS_OPTIMIZE_THRESHOLD) {
error = fts_optimize_table(table); error = fts_optimize_table(table);
slot->last_run = ut_time(); slot->last_run = time(NULL);
if (error == DB_SUCCESS) { if (error == DB_SUCCESS) {
slot->running = false; slot->running = false;
@ -3001,7 +3001,7 @@ fts_optimize_init(void)
fts_optimize_wq = ib_wqueue_create(); fts_optimize_wq = ib_wqueue_create();
ut_a(fts_optimize_wq != NULL); ut_a(fts_optimize_wq != NULL);
last_check_sync_time = ut_time(); last_check_sync_time = time(NULL);
os_thread_create(fts_optimize_thread, fts_optimize_wq, NULL); os_thread_create(fts_optimize_thread, fts_optimize_wq, NULL);
} }

View File

@ -2,7 +2,7 @@
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@ -1198,7 +1198,7 @@ struct dict_table_t{
goes to zero. If it's -1, means there's DDL goes to zero. If it's -1, means there's DDL
on the table, DML from memcached will be on the table, DML from memcached will be
blocked. */ blocked. */
ib_time_t stats_last_recalc; time_t stats_last_recalc;
/*!< Timestamp of last recalc of the stats */ /*!< Timestamp of last recalc of the stats */
ib_uint32_t stat_persistent; ib_uint32_t stat_persistent;
/*!< The two bits below are set in the /*!< The two bits below are set in the

View File

@ -431,7 +431,7 @@ struct recv_sys_t{
log record, or there is a log parsing log record, or there is a log parsing
buffer overflow */ buffer overflow */
/** the time when progress was last reported */ /** the time when progress was last reported */
ib_time_t progress_time; time_t progress_time;
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
log_group_t* archive_group; log_group_t* archive_group;
/*!< in archive recovery: the log group whose /*!< in archive recovery: the log group whose
@ -449,7 +449,7 @@ struct recv_sys_t{
@param[in] time the current time @param[in] time the current time
@return whether progress should be reported @return whether progress should be reported
(the last report was at least 15 seconds ago) */ (the last report was at least 15 seconds ago) */
bool report(ib_time_t time) bool report(time_t time)
{ {
if (time - progress_time < 15) { if (time - progress_time < 15) {
return false; return false;

View File

@ -58,9 +58,9 @@ create the internal counter ID in "monitor_id_t". */
/** Structure containing the actual values of a monitor counter. */ /** Structure containing the actual values of a monitor counter. */
struct monitor_value_t { struct monitor_value_t {
ib_time_t mon_start_time; /*!< Start time of monitoring */ time_t mon_start_time; /*!< Start time of monitoring */
ib_time_t mon_stop_time; /*!< Stop time of monitoring */ time_t mon_stop_time; /*!< Stop time of monitoring */
ib_time_t mon_reset_time; /*!< Time counter resetted */ time_t mon_reset_time; /*!< Time of resetting the counter */
mon_type_t mon_value; /*!< Current counter Value */ mon_type_t mon_value; /*!< Current counter Value */
mon_type_t mon_max_value; /*!< Current Max value */ mon_type_t mon_max_value; /*!< Current Max value */
mon_type_t mon_min_value; /*!< Current Min value */ mon_type_t mon_min_value; /*!< Current Min value */

View File

@ -129,7 +129,7 @@ struct i_s_trx_row_t {
trx_id_t trx_id; /*!< transaction identifier */ trx_id_t trx_id; /*!< transaction identifier */
const char* trx_state; /*!< transaction state from const char* trx_state; /*!< transaction state from
trx_get_que_state_str() */ trx_get_que_state_str() */
ib_time_t trx_started; /*!< trx_t::start_time */ time_t trx_started; /*!< trx_t::start_time */
const i_s_locks_row_t* requested_lock_row; const i_s_locks_row_t* requested_lock_row;
/*!< pointer to a row /*!< pointer to a row
in innodb_locks if trx in innodb_locks if trx

View File

@ -51,9 +51,6 @@ Created 1/20/1994 Heikki Tuuri
/** Index name prefix in fast index creation, as a string constant */ /** Index name prefix in fast index creation, as a string constant */
#define TEMP_INDEX_PREFIX_STR "\377" #define TEMP_INDEX_PREFIX_STR "\377"
/** Time stamp */
typedef time_t ib_time_t;
/* In order to call a piece of code, when a function returns or when the /* In order to call a piece of code, when a function returns or when the
scope ends, use this utility class. It will invoke the given function scope ends, use this utility class. It will invoke the given function
object in its destructor. */ object in its destructor. */
@ -227,14 +224,6 @@ store the given number of bits.
@return number of bytes (octets) needed to represent b */ @return number of bytes (octets) needed to represent b */
#define UT_BITS_IN_BYTES(b) (((b) + 7) / 8) #define UT_BITS_IN_BYTES(b) (((b) + 7) / 8)
/**********************************************************//**
Returns system time. We do not specify the format of the time returned:
the only way to manipulate it is to use the function ut_difftime.
@return system time */
UNIV_INTERN
ib_time_t
ut_time(void);
/*=========*/
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
/**********************************************************//** /**********************************************************//**
Returns the number of milliseconds since some epoch. The Returns the number of milliseconds since some epoch. The
@ -256,17 +245,6 @@ UNIV_INTERN
ulint ulint
ut_time_ms(void); ut_time_ms(void);
/*============*/ /*============*/
/**********************************************************//**
Returns the difference of two times in seconds.
@return time2 - time1 expressed in seconds */
UNIV_INTERN
double
ut_difftime(
/*========*/
ib_time_t time2, /*!< in: time */
ib_time_t time1); /*!< in: time */
#endif /* !UNIV_INNOCHECKSUM */ #endif /* !UNIV_INNOCHECKSUM */
/**********************************************************//** /**********************************************************//**

View File

@ -2310,7 +2310,7 @@ lock_rec_create(
/* Set the bit corresponding to rec */ /* Set the bit corresponding to rec */
lock_rec_set_nth_bit(lock, heap_no); lock_rec_set_nth_bit(lock, heap_no);
lock->requested_time = ut_time(); lock->requested_time = time(NULL);
lock->wait_time = 0; lock->wait_time = 0;
index->table->n_rec_locks++; index->table->n_rec_locks++;
@ -3085,16 +3085,18 @@ lock_grant(
} }
} }
const time_t now = time(NULL);
/* Cumulate total lock wait time for statistics */ /* Cumulate total lock wait time for statistics */
if (lock_get_type_low(lock) & LOCK_TABLE) { if (lock_get_type_low(lock) & LOCK_TABLE) {
lock->trx->total_table_lock_wait_time += lock->trx->total_table_lock_wait_time +=
(ulint)difftime(ut_time(), lock->trx->lock.wait_started); (ulint)difftime(now, lock->trx->lock.wait_started);
} else { } else {
lock->trx->total_rec_lock_wait_time += lock->trx->total_rec_lock_wait_time +=
(ulint)difftime(ut_time(), lock->trx->lock.wait_started); (ulint)difftime(now, lock->trx->lock.wait_started);
} }
lock->wait_time = (ulint)difftime(ut_time(), lock->requested_time); lock->wait_time = (ulint)difftime(now, lock->requested_time);
if (!owns_trx_mutex) { if (!owns_trx_mutex) {
trx_mutex_exit(lock->trx); trx_mutex_exit(lock->trx);
@ -4997,7 +4999,7 @@ lock_table_create(
lock->type_mode = type_mode | LOCK_TABLE; lock->type_mode = type_mode | LOCK_TABLE;
lock->trx = trx; lock->trx = trx;
lock->requested_time = ut_time(); lock->requested_time = time(NULL);
lock->wait_time = 0; lock->wait_time = 0;
lock->un_member.tab_lock.table = table; lock->un_member.tab_lock.table = table;

View File

@ -74,7 +74,7 @@ lock_wait_table_print(void)
(ulong) slot->in_use, (ulong) slot->in_use,
(ulong) slot->suspended, (ulong) slot->suspended,
slot->wait_timeout, slot->wait_timeout,
(ulong) difftime(ut_time(), slot->suspend_time)); (ulong) difftime(time(NULL), slot->suspend_time));
} }
} }
@ -171,7 +171,7 @@ lock_wait_table_reserve_slot(
os_event_reset(slot->event); os_event_reset(slot->event);
slot->suspended = TRUE; slot->suspended = TRUE;
slot->suspend_time = ut_time(); slot->suspend_time = time(NULL);
slot->wait_timeout = wait_timeout; slot->wait_timeout = wait_timeout;
if (slot == lock_sys->last_slot) { if (slot == lock_sys->last_slot) {

View File

@ -2,7 +2,7 @@
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc. Copyright (c) 2009, Google Inc.
Copyright (c) 2014, 2018, MariaDB Corporation. Copyright (c) 2014, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
@ -2591,7 +2591,8 @@ loop:
start_lsn += len; start_lsn += len;
buf += len; buf += len;
if (recv_recovery_is_on() && recv_sys && recv_sys->report(ut_time())) { if (recv_recovery_is_on() && recv_sys
&& recv_sys->report(time(NULL))) {
ib_logf(IB_LOG_LEVEL_INFO, "Read redo log up to LSN=" LSN_PF, ib_logf(IB_LOG_LEVEL_INFO, "Read redo log up to LSN=" LSN_PF,
start_lsn); start_lsn);
service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,

View File

@ -419,7 +419,7 @@ recv_sys_init(
recv_sys->last_block_buf_start, OS_FILE_LOG_BLOCK_SIZE)); recv_sys->last_block_buf_start, OS_FILE_LOG_BLOCK_SIZE));
recv_sys->found_corrupt_log = FALSE; recv_sys->found_corrupt_log = FALSE;
recv_sys->progress_time = ut_time(); recv_sys->progress_time = time(NULL);
recv_max_page_lsn = 0; recv_max_page_lsn = 0;
@ -1789,7 +1789,7 @@ recv_recover_page_func(
mtr_commit(&mtr); mtr_commit(&mtr);
ib_time_t time = ut_time(); time_t now = time(NULL);
mutex_enter(&(recv_sys->mutex)); mutex_enter(&(recv_sys->mutex));
@ -1801,7 +1801,7 @@ recv_recover_page_func(
ut_a(recv_sys->n_addrs > 0); ut_a(recv_sys->n_addrs > 0);
if (ulint n = --recv_sys->n_addrs) { if (ulint n = --recv_sys->n_addrs) {
if (recv_sys->report(time)) { if (recv_sys->report(now)) {
ib_logf(IB_LOG_LEVEL_INFO, ib_logf(IB_LOG_LEVEL_INFO,
"To recover: " ULINTPF " pages from log", n); "To recover: " ULINTPF " pages from log", n);
service_manager_extend_timeout( service_manager_extend_timeout(

View File

@ -2,7 +2,7 @@
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2013, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are by Percona Inc.. Those modifications are
@ -4509,7 +4509,7 @@ os_aio_init(
os_aio_validate(); os_aio_validate();
os_last_printout = ut_time(); os_last_printout = time(NULL);
#ifdef _WIN32 #ifdef _WIN32
ut_a(completion_port == 0 && read_completion_port == 0); ut_a(completion_port == 0 && read_completion_port == 0);
@ -4837,7 +4837,7 @@ found:
} }
slot->reserved = TRUE; slot->reserved = TRUE;
slot->reservation_time = ut_time(); slot->reservation_time = time(NULL);
slot->message1 = message1; slot->message1 = message1;
slot->message2 = message2; slot->message2 = message2;
slot->file = file; slot->file = file;
@ -5979,7 +5979,7 @@ restart:
if (slot->reserved) { if (slot->reserved) {
age = (ulint) difftime( age = (ulint) difftime(
ut_time(), slot->reservation_time); time(NULL), slot->reservation_time);
if ((age >= 2 && age > biggest_age) if ((age >= 2 && age > biggest_age)
|| (age >= 2 && age == biggest_age || (age >= 2 && age == biggest_age
@ -6392,7 +6392,7 @@ os_aio_print(
} }
putc('\n', file); putc('\n', file);
current_time = ut_time(); current_time = time(NULL);
time_elapsed = 0.001 + difftime(current_time, os_last_printout); time_elapsed = 0.001 + difftime(current_time, os_last_printout);
fprintf(file, fprintf(file,

View File

@ -2168,10 +2168,11 @@ DECLARE_THREAD(srv_monitor_thread)(void*)
pfs_register_thread(srv_monitor_thread_key); pfs_register_thread(srv_monitor_thread_key);
#endif /* UNIV_PFS_THREAD */ #endif /* UNIV_PFS_THREAD */
srv_last_monitor_time = ut_time(); current_time = time(NULL);
last_table_monitor_time = ut_time(); srv_last_monitor_time = current_time;
last_tablespace_monitor_time = ut_time(); last_table_monitor_time = current_time;
last_monitor_time = ut_time(); last_tablespace_monitor_time = current_time;
last_monitor_time = current_time;
mutex_skipped = 0; mutex_skipped = 0;
last_srv_print_monitor = srv_print_innodb_monitor; last_srv_print_monitor = srv_print_innodb_monitor;
loop: loop:
@ -2182,12 +2183,12 @@ loop:
os_event_wait_time_low(srv_monitor_event, 5000000, sig_count); os_event_wait_time_low(srv_monitor_event, 5000000, sig_count);
current_time = ut_time(); current_time = time(NULL);
time_elapsed = difftime(current_time, last_monitor_time); time_elapsed = difftime(current_time, last_monitor_time);
if (time_elapsed > 15) { if (time_elapsed > 15) {
last_monitor_time = ut_time(); last_monitor_time = current_time;
if (srv_print_innodb_monitor) { if (srv_print_innodb_monitor) {
/* Reset mutex_skipped counter everytime /* Reset mutex_skipped counter everytime
@ -2234,7 +2235,7 @@ loop:
if (srv_print_innodb_tablespace_monitor if (srv_print_innodb_tablespace_monitor
&& difftime(current_time, && difftime(current_time,
last_tablespace_monitor_time) > 60) { last_tablespace_monitor_time) > 60) {
last_tablespace_monitor_time = ut_time(); last_tablespace_monitor_time = current_time;
fputs("========================" fputs("========================"
"========================\n", "========================\n",
@ -2260,7 +2261,7 @@ loop:
if (srv_print_innodb_table_monitor if (srv_print_innodb_table_monitor
&& difftime(current_time, last_table_monitor_time) > 60) { && difftime(current_time, last_table_monitor_time) > 60) {
last_table_monitor_time = ut_time(); last_table_monitor_time = current_time;
fprintf(stderr, "Warning: %s\n", fprintf(stderr, "Warning: %s\n",
DEPRECATED_MSG_INNODB_TABLE_MONITOR); DEPRECATED_MSG_INNODB_TABLE_MONITOR);
@ -2854,20 +2855,16 @@ static
void void
srv_shutdown_print_master_pending( srv_shutdown_print_master_pending(
/*==============================*/ /*==============================*/
ib_time_t* last_print_time, /*!< last time the function time_t* last_print_time, /*!< last time the function
print the message */ print the message */
ulint n_tables_to_drop, /*!< number of tables to ulint n_tables_to_drop, /*!< number of tables to
be dropped */ be dropped */
ulint n_bytes_merged) /*!< number of change buffer ulint n_bytes_merged) /*!< number of change buffer
just merged */ just merged */
{ {
ib_time_t current_time; time_t current_time = time(NULL);
double time_elapsed;
current_time = ut_time(); if (difftime(current_time, *last_print_time) > 60) {
time_elapsed = ut_difftime(current_time, *last_print_time);
if (time_elapsed > 60) {
*last_print_time = current_time; *last_print_time = current_time;
if (n_tables_to_drop) { if (n_tables_to_drop) {
@ -2902,7 +2899,7 @@ void
srv_master_do_active_tasks(void) srv_master_do_active_tasks(void)
/*============================*/ /*============================*/
{ {
ib_time_t cur_time = ut_time(); time_t cur_time = time(NULL);
ulonglong counter_time = microsecond_interval_timer(); ulonglong counter_time = microsecond_interval_timer();
ulint n_evicted = 0; ulint n_evicted = 0;
@ -3058,7 +3055,7 @@ srv_master_do_idle_tasks(void)
if (srv_log_arch_expire_sec) { if (srv_log_arch_expire_sec) {
srv_main_thread_op_info = "purging archived logs"; srv_main_thread_op_info = "purging archived logs";
purge_archived_logs(ut_time() - srv_log_arch_expire_sec, purge_archived_logs(time(NULL) - srv_log_arch_expire_sec,
0); 0);
} }
} }
@ -3071,7 +3068,7 @@ srv_shutdown(bool ibuf_merge)
{ {
ulint n_bytes_merged = 0; ulint n_bytes_merged = 0;
ulint n_tables_to_drop; ulint n_tables_to_drop;
ib_time_t now = ut_time(); time_t now = time(NULL);
do { do {
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
@ -3232,10 +3229,10 @@ srv_purge_should_exit(ulint n_purged)
/* Slow shutdown was requested. */ /* Slow shutdown was requested. */
if (n_purged) { if (n_purged) {
#if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY #if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY
static ib_time_t progress_time; static time_t progress_time;
ib_time_t time = ut_time(); time_t now = time(NULL);
if (time - progress_time >= 15) { if (now - progress_time >= 15) {
progress_time = time; progress_time = now;
service_manager_extend_timeout( service_manager_extend_timeout(
INNODB_EXTEND_TIMEOUT_INTERVAL, INNODB_EXTEND_TIMEOUT_INTERVAL,
"InnoDB: to purge " ULINTPF " transactions", "InnoDB: to purge " ULINTPF " transactions",

View File

@ -2,7 +2,7 @@
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc. Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved. Copyright (c) 2013, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
@ -414,7 +414,7 @@ sync_array_reserve_cell(
event = sync_cell_get_event(cell); event = sync_cell_get_event(cell);
cell->signal_count = os_event_reset(event); cell->signal_count = os_event_reset(event);
cell->reservation_time = ut_time(); cell->reservation_time = time(NULL);
cell->thread = os_thread_get_curr_id(); cell->thread = os_thread_get_curr_id();

View File

@ -750,11 +750,11 @@ trx_roll_must_shutdown()
return true; return true;
} }
ib_time_t time = ut_time(); time_t now = time(NULL);
mutex_enter(&trx_sys->mutex); mutex_enter(&trx_sys->mutex);
mutex_enter(&recv_sys->mutex); mutex_enter(&recv_sys->mutex);
if (recv_sys->report(time)) { if (recv_sys->report(now)) {
ulint n_trx = 0; ulint n_trx = 0;
ulonglong n_rows = 0; ulonglong n_rows = 0;
for (const trx_t* t = UT_LIST_GET_FIRST(trx_sys->rw_trx_list); for (const trx_t* t = UT_LIST_GET_FIRST(trx_sys->rw_trx_list);

View File

@ -1106,7 +1106,7 @@ trx_start_low(
mutex_exit(&trx_sys->mutex); mutex_exit(&trx_sys->mutex);
trx->start_time = ut_time(); trx->start_time = time(NULL);
trx->start_time_micro = trx->mysql_thd trx->start_time_micro = trx->mysql_thd
? thd_query_start_micro(trx->mysql_thd) ? thd_query_start_micro(trx->mysql_thd)

View File

@ -45,21 +45,6 @@ Created 5/11/1994 Heikki Tuuri
# include "ha_prototypes.h" # include "ha_prototypes.h"
# include "mysql_com.h" /* NAME_LEN */ # include "mysql_com.h" /* NAME_LEN */
# include <string> # include <string>
#endif /* UNIV_HOTBACKUP */
/**********************************************************//**
Returns system time. We do not specify the format of the time returned:
the only way to manipulate it is to use the function ut_difftime.
@return system time */
UNIV_INTERN
ib_time_t
ut_time(void)
/*=========*/
{
return(time(NULL));
}
#ifndef UNIV_HOTBACKUP
/**********************************************************//** /**********************************************************//**
Returns the number of milliseconds since some epoch. The Returns the number of milliseconds since some epoch. The
value may wrap around. It should only be used for heuristic value may wrap around. It should only be used for heuristic
@ -73,20 +58,6 @@ ut_time_ms(void)
return static_cast<ulint>(my_interval_timer() / 1000000); return static_cast<ulint>(my_interval_timer() / 1000000);
} }
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
/**********************************************************//**
Returns the difference of two times in seconds.
@return time2 - time1 expressed in seconds */
UNIV_INTERN
double
ut_difftime(
/*========*/
ib_time_t time2, /*!< in: time */
ib_time_t time1) /*!< in: time */
{
return(difftime(time2, time1));
}
#endif /* !UNIV_INNOCHECKSUM */ #endif /* !UNIV_INNOCHECKSUM */
/**********************************************************//** /**********************************************************//**