43 #ifndef UNIV_HOTBACKUP
45 # if defined(BUILD_DRIZZLE)
46 # include "drizzled/common.h"
47 # if TIME_WITH_SYS_TIME
48 # include <sys/time.h>
52 # include <sys/time.h>
59 # include "mysql_com.h"
66 UNIV_INTERN ibool ut_always_false = FALSE;
73 #define WIN_TO_UNIX_DELTA_USEC ((ib_int64_t) 11644473600000000ULL)
94 GetSystemTimeAsFileTime(&ft);
96 tm = (ib_int64_t) ft.dwHighDateTime << 32;
97 tm |= ft.dwLowDateTime;
106 tm -= WIN_TO_UNIX_DELTA_USEC;
108 tv->tv_sec = (long) (tm / 1000000L);
109 tv->tv_usec = (long) (tm % 1000000L);
116 #define ut_gettimeofday gettimeofday
151 #ifndef UNIV_HOTBACKUP
167 int errno_gettimeofday;
170 for (i = 0; i < 10; i++) {
172 ret = ut_gettimeofday(&tv, NULL);
175 errno_gettimeofday = errno;
177 fprintf(stderr,
" InnoDB: gettimeofday(): %s\n",
178 strerror(errno_gettimeofday));
180 errno = errno_gettimeofday;
187 *sec = (ulint) tv.tv_sec;
188 *ms = (ulint) tv.tv_usec;
208 ut_gettimeofday(&tv, NULL);
210 us = (ullint) tv.tv_sec * 1000000 + tv.tv_usec;
231 ut_gettimeofday(&tv, NULL);
233 return((ulint) tv.tv_sec * 1000 + tv.tv_usec / 1000);
247 return(difftime(time2, time1));
261 GetLocalTime(&cal_tm);
263 fprintf(file,
"%02d%02d%02d %2d:%02d:%02d",
264 (
int)cal_tm.wYear % 100,
269 (
int)cal_tm.wSecond);
272 struct tm* cal_tm_ptr;
277 #ifdef HAVE_LOCALTIME_R
278 localtime_r(&tm, &cal_tm);
279 cal_tm_ptr = &cal_tm;
281 cal_tm_ptr = localtime(&tm);
283 fprintf(file,
"%02d%02d%02d %2d:%02d:%02d",
284 cal_tm_ptr->tm_year % 100,
285 cal_tm_ptr->tm_mon + 1,
304 GetLocalTime(&cal_tm);
306 sprintf(buf,
"%02d%02d%02d %2d:%02d:%02d",
307 (
int)cal_tm.wYear % 100,
312 (
int)cal_tm.wSecond);
315 struct tm* cal_tm_ptr;
320 #ifdef HAVE_LOCALTIME_R
321 localtime_r(&tm, &cal_tm);
322 cal_tm_ptr = &cal_tm;
324 cal_tm_ptr = localtime(&tm);
326 sprintf(buf,
"%02d%02d%02d %2d:%02d:%02d",
327 cal_tm_ptr->tm_year % 100,
328 cal_tm_ptr->tm_mon + 1,
336 #ifdef UNIV_HOTBACKUP
342 ut_sprintf_timestamp_without_extra_chars(
349 GetLocalTime(&cal_tm);
351 sprintf(buf,
"%02d%02d%02d_%2d_%02d_%02d",
352 (
int)cal_tm.wYear % 100,
357 (
int)cal_tm.wSecond);
360 struct tm* cal_tm_ptr;
365 #ifdef HAVE_LOCALTIME_R
366 localtime_r(&tm, &cal_tm);
367 cal_tm_ptr = &cal_tm;
369 cal_tm_ptr = localtime(&tm);
371 sprintf(buf,
"%02d%02d%02d_%2d_%02d_%02d",
372 cal_tm_ptr->tm_year % 100,
373 cal_tm_ptr->tm_mon + 1,
385 ut_get_year_month_day(
394 GetLocalTime(&cal_tm);
396 *year = (ulint)cal_tm.wYear;
397 *month = (ulint)cal_tm.wMonth;
398 *day = (ulint)cal_tm.wDay;
401 struct tm* cal_tm_ptr;
406 #ifdef HAVE_LOCALTIME_R
407 localtime_r(&tm, &cal_tm);
408 cal_tm_ptr = &cal_tm;
410 cal_tm_ptr = localtime(&tm);
412 *year = (ulint)cal_tm_ptr->tm_year + 1900;
413 *month = (ulint)cal_tm_ptr->tm_mon + 1;
414 *day = (ulint)cal_tm_ptr->tm_mday;
419 #ifndef UNIV_HOTBACKUP
434 for (i = 0; i < delay * 50; i++) {
439 if (ut_always_false) {
440 ut_always_false = (ibool) j;
460 UNIV_MEM_ASSERT_RW(buf, len);
462 fprintf(file,
" len %lu; hex ", len);
464 for (data = (
const byte*)buf, i = 0; i < len; i++) {
465 fprintf(file,
"%02lx", (ulong)*data++);
468 fputs(
"; asc ", file);
470 data = (
const byte*)buf;
472 for (i = 0; i < len; i++) {
473 int c = (int) *data++;
474 putc(isprint(c) ? c :
' ', file);
527 #ifndef UNIV_HOTBACKUP
564 char buf[3 * NAME_LEN];
572 ssize_t ret= fwrite(buf, 1, bufend - buf, f);
573 assert(ret==bufend-buf);
585 long len = ftell(src);
590 size_t maxs = len < (long)
sizeof buf
593 size_t size = fread(buf, 1, maxs, src);
594 size_t ret= fwrite(buf, 1, size, dest);
627 res = _vscprintf(fmt, ap1);
631 _vsnprintf(str, size, fmt, ap2);
633 if ((
size_t) res >= size) {
634 str[size - 1] =
'\0';
659 return(
"Success, record lock created");
661 return(
"Generic error");
663 return(
"Operation interrupted");
664 case DB_OUT_OF_MEMORY:
665 return(
"Cannot allocate memory");
666 case DB_OUT_OF_FILE_SPACE:
667 return(
"Out of disk space");
674 case DB_DUPLICATE_KEY:
675 return(
"Duplicate key");
676 case DB_QUE_THR_SUSPENDED:
677 return(
"The queue thread has been suspended");
678 case DB_MISSING_HISTORY:
679 return(
"Required history data has been deleted");
680 case DB_CLUSTER_NOT_FOUND:
681 return(
"Cluster not found");
682 case DB_TABLE_NOT_FOUND:
683 return(
"Table not found");
684 case DB_MUST_GET_MORE_FILE_SPACE:
685 return(
"More file space needed");
686 case DB_TABLE_IS_BEING_USED:
687 return(
"Table is being used");
688 case DB_TOO_BIG_RECORD:
689 return(
"Record too big");
690 case DB_LOCK_WAIT_TIMEOUT:
691 return(
"Lock wait timeout");
692 case DB_NO_REFERENCED_ROW:
693 return(
"Referenced key value not found");
694 case DB_ROW_IS_REFERENCED:
695 return(
"Row is referenced");
696 case DB_CANNOT_ADD_CONSTRAINT:
697 return(
"Cannot add constraint");
699 return(
"Data structure corruption");
700 case DB_COL_APPEARS_TWICE_IN_INDEX:
701 return(
"Column appears twice in index");
702 case DB_CANNOT_DROP_CONSTRAINT:
703 return(
"Cannot drop constraint");
704 case DB_NO_SAVEPOINT:
705 return(
"No such savepoint");
706 case DB_TABLESPACE_ALREADY_EXISTS:
707 return(
"Tablespace already exists");
708 case DB_TABLESPACE_DELETED:
709 return(
"No such tablespace");
710 case DB_LOCK_TABLE_FULL:
711 return(
"Lock structs have exhausted the buffer pool");
712 case DB_FOREIGN_DUPLICATE_KEY:
713 return(
"Foreign key activated with duplicate keys");
714 case DB_FOREIGN_EXCEED_MAX_CASCADE:
715 return(
"Foreign key cascade delete/update exceeds max depth");
716 case DB_TOO_MANY_CONCURRENT_TRXS:
717 return(
"Too many concurrent transactions");
719 return(
"Unsupported");
720 case DB_PRIMARY_KEY_IS_NULL:
721 return(
"Primary key is NULL");
722 case DB_STATS_DO_NOT_EXIST:
723 return(
"Persistent statistics do not exist");
725 return(
"Failed, retry may succeed");
731 return(
"Failed, retry will not succeed");
732 case DB_ZIP_OVERFLOW:
733 return(
"Zip overflow");
734 case DB_RECORD_NOT_FOUND:
735 return(
"Record not found");
736 case DB_CHILD_NO_INDEX:
737 return(
"No index on referencing keys in referencing table");
738 case DB_PARENT_NO_INDEX:
739 return(
"No index on referenced keys in referenced table");
740 case DB_END_OF_INDEX:
741 return(
"End of index");
752 return(
"Unknown error");