~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/client.cc

  • Committer: Jay Pipes
  • Date: 2010-03-09 20:02:29 UTC
  • mto: This revision was merged to the branch mainline in revision 1339.
  • Revision ID: jpipes@serialcoder-20100309200229-dfrliy4fads9vyf4
Fixes Bug #535296 by only incrementing ha_commit_count when its a normal transaction commit.

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>
 
20
#include "config.h"
 
21
#include "drizzled/plugin/client.h"
 
22
 
 
23
using namespace std;
26
24
 
27
25
namespace drizzled
28
26
{
29
27
 
30
 
bool plugin::Client::store(const type::Time *from)
 
28
bool plugin::Client::store(const DRIZZLE_TIME *from)
31
29
{
32
 
  const size_t buff_len= 40;
33
 
  char buff[buff_len];
34
 
  uint32_t length= 0;
 
30
  char buff[40];
 
31
  uint32_t length;
35
32
  uint32_t day;
36
33
 
37
34
  switch (from->time_type)
38
35
  {
39
 
  case type::DRIZZLE_TIMESTAMP_DATETIME:
40
 
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
 
36
  case DRIZZLE_TIMESTAMP_DATETIME:
 
37
    length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d",
41
38
                    (int) from->year,
42
39
                    (int) from->month,
43
40
                    (int) from->day,
45
42
                    (int) from->minute,
46
43
                    (int) from->second);
47
44
    if (from->second_part)
48
 
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
 
45
      length+= sprintf(buff+length, ".%06d", (int)from->second_part);
49
46
    break;
50
47
 
51
 
  case type::DRIZZLE_TIMESTAMP_DATE:
52
 
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
 
48
  case DRIZZLE_TIMESTAMP_DATE:
 
49
    length= sprintf(buff, "%04d-%02d-%02d",
53
50
                    (int) from->year,
54
51
                    (int) from->month,
55
52
                    (int) from->day);
56
53
    break;
57
54
 
58
 
  case type::DRIZZLE_TIMESTAMP_TIME:
 
55
  case DRIZZLE_TIMESTAMP_TIME:
59
56
    day= (from->year || from->month) ? 0 : from->day;
60
 
    length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
 
57
    length= sprintf(buff, "%s%02ld:%02d:%02d",
61
58
                    from->neg ? "-" : "",
62
59
                    (long) day*24L+(long) from->hour,
63
60
                    (int) from->minute,
64
61
                    (int) from->second);
65
62
    if (from->second_part)
66
 
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
 
63
      length+= sprintf(buff+length, ".%06d", (int)from->second_part);
67
64
    break;
68
65
 
69
 
  case type::DRIZZLE_TIMESTAMP_NONE:
70
 
  case type::DRIZZLE_TIMESTAMP_ERROR:
 
66
  case DRIZZLE_TIMESTAMP_NONE:
 
67
  case DRIZZLE_TIMESTAMP_ERROR:
71
68
  default:
72
69
    assert(0);
73
70
    return false;
80
77
{
81
78
  if (from == NULL)
82
79
    return store();
83
 
 
84
80
  return store(from, strlen(from));
85
81
}
86
82