~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/pbms/src/mysql_ms.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
2
 
 *
3
 
 * PrimeBase Media Stream for MySQL
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
 
 *
19
 
 * Original author: Paul McCullagh
20
 
 * Continued development: Barry Leslie
21
 
 *
22
 
 * 2007-05-25
23
 
 *
24
 
 * H&G2JCtL
25
 
 *
26
 
 * MySQL interface.
27
 
 *
28
 
 */
29
 
 
30
 
 
31
 
#ifdef DRIZZLED
32
 
#include <config.h>
33
 
#include <drizzled/common.h>
34
 
#include <drizzled/data_home.h>
35
 
#include <drizzled/current_session.h>
36
 
#include <drizzled/session.h>
37
 
#else
38
 
#include "cslib/CSConfig.h"
39
 
#endif
40
 
 
41
 
#include "cslib/CSGlobal.h"
42
 
#include "cslib/CSException.h"
43
 
#include "defs_ms.h"
44
 
#include "mysql_ms.h"
45
 
 
46
 
/* Note: 'new' used here is NOT CSObject::new which is a DEBUG define*/
47
 
#ifdef new
48
 
#undef new
49
 
#endif
50
 
 
51
 
void *ms_my_get_thread()
52
 
{
53
 
        THD *thd = current_thd;
54
 
 
55
 
        return (void *) thd;
56
 
}
57
 
 
58
 
#ifdef DRIZZLED
59
 
const char *ms_my_get_mysql_home_path()
60
 
{
61
 
        return drizzled::getDataHomeCatalog().file_string().c_str();
62
 
}
63
 
 
64
 
bool ms_is_autocommit()
65
 
{
66
 
        return (session_test_options(current_thd, (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) == 0;
67
 
}
68
 
 
69
 
#else
70
 
const char *ms_my_get_mysql_home_path()
71
 
{
72
 
        return mysql_real_data_home;
73
 
}
74
 
 
75
 
bool ms_is_autocommit()
76
 
{
77
 
        return (thd_test_options(current_thd, (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) == 0;
78
 
}
79
 
#endif
80
 
 
81
 
/* YYYYMMDDHHMMSS */
82
 
uint64_t        ms_my_1970_to_mysql_time(time_t t)
83
 
{
84
 
        struct tm       details;
85
 
        uint64_t                sec;
86
 
        uint64_t                min;
87
 
        uint64_t                hour;
88
 
        uint64_t                day;
89
 
        uint64_t                mon;
90
 
        uint64_t                year;
91
 
 
92
 
        gmtime_r(&t, &details);
93
 
        sec = (uint64_t) details.tm_sec;
94
 
        min = (uint64_t) details.tm_min * 100LL;
95
 
        hour = (uint64_t) details.tm_hour * 10000LL;
96
 
        day = (uint64_t) details.tm_mday * 1000000LL;
97
 
        mon = (uint64_t) (details.tm_mon+1) * 100000000LL;
98
 
        year = (uint64_t) (details.tm_year+1900) * 10000000000LL;
99
 
        
100
 
        return year + mon + day + hour + min + sec;
101
 
}
102
 
 
103