Commit 7c5df808 authored by sunny's avatar sunny

Fix for Bug# 23666. On Windows ut_usectime returns secs

and usecs relative to the UNIX epoch (which is Jan, 1 1970).
parent 053fec7e
...@@ -1818,15 +1818,15 @@ srv_export_innodb_status(void) ...@@ -1818,15 +1818,15 @@ srv_export_innodb_status(void)
export_vars.innodb_row_lock_waits = srv_n_lock_wait_count; export_vars.innodb_row_lock_waits = srv_n_lock_wait_count;
export_vars.innodb_row_lock_current_waits export_vars.innodb_row_lock_current_waits
= srv_n_lock_wait_current_count; = srv_n_lock_wait_current_count;
export_vars.innodb_row_lock_time = srv_n_lock_wait_time / 10000; export_vars.innodb_row_lock_time = srv_n_lock_wait_time / 1000;
if (srv_n_lock_wait_count > 0) { if (srv_n_lock_wait_count > 0) {
export_vars.innodb_row_lock_time_avg = (ulint) export_vars.innodb_row_lock_time_avg = (ulint)
(srv_n_lock_wait_time / 10000 / srv_n_lock_wait_count); (srv_n_lock_wait_time / 1000 / srv_n_lock_wait_count);
} else { } else {
export_vars.innodb_row_lock_time_avg = 0; export_vars.innodb_row_lock_time_avg = 0;
} }
export_vars.innodb_row_lock_time_max export_vars.innodb_row_lock_time_max
= srv_n_lock_max_wait_time / 10000; = srv_n_lock_max_wait_time / 1000;
export_vars.innodb_rows_read = srv_n_rows_read; export_vars.innodb_rows_read = srv_n_rows_read;
export_vars.innodb_rows_inserted = srv_n_rows_inserted; export_vars.innodb_rows_inserted = srv_n_rows_inserted;
export_vars.innodb_rows_updated = srv_n_rows_updated; export_vars.innodb_rows_updated = srv_n_rows_updated;
......
...@@ -20,6 +20,55 @@ Created 5/11/1994 Heikki Tuuri ...@@ -20,6 +20,55 @@ Created 5/11/1994 Heikki Tuuri
ibool ut_always_false = FALSE; ibool ut_always_false = FALSE;
#ifdef __WIN__
/*********************************************************************
NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix
epoch starts from 1970/1/1. For selection of constant see:
http://support.microsoft.com/kb/167296/ */
#define WIN_TO_UNIX_DELTA_USEC ((ib_longlong) 11644473600000000ULL)
/*********************************************************************
This is the Windows version of gettimeofday(2).*/
static
int
ut_gettimeofday(
/*============*/
/* out: 0 if all OK else -1 */
struct timeval* tv, /* out: Values are relative to Unix epoch */
void* tz) /* in: not used */
{
FILETIME ft;
ib_longlong tm;
if (!tv) {
errno = EINVAL;
return(-1);
}
GetSystemTimeAsFileTime(&ft);
tm = (ib_longlong) ft.dwHighDateTime << 32;
tm |= ft.dwLowDateTime;
ut_a(tm >= 0); /* If tm wraps over to negative, the quotient / 10
does not work */
tm /= 10; /* Convert from 100 nsec periods to usec */
/* If we don't convert to the Unix epoch the value for
struct timeval::tv_sec will overflow.*/
tm -= WIN_TO_UNIX_DELTA_USEC;
tv->tv_sec = (long) (tm / 1000000L);
tv->tv_usec = (long) (tm % 1000000L);
return(0);
}
#else
#define ut_gettimeofday gettimeofday
#endif
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
/********************************************************************* /*********************************************************************
Display an SQL identifier. Display an SQL identifier.
...@@ -85,17 +134,11 @@ ut_usectime( ...@@ -85,17 +134,11 @@ ut_usectime(
ulint* sec, /* out: seconds since the Epoch */ ulint* sec, /* out: seconds since the Epoch */
ulint* ms) /* out: microseconds since the Epoch+*sec */ ulint* ms) /* out: microseconds since the Epoch+*sec */
{ {
#ifdef __WIN__
SYSTEMTIME st;
GetLocalTime(&st);
*sec = (ulint) st.wSecond;
*ms = (ulint) st.wMilliseconds;
#else
struct timeval tv; struct timeval tv;
gettimeofday(&tv,NULL);
ut_gettimeofday(&tv, NULL);
*sec = (ulint) tv.tv_sec; *sec = (ulint) tv.tv_sec;
*ms = (ulint) tv.tv_usec; *ms = (ulint) tv.tv_usec;
#endif
} }
/************************************************************** /**************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment