~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-03-25 18:24:15 UTC
  • mto: This revision was merged to the branch mainline in revision 963.
  • Revision ID: brian@tangent.org-20090325182415-opf2720c1hidtfgk
Cut down on shutdown loop of plugins (cutting stuff out in order to simplify
old lock system).

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"
21
 
#include <boost/lexical_cast.hpp>
22
 
#include "drizzled/function/time/from_unixtime.h"
23
 
#include "drizzled/session.h"
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/function/time/from_unixtime.h>
 
23
#include <drizzled/session.h>
 
24
 
24
25
#include "drizzled/temporal.h"
25
 
#include "drizzled/time_functions.h"
26
26
 
27
27
#include <sstream>
28
28
#include <string>
29
29
 
30
 
namespace drizzled
31
 
{
32
 
 
33
30
void Item_func_from_unixtime::fix_length_and_dec()
34
31
{
35
32
  session= current_session;
36
33
  collation.set(&my_charset_bin);
37
34
  decimals= DATETIME_DEC;
38
 
  max_length=DateTime::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
 
35
  max_length=MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
39
36
  maybe_null= 1;
40
37
}
41
38
 
81
78
  if ((null_value= (args[0]->null_value || tmp > TIMESTAMP_MAX_VALUE)))
82
79
    return 1;
83
80
 
84
 
  Timestamp temporal;
 
81
  drizzled::Timestamp temporal;
85
82
  if (! temporal.from_time_t((time_t) tmp))
86
83
  {
87
84
    null_value= true;
88
 
    std::string tmp_string(boost::lexical_cast<std::string>(tmp));
 
85
    std::stringstream ss;
 
86
    std::string tmp_string;
 
87
    ss << tmp; ss >> tmp_string;
89
88
    my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(0), tmp_string.c_str());
90
89
    return 0;
91
90
  }
102
101
 
103
102
  return 0;
104
103
}
105
 
 
106
 
} /* namespace drizzled */