~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/client.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-12-17 04:48:59 UTC
  • mto: This revision was merged to the branch mainline in revision 1246.
  • Revision ID: osullivan.padraig@gmail.com-20091217044859-qorpkp4911zypfv3
Added some dtrace probes for tracing the optimizer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
22
 
#include <cstdio>
23
 
 
24
 
#include <drizzled/plugin/client.h>
25
 
#include <drizzled/type/time.h>
26
 
 
27
 
namespace drizzled
28
 
{
29
 
 
30
 
bool plugin::Client::store(const type::Time *from)
31
 
{
32
 
  const size_t buff_len= 40;
33
 
  char buff[buff_len];
34
 
  uint32_t length= 0;
 
20
#include "drizzled/server_includes.h"
 
21
#include "drizzled/plugin/client.h"
 
22
 
 
23
using namespace std;
 
24
using namespace drizzled;
 
25
 
 
26
bool plugin::Client::store(const DRIZZLE_TIME *from)
 
27
{
 
28
  char buff[40];
 
29
  uint32_t length;
35
30
  uint32_t day;
36
31
 
37
32
  switch (from->time_type)
38
33
  {
39
 
  case type::DRIZZLE_TIMESTAMP_DATETIME:
40
 
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
 
34
  case DRIZZLE_TIMESTAMP_DATETIME:
 
35
    length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d",
41
36
                    (int) from->year,
42
37
                    (int) from->month,
43
38
                    (int) from->day,
45
40
                    (int) from->minute,
46
41
                    (int) from->second);
47
42
    if (from->second_part)
48
 
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
 
43
      length+= sprintf(buff+length, ".%06d", (int)from->second_part);
49
44
    break;
50
45
 
51
 
  case type::DRIZZLE_TIMESTAMP_DATE:
52
 
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
 
46
  case DRIZZLE_TIMESTAMP_DATE:
 
47
    length= sprintf(buff, "%04d-%02d-%02d",
53
48
                    (int) from->year,
54
49
                    (int) from->month,
55
50
                    (int) from->day);
56
51
    break;
57
52
 
58
 
  case type::DRIZZLE_TIMESTAMP_TIME:
 
53
  case DRIZZLE_TIMESTAMP_TIME:
59
54
    day= (from->year || from->month) ? 0 : from->day;
60
 
    length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
 
55
    length= sprintf(buff, "%s%02ld:%02d:%02d",
61
56
                    from->neg ? "-" : "",
62
57
                    (long) day*24L+(long) from->hour,
63
58
                    (int) from->minute,
64
59
                    (int) from->second);
65
60
    if (from->second_part)
66
 
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
 
61
      length+= sprintf(buff+length, ".%06d", (int)from->second_part);
67
62
    break;
68
63
 
69
 
  case type::DRIZZLE_TIMESTAMP_NONE:
70
 
  case type::DRIZZLE_TIMESTAMP_ERROR:
 
64
  case DRIZZLE_TIMESTAMP_NONE:
 
65
  case DRIZZLE_TIMESTAMP_ERROR:
71
66
  default:
72
67
    assert(0);
73
68
    return false;
80
75
{
81
76
  if (from == NULL)
82
77
    return store();
83
 
 
84
78
  return store(from, strlen(from));
85
79
}
86
 
 
87
 
 
88
 
} /* namespace drizzled */