1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/server_includes.h>
22
#include <drizzled/functions/time/to_days.h>
24
int64_t Item_func_to_days::val_int()
28
if (get_arg0_date(<ime, TIME_NO_ZERO_DATE))
30
return (int64_t) calc_daynr(ltime.year,ltime.month,ltime.day);
35
Get information about this Item tree monotonicity
38
Item_func_to_days::get_monotonicity_info()
41
Get information about monotonicity of the function represented by this item
45
See enum_monotonicity_info.
48
enum_monotonicity_info Item_func_to_days::get_monotonicity_info() const
50
if (args[0]->type() == Item::FIELD_ITEM)
52
if (args[0]->field_type() == DRIZZLE_TYPE_NEWDATE)
53
return MONOTONIC_STRICT_INCREASING;
54
if (args[0]->field_type() == DRIZZLE_TYPE_DATETIME)
55
return MONOTONIC_INCREASING;
60
int64_t Item_func_to_days::val_int_endpoint(bool left_endp, bool *incl_endp)
65
if (get_arg0_date(<ime, TIME_NO_ZERO_DATE))
67
/* got NULL, leave the incl_endp intact */
70
res=(int64_t) calc_daynr(ltime.year,ltime.month,ltime.day);
72
if (args[0]->field_type() == DRIZZLE_TYPE_NEWDATE)
74
// TO_DAYS() is strictly monotonic for dates, leave incl_endp intact
79
Handle the special but practically useful case of datetime values that
80
point to day bound ("strictly less" comparison stays intact):
82
col < '2007-09-15 00:00:00' -> TO_DAYS(col) < TO_DAYS('2007-09-15')
84
which is different from the general case ("strictly less" changes to
87
col < '2007-09-15 12:34:56' -> TO_DAYS(col) <= TO_DAYS('2007-09-15')
89
if (!left_endp && !(ltime.hour || ltime.minute || ltime.second ||