Commit 645b3922 authored by marko's avatar marko

branches/zip: Merge revisions 1206:1271 from trunk.

parent b09ce29a
...@@ -2553,10 +2553,10 @@ innobase_mysql_cmp( ...@@ -2553,10 +2553,10 @@ innobase_mysql_cmp(
case MYSQL_TYPE_BIT: case MYSQL_TYPE_BIT:
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VAR_STRING:
case FIELD_TYPE_TINY_BLOB: case MYSQL_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_BLOB: case MYSQL_TYPE_BLOB:
case FIELD_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_VARCHAR:
/* Use the charset number to pick the right charset struct for /* Use the charset number to pick the right charset struct for
the comparison. Since the MySQL function get_charset may be the comparison. Since the MySQL function get_charset may be
...@@ -2620,11 +2620,11 @@ get_innobase_type_from_mysql_type( ...@@ -2620,11 +2620,11 @@ get_innobase_type_from_mysql_type(
8 bits: this is used in ibuf and also when DATA_NOT_NULL is ORed to 8 bits: this is used in ibuf and also when DATA_NOT_NULL is ORed to
the type */ the type */
DBUG_ASSERT((ulint)FIELD_TYPE_STRING < 256); DBUG_ASSERT((ulint)MYSQL_TYPE_STRING < 256);
DBUG_ASSERT((ulint)FIELD_TYPE_VAR_STRING < 256); DBUG_ASSERT((ulint)MYSQL_TYPE_VAR_STRING < 256);
DBUG_ASSERT((ulint)FIELD_TYPE_DOUBLE < 256); DBUG_ASSERT((ulint)MYSQL_TYPE_DOUBLE < 256);
DBUG_ASSERT((ulint)FIELD_TYPE_FLOAT < 256); DBUG_ASSERT((ulint)MYSQL_TYPE_FLOAT < 256);
DBUG_ASSERT((ulint)FIELD_TYPE_DECIMAL < 256); DBUG_ASSERT((ulint)MYSQL_TYPE_DECIMAL < 256);
if (field->flags & UNSIGNED_FLAG) { if (field->flags & UNSIGNED_FLAG) {
...@@ -2633,8 +2633,8 @@ get_innobase_type_from_mysql_type( ...@@ -2633,8 +2633,8 @@ get_innobase_type_from_mysql_type(
*unsigned_flag = 0; *unsigned_flag = 0;
} }
if (field->real_type() == FIELD_TYPE_ENUM if (field->real_type() == MYSQL_TYPE_ENUM
|| field->real_type() == FIELD_TYPE_SET) { || field->real_type() == MYSQL_TYPE_SET) {
/* MySQL has field->type() a string type for these, but the /* MySQL has field->type() a string type for these, but the
data is actually internally stored as an unsigned integer data is actually internally stored as an unsigned integer
...@@ -2672,31 +2672,31 @@ get_innobase_type_from_mysql_type( ...@@ -2672,31 +2672,31 @@ get_innobase_type_from_mysql_type(
} else { } else {
return(DATA_MYSQL); return(DATA_MYSQL);
} }
case FIELD_TYPE_NEWDECIMAL: case MYSQL_TYPE_NEWDECIMAL:
return(DATA_FIXBINARY); return(DATA_FIXBINARY);
case FIELD_TYPE_LONG: case MYSQL_TYPE_LONG:
case FIELD_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
case FIELD_TYPE_TINY: case MYSQL_TYPE_TINY:
case FIELD_TYPE_SHORT: case MYSQL_TYPE_SHORT:
case FIELD_TYPE_INT24: case MYSQL_TYPE_INT24:
case FIELD_TYPE_DATE: case MYSQL_TYPE_DATE:
case FIELD_TYPE_DATETIME: case MYSQL_TYPE_DATETIME:
case FIELD_TYPE_YEAR: case MYSQL_TYPE_YEAR:
case FIELD_TYPE_NEWDATE: case MYSQL_TYPE_NEWDATE:
case FIELD_TYPE_TIME: case MYSQL_TYPE_TIME:
case FIELD_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
return(DATA_INT); return(DATA_INT);
case FIELD_TYPE_FLOAT: case MYSQL_TYPE_FLOAT:
return(DATA_FLOAT); return(DATA_FLOAT);
case FIELD_TYPE_DOUBLE: case MYSQL_TYPE_DOUBLE:
return(DATA_DOUBLE); return(DATA_DOUBLE);
case FIELD_TYPE_DECIMAL: case MYSQL_TYPE_DECIMAL:
return(DATA_DECIMAL); return(DATA_DECIMAL);
case FIELD_TYPE_GEOMETRY: case MYSQL_TYPE_GEOMETRY:
case FIELD_TYPE_TINY_BLOB: case MYSQL_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_BLOB: case MYSQL_TYPE_BLOB:
case FIELD_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
return(DATA_BLOB); return(DATA_BLOB);
default: default:
assert(0); assert(0);
...@@ -2864,10 +2864,10 @@ ha_innobase::store_key_val_for_row( ...@@ -2864,10 +2864,10 @@ ha_innobase::store_key_val_for_row(
buff += key_len; buff += key_len;
} else if (mysql_type == FIELD_TYPE_TINY_BLOB } else if (mysql_type == MYSQL_TYPE_TINY_BLOB
|| mysql_type == FIELD_TYPE_MEDIUM_BLOB || mysql_type == MYSQL_TYPE_MEDIUM_BLOB
|| mysql_type == FIELD_TYPE_BLOB || mysql_type == MYSQL_TYPE_BLOB
|| mysql_type == FIELD_TYPE_LONG_BLOB) { || mysql_type == MYSQL_TYPE_LONG_BLOB) {
CHARSET_INFO* cs; CHARSET_INFO* cs;
ulint key_len; ulint key_len;
...@@ -2961,8 +2961,8 @@ ha_innobase::store_key_val_for_row( ...@@ -2961,8 +2961,8 @@ ha_innobase::store_key_val_for_row(
type is not enum or set. For these fields check type is not enum or set. For these fields check
if character set is multi byte. */ if character set is multi byte. */
if (real_type != FIELD_TYPE_ENUM if (real_type != MYSQL_TYPE_ENUM
&& real_type != FIELD_TYPE_SET && real_type != MYSQL_TYPE_SET
&& ( mysql_type == MYSQL_TYPE_VAR_STRING && ( mysql_type == MYSQL_TYPE_VAR_STRING
|| mysql_type == MYSQL_TYPE_STRING)) { || mysql_type == MYSQL_TYPE_STRING)) {
...@@ -5865,6 +5865,9 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) ...@@ -5865,6 +5865,9 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
uint i; uint i;
FOREIGN_KEY_INFO f_key_info; FOREIGN_KEY_INFO f_key_info;
LEX_STRING *name= 0; LEX_STRING *name= 0;
uint ulen;
char uname[NAME_LEN*3+1]; /* Unencoded name */
char db_name[NAME_LEN*3+1];
const char *tmp_buff; const char *tmp_buff;
tmp_buff= foreign->id; tmp_buff= foreign->id;
...@@ -5875,14 +5878,23 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) ...@@ -5875,14 +5878,23 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
f_key_info.forein_id= make_lex_string(thd, 0, tmp_buff, f_key_info.forein_id= make_lex_string(thd, 0, tmp_buff,
(uint) strlen(tmp_buff), 1); (uint) strlen(tmp_buff), 1);
tmp_buff= foreign->referenced_table_name; tmp_buff= foreign->referenced_table_name;
/* Database name */
i= 0; i= 0;
while (tmp_buff[i] != '/') while (tmp_buff[i] != '/')
i++; {
f_key_info.referenced_db= make_lex_string(thd, 0, db_name[i]= tmp_buff[i];
tmp_buff, i, 1); i++;
}
db_name[i]= 0;
ulen= filename_to_tablename(db_name, uname, sizeof(uname));
f_key_info.referenced_db= make_lex_string(thd, 0, uname, ulen, 1);
/* Table name */
tmp_buff+= i + 1; tmp_buff+= i + 1;
f_key_info.referenced_table= make_lex_string(thd, 0, tmp_buff, ulen= filename_to_tablename(tmp_buff, uname, sizeof(uname));
(uint) strlen(tmp_buff), 1); f_key_info.referenced_table= make_lex_string(thd, 0, uname,
ulen, 1);
for (i= 0;;) { for (i= 0;;) {
tmp_buff= foreign->foreign_col_names[i]; tmp_buff= foreign->foreign_col_names[i];
...@@ -5944,8 +5956,14 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) ...@@ -5944,8 +5956,14 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
} }
f_key_info.update_method= make_lex_string(thd, f_key_info.update_method, f_key_info.update_method= make_lex_string(thd, f_key_info.update_method,
tmp_buff, length, 1); tmp_buff, length, 1);
if (foreign->referenced_index &&
foreign->referenced_index->name)
{
f_key_info.referenced_key_name=
make_lex_string(thd, f_key_info.referenced_key_name,
foreign->referenced_index->name,
strlen(foreign->referenced_index->name), 1);
}
FOREIGN_KEY_INFO *pf_key_info= ((FOREIGN_KEY_INFO *) FOREIGN_KEY_INFO *pf_key_info= ((FOREIGN_KEY_INFO *)
thd->memdup((gptr) &f_key_info, thd->memdup((gptr) &f_key_info,
...@@ -6560,7 +6578,7 @@ innodb_mutex_show_status( ...@@ -6560,7 +6578,7 @@ innodb_mutex_show_status(
mutex->count_spin_rounds, mutex->count_spin_rounds,
mutex->count_os_wait, mutex->count_os_wait,
mutex->count_os_yield, mutex->count_os_yield,
(ulong) mutex->lspent_time/1000); (ulong) (mutex->lspent_time/1000));
if (stat_print(thd, innobase_hton_name, if (stat_print(thd, innobase_hton_name,
hton_name_len, buf1, buf1len, hton_name_len, buf1, buf1len,
...@@ -6605,7 +6623,7 @@ innodb_mutex_show_status( ...@@ -6605,7 +6623,7 @@ innodb_mutex_show_status(
rw_lock_count, rw_lock_count_spin_loop, rw_lock_count, rw_lock_count_spin_loop,
rw_lock_count_spin_rounds, rw_lock_count_spin_rounds,
rw_lock_count_os_wait, rw_lock_count_os_yield, rw_lock_count_os_wait, rw_lock_count_os_yield,
(ulong) rw_lock_wait_time/1000); (ulong) (rw_lock_wait_time/1000));
if (stat_print(thd, innobase_hton_name, hton_name_len, if (stat_print(thd, innobase_hton_name, hton_name_len,
STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) { STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) {
...@@ -7157,10 +7175,10 @@ ha_innobase::cmp_ref( ...@@ -7157,10 +7175,10 @@ ha_innobase::cmp_ref(
field = key_part->field; field = key_part->field;
mysql_type = field->type(); mysql_type = field->type();
if (mysql_type == FIELD_TYPE_TINY_BLOB if (mysql_type == MYSQL_TYPE_TINY_BLOB
|| mysql_type == FIELD_TYPE_MEDIUM_BLOB || mysql_type == MYSQL_TYPE_MEDIUM_BLOB
|| mysql_type == FIELD_TYPE_BLOB || mysql_type == MYSQL_TYPE_BLOB
|| mysql_type == FIELD_TYPE_LONG_BLOB) { || mysql_type == MYSQL_TYPE_LONG_BLOB) {
/* In the MySQL key value format, a column prefix of /* In the MySQL key value format, a column prefix of
a BLOB is preceded by a 2-byte length field */ a BLOB is preceded by a 2-byte length field */
......
...@@ -18,6 +18,9 @@ typedef struct hash_cell_struct hash_cell_t; ...@@ -18,6 +18,9 @@ typedef struct hash_cell_struct hash_cell_t;
typedef void* hash_node_t; typedef void* hash_node_t;
/* Fix Bug #13859: symbol collision between imap/mysql */
#define hash_create hash0_create
/***************************************************************** /*****************************************************************
Creates a hash table with >= n array cells. The actual number Creates a hash table with >= n array cells. The actual number
of cells is chosen to be a prime number slightly bigger than n. */ of cells is chosen to be a prime number slightly bigger than n. */
......
...@@ -259,17 +259,6 @@ mem_strdupl( ...@@ -259,17 +259,6 @@ mem_strdupl(
const char* str, /* in: string to be copied */ const char* str, /* in: string to be copied */
ulint len); /* in: length of str, in bytes */ ulint len); /* in: length of str, in bytes */
/**************************************************************************
Makes a NUL-terminated quoted copy of a NUL-terminated string. */
UNIV_INLINE
char*
mem_strdupq(
/*========*/
/* out, own: a quoted copy of the string,
must be deallocated with mem_free */
const char* str, /* in: string to be copied */
char q); /* in: quote character */
/************************************************************************** /**************************************************************************
Duplicates a NUL-terminated string, allocated from a memory heap. */ Duplicates a NUL-terminated string, allocated from a memory heap. */
......
...@@ -569,41 +569,6 @@ mem_strdupl( ...@@ -569,41 +569,6 @@ mem_strdupl(
return(memcpy(s, str, len)); return(memcpy(s, str, len));
} }
/**************************************************************************
Makes a NUL-terminated quoted copy of a NUL-terminated string. */
UNIV_INLINE
char*
mem_strdupq(
/*========*/
/* out, own: a quoted copy of the string,
must be deallocated with mem_free */
const char* str, /* in: string to be copied */
char q) /* in: quote character */
{
char* dst;
char* d;
const char* s = str;
size_t len = strlen(str) + 3;
/* calculate the number of quote characters in the string */
while((s = strchr(s, q)) != NULL) {
s++;
len++;
}
/* allocate the quoted string, and copy it */
d = dst = mem_alloc(len);
*d++ = q;
s = str;
while(*s) {
if ((*d++ = *s++) == q) {
*d++ = q;
}
}
*d++ = q;
*d++ = '\0';
ut_ad((ssize_t) len == d - dst);
return(dst);
}
/************************************************************************** /**************************************************************************
Makes a NUL-terminated copy of a nonterminated string, Makes a NUL-terminated copy of a nonterminated string,
allocated from a memory heap. */ allocated from a memory heap. */
......
...@@ -113,13 +113,20 @@ mutex_enter_func( ...@@ -113,13 +113,20 @@ mutex_enter_func(
mutex_t* mutex, /* in: pointer to mutex */ mutex_t* mutex, /* in: pointer to mutex */
const char* file_name, /* in: file name where locked */ const char* file_name, /* in: file name where locked */
ulint line); /* in: line where locked */ ulint line); /* in: line where locked */
/******************************************************************
NOTE! The following macro should be used in mutex locking, not the
corresponding function. */
#define mutex_enter_nowait(M) \
mutex_enter_nowait_func((M), __FILE__, __LINE__)
/************************************************************************ /************************************************************************
Tries to lock the mutex for the current thread. If the lock is not acquired NOTE! Use the corresponding macro in the header file, not this function
immediately, returns with return value 1. */ directly. Tries to lock the mutex for the current thread. If the lock is not
acquired immediately, returns with return value 1. */
ulint ulint
mutex_enter_nowait( mutex_enter_nowait_func(
/*===============*/ /*====================*/
/* out: 0 if succeed, 1 if not */ /* out: 0 if succeed, 1 if not */
mutex_t* mutex, /* in: pointer to mutex */ mutex_t* mutex, /* in: pointer to mutex */
const char* file_name, /* in: file name where mutex const char* file_name, /* in: file name where mutex
......
...@@ -250,6 +250,7 @@ mutex_enter_func( ...@@ -250,6 +250,7 @@ mutex_enter_func(
ulint line) /* in: line where locked */ ulint line) /* in: line where locked */
{ {
ut_ad(mutex_validate(mutex)); ut_ad(mutex_validate(mutex));
ut_ad(!mutex_own(mutex));
/* Note that we do not peek at the value of lock_word before trying /* Note that we do not peek at the value of lock_word before trying
the atomic test_and_set; we could peek, and possibly save time. */ the atomic test_and_set; we could peek, and possibly save time. */
......
...@@ -74,6 +74,7 @@ the pointer to the node to be added to the list. NAME is the list name. */ ...@@ -74,6 +74,7 @@ the pointer to the node to be added to the list. NAME is the list name. */
((N)->NAME).next = (BASE).start;\ ((N)->NAME).next = (BASE).start;\
((N)->NAME).prev = NULL;\ ((N)->NAME).prev = NULL;\
if ((BASE).start != NULL) {\ if ((BASE).start != NULL) {\
ut_ad((BASE).start != (N));\
(((BASE).start)->NAME).prev = (N);\ (((BASE).start)->NAME).prev = (N);\
}\ }\
(BASE).start = (N);\ (BASE).start = (N);\
...@@ -94,6 +95,7 @@ the pointer to the node to be added to the list. NAME is the list name. */ ...@@ -94,6 +95,7 @@ the pointer to the node to be added to the list. NAME is the list name. */
((N)->NAME).prev = (BASE).end;\ ((N)->NAME).prev = (BASE).end;\
((N)->NAME).next = NULL;\ ((N)->NAME).next = NULL;\
if ((BASE).end != NULL) {\ if ((BASE).end != NULL) {\
ut_ad((BASE).end != (N));\
(((BASE).end)->NAME).next = (N);\ (((BASE).end)->NAME).next = (N);\
}\ }\
(BASE).end = (N);\ (BASE).end = (N);\
...@@ -111,6 +113,7 @@ name, NODE1 and NODE2 are pointers to nodes. */ ...@@ -111,6 +113,7 @@ name, NODE1 and NODE2 are pointers to nodes. */
{\ {\
ut_ad(NODE1);\ ut_ad(NODE1);\
ut_ad(NODE2);\ ut_ad(NODE2);\
ut_ad((NODE1) != (NODE2));\
((BASE).count)++;\ ((BASE).count)++;\
((NODE2)->NAME).prev = (NODE1);\ ((NODE2)->NAME).prev = (NODE1);\
((NODE2)->NAME).next = ((NODE1)->NAME).next;\ ((NODE2)->NAME).next = ((NODE1)->NAME).next;\
......
...@@ -3227,7 +3227,7 @@ log_peek_lsn( ...@@ -3227,7 +3227,7 @@ log_peek_lsn(
could not get the log system mutex */ could not get the log system mutex */
ib_uint64_t* lsn) /* out: if returns TRUE, current lsn is here */ ib_uint64_t* lsn) /* out: if returns TRUE, current lsn is here */
{ {
if (0 == mutex_enter_nowait(&(log_sys->mutex), __FILE__, __LINE__)) { if (0 == mutex_enter_nowait(&(log_sys->mutex))) {
*lsn = log_sys->lsn; *lsn = log_sys->lsn;
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
......
...@@ -1733,7 +1733,7 @@ os_file_set_size( ...@@ -1733,7 +1733,7 @@ os_file_set_size(
} }
/* Print about progress for each 100 MB written */ /* Print about progress for each 100 MB written */
if ((current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024) if ((ib_longlong) (current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024)
!= current_size / (ib_longlong)(100 * 1024 * 1024)) { != current_size / (ib_longlong)(100 * 1024 * 1024)) {
fprintf(stderr, " %lu00", fprintf(stderr, " %lu00",
......
...@@ -1791,15 +1791,15 @@ srv_export_innodb_status(void) ...@@ -1791,15 +1791,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;
......
...@@ -563,8 +563,7 @@ rw_lock_debug_mutex_enter(void) ...@@ -563,8 +563,7 @@ rw_lock_debug_mutex_enter(void)
/*==========================*/ /*==========================*/
{ {
loop: loop:
if (0 == mutex_enter_nowait(&rw_lock_debug_mutex, if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) {
__FILE__, __LINE__)) {
return; return;
} }
...@@ -572,8 +571,7 @@ loop: ...@@ -572,8 +571,7 @@ loop:
rw_lock_debug_waiters = TRUE; rw_lock_debug_waiters = TRUE;
if (0 == mutex_enter_nowait(&rw_lock_debug_mutex, if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) {
__FILE__, __LINE__)) {
return; return;
} }
......
...@@ -311,12 +311,13 @@ mutex_free( ...@@ -311,12 +311,13 @@ mutex_free(
} }
/************************************************************************ /************************************************************************
Tries to lock the mutex for the current thread. If the lock is not acquired NOTE! Use the corresponding macro in the header file, not this function
immediately, returns with return value 1. */ directly. Tries to lock the mutex for the current thread. If the lock is not
acquired immediately, returns with return value 1. */
ulint ulint
mutex_enter_nowait( mutex_enter_nowait_func(
/*===============*/ /*====================*/
/* out: 0 if succeed, 1 if not */ /* out: 0 if succeed, 1 if not */
mutex_t* mutex, /* in: pointer to mutex */ mutex_t* mutex, /* in: pointer to mutex */
const char* file_name __attribute__((unused)), const char* file_name __attribute__((unused)),
......
...@@ -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.
...@@ -76,17 +125,11 @@ ut_usectime( ...@@ -76,17 +125,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