36 #ifndef UNIV_HOTBACKUP
38 # if defined(BUILD_DRIZZLE)
39 # include "drizzled/common.h"
40 # if TIME_WITH_SYS_TIME
41 # include <sys/time.h>
45 # include <sys/time.h>
52 # include "mysql_com.h"
59 UNIV_INTERN ibool ut_always_false = FALSE;
66 #define WIN_TO_UNIX_DELTA_USEC ((ib_int64_t) 11644473600000000ULL)
87 GetSystemTimeAsFileTime(&ft);
89 tm = (ib_int64_t) ft.dwHighDateTime << 32;
90 tm |= ft.dwLowDateTime;
99 tm -= WIN_TO_UNIX_DELTA_USEC;
101 tv->tv_sec = (long) (tm / 1000000L);
102 tv->tv_usec = (long) (tm % 1000000L);
109 #define ut_gettimeofday gettimeofday
144 #ifndef UNIV_HOTBACKUP
160 int errno_gettimeofday;
163 for (i = 0; i < 10; i++) {
165 ret = ut_gettimeofday(&tv, NULL);
168 errno_gettimeofday = errno;
170 fprintf(stderr,
" InnoDB: gettimeofday(): %s\n",
171 strerror(errno_gettimeofday));
173 errno = errno_gettimeofday;
180 *sec = (ulint) tv.tv_sec;
181 *ms = (ulint) tv.tv_usec;
201 ut_gettimeofday(&tv, NULL);
203 us = (ullint) tv.tv_sec * 1000000 + tv.tv_usec;
224 ut_gettimeofday(&tv, NULL);
226 return((ulint) tv.tv_sec * 1000 + tv.tv_usec / 1000);
240 return(difftime(time2, time1));
254 GetLocalTime(&cal_tm);
256 fprintf(file,
"%02d%02d%02d %2d:%02d:%02d",
257 (
int)cal_tm.wYear % 100,
262 (
int)cal_tm.wSecond);
265 struct tm* cal_tm_ptr;
270 #ifdef HAVE_LOCALTIME_R
271 localtime_r(&tm, &cal_tm);
272 cal_tm_ptr = &cal_tm;
274 cal_tm_ptr = localtime(&tm);
276 fprintf(file,
"%02d%02d%02d %2d:%02d:%02d",
277 cal_tm_ptr->tm_year % 100,
278 cal_tm_ptr->tm_mon + 1,
297 GetLocalTime(&cal_tm);
299 sprintf(buf,
"%02d%02d%02d %2d:%02d:%02d",
300 (
int)cal_tm.wYear % 100,
305 (
int)cal_tm.wSecond);
308 struct tm* cal_tm_ptr;
313 #ifdef HAVE_LOCALTIME_R
314 localtime_r(&tm, &cal_tm);
315 cal_tm_ptr = &cal_tm;
317 cal_tm_ptr = localtime(&tm);
319 sprintf(buf,
"%02d%02d%02d %2d:%02d:%02d",
320 cal_tm_ptr->tm_year % 100,
321 cal_tm_ptr->tm_mon + 1,
329 #ifdef UNIV_HOTBACKUP
335 ut_sprintf_timestamp_without_extra_chars(
342 GetLocalTime(&cal_tm);
344 sprintf(buf,
"%02d%02d%02d_%2d_%02d_%02d",
345 (
int)cal_tm.wYear % 100,
350 (
int)cal_tm.wSecond);
353 struct tm* cal_tm_ptr;
358 #ifdef HAVE_LOCALTIME_R
359 localtime_r(&tm, &cal_tm);
360 cal_tm_ptr = &cal_tm;
362 cal_tm_ptr = localtime(&tm);
364 sprintf(buf,
"%02d%02d%02d_%2d_%02d_%02d",
365 cal_tm_ptr->tm_year % 100,
366 cal_tm_ptr->tm_mon + 1,
378 ut_get_year_month_day(
387 GetLocalTime(&cal_tm);
389 *year = (ulint)cal_tm.wYear;
390 *month = (ulint)cal_tm.wMonth;
391 *day = (ulint)cal_tm.wDay;
394 struct tm* cal_tm_ptr;
399 #ifdef HAVE_LOCALTIME_R
400 localtime_r(&tm, &cal_tm);
401 cal_tm_ptr = &cal_tm;
403 cal_tm_ptr = localtime(&tm);
405 *year = (ulint)cal_tm_ptr->tm_year + 1900;
406 *month = (ulint)cal_tm_ptr->tm_mon + 1;
407 *day = (ulint)cal_tm_ptr->tm_mday;
412 #ifndef UNIV_HOTBACKUP
427 for (i = 0; i < delay * 50; i++) {
432 if (ut_always_false) {
433 ut_always_false = (ibool) j;
453 UNIV_MEM_ASSERT_RW(buf, len);
455 fprintf(file,
" len %lu; hex ", len);
457 for (data = (
const byte*)buf, i = 0; i < len; i++) {
458 fprintf(file,
"%02lx", (ulong)*data++);
461 fputs(
"; asc ", file);
463 data = (
const byte*)buf;
465 for (i = 0; i < len; i++) {
466 int c = (int) *data++;
467 putc(isprint(c) ? c :
' ', file);
520 #ifndef UNIV_HOTBACKUP
557 char buf[3 * NAME_LEN];
565 ssize_t ret= fwrite(buf, 1, bufend - buf, f);
566 assert(ret==bufend-buf);
578 long len = ftell(src);
583 size_t maxs = len < (long)
sizeof buf
586 size_t size = fread(buf, 1, maxs, src);
587 size_t ret= fwrite(buf, 1, size, dest);
620 res = _vscprintf(fmt, ap1);
624 _vsnprintf(str, size, fmt, ap2);
626 if ((
size_t) res >= size) {
627 str[size - 1] =
'\0';
652 return(
"Success, record lock created");
654 return(
"Generic error");
656 return(
"Operation interrupted");
657 case DB_OUT_OF_MEMORY:
658 return(
"Cannot allocate memory");
659 case DB_OUT_OF_FILE_SPACE:
660 return(
"Out of disk space");
667 case DB_DUPLICATE_KEY:
668 return(
"Duplicate key");
669 case DB_QUE_THR_SUSPENDED:
670 return(
"The queue thread has been suspended");
671 case DB_MISSING_HISTORY:
672 return(
"Required history data has been deleted");
673 case DB_CLUSTER_NOT_FOUND:
674 return(
"Cluster not found");
675 case DB_TABLE_NOT_FOUND:
676 return(
"Table not found");
677 case DB_MUST_GET_MORE_FILE_SPACE:
678 return(
"More file space needed");
679 case DB_TABLE_IS_BEING_USED:
680 return(
"Table is being used");
681 case DB_TOO_BIG_RECORD:
682 return(
"Record too big");
683 case DB_LOCK_WAIT_TIMEOUT:
684 return(
"Lock wait timeout");
685 case DB_NO_REFERENCED_ROW:
686 return(
"Referenced key value not found");
687 case DB_ROW_IS_REFERENCED:
688 return(
"Row is referenced");
689 case DB_CANNOT_ADD_CONSTRAINT:
690 return(
"Cannot add constraint");
692 return(
"Data structure corruption");
693 case DB_COL_APPEARS_TWICE_IN_INDEX:
694 return(
"Column appears twice in index");
695 case DB_CANNOT_DROP_CONSTRAINT:
696 return(
"Cannot drop constraint");
697 case DB_NO_SAVEPOINT:
698 return(
"No such savepoint");
699 case DB_TABLESPACE_ALREADY_EXISTS:
700 return(
"Tablespace already exists");
701 case DB_TABLESPACE_DELETED:
702 return(
"No such tablespace");
703 case DB_LOCK_TABLE_FULL:
704 return(
"Lock structs have exhausted the buffer pool");
705 case DB_FOREIGN_DUPLICATE_KEY:
706 return(
"Foreign key activated with duplicate keys");
707 case DB_FOREIGN_EXCEED_MAX_CASCADE:
708 return(
"Foreign key cascade delete/update exceeds max depth");
709 case DB_TOO_MANY_CONCURRENT_TRXS:
710 return(
"Too many concurrent transactions");
712 return(
"Unsupported");
713 case DB_PRIMARY_KEY_IS_NULL:
714 return(
"Primary key is NULL");
715 case DB_STATS_DO_NOT_EXIST:
716 return(
"Persistent statistics do not exist");
718 return(
"Failed, retry may succeed");
724 return(
"Failed, retry will not succeed");
725 case DB_ZIP_OVERFLOW:
726 return(
"Zip overflow");
727 case DB_RECORD_NOT_FOUND:
728 return(
"Record not found");
729 case DB_CHILD_NO_INDEX:
730 return(
"No index on referencing keys in referencing table");
731 case DB_PARENT_NO_INDEX:
732 return(
"No index on referenced keys in referenced table");
733 case DB_END_OF_INDEX:
734 return(
"End of index");
745 return(
"Unknown error");