00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifdef DRIZZLED
00032 #include <config.h>
00033 #include <drizzled/common.h>
00034 #include <drizzled/data_home.h>
00035 #include <drizzled/current_session.h>
00036 #include <drizzled/session.h>
00037 #else
00038 #include "cslib/CSConfig.h"
00039 #endif
00040
00041 #include "cslib/CSGlobal.h"
00042 #include "cslib/CSException.h"
00043 #include "defs_ms.h"
00044 #include "mysql_ms.h"
00045
00046
00047 #ifdef new
00048 #undef new
00049 #endif
00050
00051 void *ms_my_get_thread()
00052 {
00053 THD *thd = current_thd;
00054
00055 return (void *) thd;
00056 }
00057
00058 #ifdef DRIZZLED
00059 const char *ms_my_get_mysql_home_path()
00060 {
00061 return drizzled::getDataHomeCatalog().file_string().c_str();
00062 }
00063
00064 bool ms_is_autocommit()
00065 {
00066 return (session_test_options(current_thd, (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) == 0;
00067 }
00068
00069 #else
00070 const char *ms_my_get_mysql_home_path()
00071 {
00072 return mysql_real_data_home;
00073 }
00074
00075 bool ms_is_autocommit()
00076 {
00077 return (thd_test_options(current_thd, (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) == 0;
00078 }
00079 #endif
00080
00081
00082 uint64_t ms_my_1970_to_mysql_time(time_t t)
00083 {
00084 struct tm details;
00085 uint64_t sec;
00086 uint64_t min;
00087 uint64_t hour;
00088 uint64_t day;
00089 uint64_t mon;
00090 uint64_t year;
00091
00092 gmtime_r(&t, &details);
00093 sec = (uint64_t) details.tm_sec;
00094 min = (uint64_t) details.tm_min * 100LL;
00095 hour = (uint64_t) details.tm_hour * 10000LL;
00096 day = (uint64_t) details.tm_mday * 1000000LL;
00097 mon = (uint64_t) (details.tm_mon+1) * 100000000LL;
00098 year = (uint64_t) (details.tm_year+1900) * 10000000000LL;
00099
00100 return year + mon + day + hour + min + sec;
00101 }
00102
00103