~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/client.cc

  • Committer: Brian Aker
  • Date: 2009-12-03 01:17:53 UTC
  • mto: (1237.3.2 push)
  • mto: This revision was merged to the branch mainline in revision 1238.
  • Revision ID: brian@gaz-20091203011753-159h2no5m5c5dt9b
Small cleanups, did in MERGE table only engine flag.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include "drizzled/server_includes.h"
21
21
#include "drizzled/plugin/client.h"
22
22
 
23
23
using namespace std;
24
 
 
25
 
namespace drizzled
26
 
{
 
24
using namespace drizzled;
27
25
 
28
26
bool plugin::Client::store(const DRIZZLE_TIME *from)
29
27
{
30
 
  const size_t buff_len= 40;
31
 
  char buff[buff_len];
32
 
  uint32_t length= 0;
 
28
  char buff[40];
 
29
  uint32_t length;
33
30
  uint32_t day;
34
31
 
35
32
  switch (from->time_type)
36
33
  {
37
34
  case DRIZZLE_TIMESTAMP_DATETIME:
38
 
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
 
35
    length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d",
39
36
                    (int) from->year,
40
37
                    (int) from->month,
41
38
                    (int) from->day,
43
40
                    (int) from->minute,
44
41
                    (int) from->second);
45
42
    if (from->second_part)
46
 
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
 
43
      length+= sprintf(buff+length, ".%06d", (int)from->second_part);
47
44
    break;
48
45
 
49
46
  case DRIZZLE_TIMESTAMP_DATE:
50
 
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
 
47
    length= sprintf(buff, "%04d-%02d-%02d",
51
48
                    (int) from->year,
52
49
                    (int) from->month,
53
50
                    (int) from->day);
55
52
 
56
53
  case DRIZZLE_TIMESTAMP_TIME:
57
54
    day= (from->year || from->month) ? 0 : from->day;
58
 
    length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
 
55
    length= sprintf(buff, "%s%02ld:%02d:%02d",
59
56
                    from->neg ? "-" : "",
60
57
                    (long) day*24L+(long) from->hour,
61
58
                    (int) from->minute,
62
59
                    (int) from->second);
63
60
    if (from->second_part)
64
 
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
 
61
      length+= sprintf(buff+length, ".%06d", (int)from->second_part);
65
62
    break;
66
63
 
67
64
  case DRIZZLE_TIMESTAMP_NONE:
80
77
    return store();
81
78
  return store(from, strlen(from));
82
79
}
83
 
 
84
 
 
85
 
} /* namespace drizzled */