~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/time/unix_timestamp.cc

  • Committer: lbieber
  • Date: 2010-10-01 13:06:31 UTC
  • mfrom: (1802.2.2 drizzle-bug-651948)
  • mto: This revision was merged to the branch mainline in revision 1805.
  • Revision ID: lbieber@orisndriz08-20101001130631-xubscnhmj7r5dn6g
Merge Andrew - Fix bug 651948 - Index lengths not retrieved using drizzledump

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
20
20
#include "config.h"
21
21
 
22
22
#include <drizzled/function/time/unix_timestamp.h>
23
 
#include <drizzled/field/epoch.h>
 
23
#include <drizzled/field/timestamp.h>
24
24
#include <drizzled/session.h>
25
25
 
26
26
#include "drizzled/temporal.h"
30
30
 
31
31
int64_t Item_func_unix_timestamp::val_int()
32
32
{
33
 
  type::Time ltime;
 
33
  DRIZZLE_TIME ltime;
34
34
 
35
35
  assert(fixed == 1);
36
36
  if (arg_count == 0)
37
 
    return (int64_t) current_session->getCurrentTimestampEpoch();
38
 
 
 
37
    return (int64_t) current_session->query_start();
39
38
  if (args[0]->type() == FIELD_ITEM)
40
39
  {                                             // Optimize timestamp field
41
40
    Field *field=((Item_field*) args[0])->field;
42
41
    if (field->type() == DRIZZLE_TYPE_TIMESTAMP)
43
 
      return ((field::Epoch::pointer) field)->get_timestamp(&null_value);
 
42
      return ((Field_timestamp*) field)->get_timestamp(&null_value);
44
43
  }
45
44
 
46
 
  if (get_arg0_date(ltime, 0))
 
45
  if (get_arg0_date(&ltime, 0))
47
46
  {
48
47
    /*
49
48
      We have to set null_value again because get_arg0_date will also set it
76
75
  }
77
76
 
78
77
  time_t tmp;
79
 
  temporal.to_time_t(tmp);
 
78
  temporal.to_time_t(&tmp);
80
79
 
81
80
  return (int64_t) tmp;
82
81
}