40# if defined(BUILD_DRIZZLE)
41# include "drizzled/common.h"
44# include "mysql_com.h"
51UNIV_INTERN ibool ut_always_false = FALSE;
58#define WIN_TO_UNIX_DELTA_USEC ((ib_int64_t) 11644473600000000ULL)
79 GetSystemTimeAsFileTime(&ft);
81 tm = (ib_int64_t) ft.dwHighDateTime << 32;
82 tm |= ft.dwLowDateTime;
91 tm -= WIN_TO_UNIX_DELTA_USEC;
93 tv->tv_sec = (long) (tm / 1000000L);
94 tv->tv_usec = (long) (tm % 1000000L);
101#define ut_gettimeofday gettimeofday
136#ifndef UNIV_HOTBACKUP
152 int errno_gettimeofday;
155 for (i = 0; i < 10; i++) {
157 ret = ut_gettimeofday(&tv, NULL);
160 errno_gettimeofday = errno;
162 fprintf(stderr,
" InnoDB: gettimeofday(): %s\n",
163 strerror(errno_gettimeofday));
165 errno = errno_gettimeofday;
172 *sec = (ulint) tv.tv_sec;
173 *ms = (ulint) tv.tv_usec;
193 ut_gettimeofday(&tv, NULL);
195 us = (ullint) tv.tv_sec * 1000000 + tv.tv_usec;
216 ut_gettimeofday(&tv, NULL);
218 return((ulint) tv.tv_sec * 1000 + tv.tv_usec / 1000);
232 return(difftime(time2, time1));
246 GetLocalTime(&cal_tm);
248 fprintf(file,
"%02d%02d%02d %2d:%02d:%02d",
249 (
int)cal_tm.wYear % 100,
254 (
int)cal_tm.wSecond);
257 struct tm* cal_tm_ptr;
262#ifdef HAVE_LOCALTIME_R
263 localtime_r(&tm, &cal_tm);
264 cal_tm_ptr = &cal_tm;
266 cal_tm_ptr = localtime(&tm);
268 fprintf(file,
"%02d%02d%02d %2d:%02d:%02d",
269 cal_tm_ptr->tm_year % 100,
270 cal_tm_ptr->tm_mon + 1,
289 GetLocalTime(&cal_tm);
291 sprintf(buf,
"%02d%02d%02d %2d:%02d:%02d",
292 (
int)cal_tm.wYear % 100,
297 (
int)cal_tm.wSecond);
300 struct tm* cal_tm_ptr;
305#ifdef HAVE_LOCALTIME_R
306 localtime_r(&tm, &cal_tm);
307 cal_tm_ptr = &cal_tm;
309 cal_tm_ptr = localtime(&tm);
311 sprintf(buf,
"%02d%02d%02d %2d:%02d:%02d",
312 cal_tm_ptr->tm_year % 100,
313 cal_tm_ptr->tm_mon + 1,
327ut_sprintf_timestamp_without_extra_chars(
334 GetLocalTime(&cal_tm);
336 sprintf(buf,
"%02d%02d%02d_%2d_%02d_%02d",
337 (
int)cal_tm.wYear % 100,
342 (
int)cal_tm.wSecond);
345 struct tm* cal_tm_ptr;
350#ifdef HAVE_LOCALTIME_R
351 localtime_r(&tm, &cal_tm);
352 cal_tm_ptr = &cal_tm;
354 cal_tm_ptr = localtime(&tm);
356 sprintf(buf,
"%02d%02d%02d_%2d_%02d_%02d",
357 cal_tm_ptr->tm_year % 100,
358 cal_tm_ptr->tm_mon + 1,
370ut_get_year_month_day(
379 GetLocalTime(&cal_tm);
381 *year = (ulint)cal_tm.wYear;
382 *month = (ulint)cal_tm.wMonth;
383 *day = (ulint)cal_tm.wDay;
386 struct tm* cal_tm_ptr;
391#ifdef HAVE_LOCALTIME_R
392 localtime_r(&tm, &cal_tm);
393 cal_tm_ptr = &cal_tm;
395 cal_tm_ptr = localtime(&tm);
397 *year = (ulint)cal_tm_ptr->tm_year + 1900;
398 *month = (ulint)cal_tm_ptr->tm_mon + 1;
399 *day = (ulint)cal_tm_ptr->tm_mday;
404#ifndef UNIV_HOTBACKUP
419 for (i = 0; i < delay * 50; i++) {
424 if (ut_always_false) {
425 ut_always_false = (ibool) j;
445 UNIV_MEM_ASSERT_RW(buf, len);
447 fprintf(file,
" len %lu; hex ", len);
449 for (data = (
const byte*)buf, i = 0; i < len; i++) {
450 fprintf(file,
"%02lx", (ulong)*data++);
453 fputs(
"; asc ", file);
455 data = (
const byte*)buf;
457 for (i = 0; i < len; i++) {
458 int c = (int) *data++;
459 putc(isprint(c) ? c :
' ', file);
512#ifndef UNIV_HOTBACKUP
549 char buf[3 * NAME_LEN];
557 ssize_t ret= fwrite(buf, 1, bufend - buf, f);
558 assert(ret==bufend-buf);
570 long len = ftell(src);
575 size_t maxs = len < (long)
sizeof buf
578 size_t size = fread(buf, 1, maxs, src);
579 size_t ret= fwrite(buf, 1, size, dest);
612 res = _vscprintf(fmt, ap1);
616 _vsnprintf(str, size, fmt, ap2);
618 if ((
size_t) res >= size) {
619 str[size - 1] =
'\0';
644 return(
"Success, record lock created");
646 return(
"Generic error");
648 return(
"Operation interrupted");
649 case DB_OUT_OF_MEMORY:
650 return(
"Cannot allocate memory");
651 case DB_OUT_OF_FILE_SPACE:
652 return(
"Out of disk space");
659 case DB_DUPLICATE_KEY:
660 return(
"Duplicate key");
661 case DB_QUE_THR_SUSPENDED:
662 return(
"The queue thread has been suspended");
663 case DB_MISSING_HISTORY:
664 return(
"Required history data has been deleted");
665 case DB_CLUSTER_NOT_FOUND:
666 return(
"Cluster not found");
667 case DB_TABLE_NOT_FOUND:
668 return(
"Table not found");
669 case DB_MUST_GET_MORE_FILE_SPACE:
670 return(
"More file space needed");
671 case DB_TABLE_IS_BEING_USED:
672 return(
"Table is being used");
673 case DB_TOO_BIG_RECORD:
674 return(
"Record too big");
675 case DB_LOCK_WAIT_TIMEOUT:
676 return(
"Lock wait timeout");
677 case DB_NO_REFERENCED_ROW:
678 return(
"Referenced key value not found");
679 case DB_ROW_IS_REFERENCED:
680 return(
"Row is referenced");
681 case DB_CANNOT_ADD_CONSTRAINT:
682 return(
"Cannot add constraint");
684 return(
"Data structure corruption");
685 case DB_COL_APPEARS_TWICE_IN_INDEX:
686 return(
"Column appears twice in index");
687 case DB_CANNOT_DROP_CONSTRAINT:
688 return(
"Cannot drop constraint");
689 case DB_NO_SAVEPOINT:
690 return(
"No such savepoint");
691 case DB_TABLESPACE_ALREADY_EXISTS:
692 return(
"Tablespace already exists");
693 case DB_TABLESPACE_DELETED:
694 return(
"No such tablespace");
695 case DB_LOCK_TABLE_FULL:
696 return(
"Lock structs have exhausted the buffer pool");
697 case DB_FOREIGN_DUPLICATE_KEY:
698 return(
"Foreign key activated with duplicate keys");
699 case DB_FOREIGN_EXCEED_MAX_CASCADE:
700 return(
"Foreign key cascade delete/update exceeds max depth");
701 case DB_TOO_MANY_CONCURRENT_TRXS:
702 return(
"Too many concurrent transactions");
704 return(
"Unsupported");
705 case DB_PRIMARY_KEY_IS_NULL:
706 return(
"Primary key is NULL");
707 case DB_STATS_DO_NOT_EXIST:
708 return(
"Persistent statistics do not exist");
710 return(
"Failed, retry may succeed");
716 return(
"Failed, retry will not succeed");
717 case DB_ZIP_OVERFLOW:
718 return(
"Zip overflow");
719 case DB_RECORD_NOT_FOUND:
720 return(
"Record not found");
721 case DB_CHILD_NO_INDEX:
722 return(
"No index on referencing keys in referencing table");
723 case DB_PARENT_NO_INDEX:
724 return(
"No index on referenced keys in referenced table");
725 case DB_END_OF_INDEX:
726 return(
"End of index");
737 return(
"Unknown error");
UNIV_INTERN char * innobase_convert_name(char *buf, ulint buflen, const char *id, ulint idlen, drizzled::Session *session, ibool table_id)
UNIV_INTERN void os_thread_sleep(ulint tm)
drizzled::Session * mysql_thd
UNIV_INTERN ulint ut_2_power_up(ulint n) __attribute__((const))
UNIV_INTERN ulint ut_time_ms(void)
UNIV_INTERN ib_time_t ut_time(void)
UNIV_INTERN void ut_print_buf(FILE *file, const void *buf, ulint len)
UNIV_INTERN int ut_usectime(ulint *sec, ulint *ms)
UNIV_INTERN void ut_print_timestamp(FILE *file)
UNIV_INTERN void ut_print_name(FILE *f, struct trx_struct *trx, ibool table_id, const char *name)
UNIV_INTERN ulint ut_delay(ulint delay)
UNIV_INTERN void ut_sprintf_timestamp(char *buf)
UNIV_INTERN void ut_copy_file(FILE *dest, FILE *src)
UNIV_INTERN void ut_print_namel(FILE *f, struct trx_struct *trx, ibool table_id, const char *name, ulint namelen)
UNIV_INTERN ulint ut_get_high32(ulint a)
UNIV_INTERN void ut_print_filename(FILE *f, const char *name)
UNIV_INTERN ullint ut_time_us(ullint *tloc)
UNIV_INTERN const char * ut_strerr(enum db_err num)
UNIV_INTERN double ut_difftime(ib_time_t time2, ib_time_t time1)