Drizzled Public API Documentation

mysql_ms.cc

00001 /* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
00002  *
00003  * PrimeBase Media Stream for MySQL
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  *
00019  * Original author: Paul McCullagh
00020  * Continued development: Barry Leslie
00021  *
00022  * 2007-05-25
00023  *
00024  * H&G2JCtL
00025  *
00026  * MySQL interface.
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 /* Note: 'new' used here is NOT CSObject::new which is a DEBUG define*/
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 /* YYYYMMDDHHMMSS */
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