1
/* Copyright (C) 2000-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
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
17
21
/* Function items used by mysql */
19
#ifdef USE_PRAGMA_INTERFACE
20
#pragma interface /* gcc class implementation */
23
23
enum date_time_format_types
25
25
TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND
476
486
int64_t val_int() { assert(fixed == 1); return (value) ; }
477
487
String *val_str(String *str);
478
488
void fix_length_and_dec();
479
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
489
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
480
490
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
491
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
516
528
int save_in_field(Field *to, bool no_conversions);
517
529
String *val_str(String *str);
518
530
void fix_length_and_dec();
519
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
531
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
520
532
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
533
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
559
573
int save_in_field(Field *to, bool no_conversions);
560
574
String *val_str(String *str);
561
575
void fix_length_and_dec();
562
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
576
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
563
577
void update_used_tables()
565
579
Item_func_now::update_used_tables();
574
588
Item_func_from_days(Item *a) :Item_date(a) {}
575
589
const char *func_name() const { return "from_days"; }
576
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
590
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
591
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
589
605
const char *func_name() const
590
606
{ return is_time_format ? "time_format" : "date_format"; }
591
607
void fix_length_and_dec();
592
uint format_length(const String *format);
608
uint32_t format_length(const String *format);
593
609
bool eq(const Item *item, bool binary_cmp) const;
597
613
class Item_func_from_unixtime :public Item_date_func
601
617
Item_func_from_unixtime(Item *a) :Item_date_func(a) {}
602
618
int64_t val_int();
603
619
String *val_str(String *str);
604
620
const char *func_name() const { return "from_unixtime"; }
605
621
void fix_length_and_dec();
606
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
622
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
638
654
String *val_str(String *str);
639
655
const char *func_name() const { return "convert_tz"; }
640
656
void fix_length_and_dec();
641
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
657
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
680
696
void fix_length_and_dec();
681
697
enum_field_types field_type() const { return cached_field_type; }
682
698
int64_t val_int();
683
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
699
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
684
700
bool eq(const Item *item, bool binary_cmp) const;
685
701
virtual void print(String *str, enum_query_type query_type);
764
780
Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
765
781
const char *func_name() const { return "cast_as_date"; }
766
782
String *val_str(String *str);
767
bool get_date(DRIZZLE_TIME *ltime, uint fuzzy_date);
783
bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date);
768
784
bool get_time(DRIZZLE_TIME *ltime);
769
785
const char *cast_type() const { return "date"; }
770
786
enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDATE; }
978
994
class Item_func_get_format :public Item_str_func
981
const timestamp_type type; // keep it public
982
Item_func_get_format(timestamp_type type_arg, Item *a)
997
const enum enum_drizzle_timestamp_type type; // keep it public
998
Item_func_get_format(enum enum_drizzle_timestamp_type type_arg, Item *a)
983
999
:Item_str_func(a), type(type_arg)
985
1001
String *val_str(String *str);
999
1015
enum_field_types cached_field_type;
1000
1016
date_time_format_types cached_format_type;
1001
timestamp_type cached_timestamp_type;
1017
enum enum_drizzle_timestamp_type cached_timestamp_type;
1002
1018
bool const_item;
1004
1020
Item_func_str_to_date(Item *a, Item *b)
1005
1021
:Item_str_func(a, b), const_item(false)
1007
1023
String *val_str(String *str);
1008
bool get_date(DRIZZLE_TIME *ltime, uint fuzzy_date);
1024
bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date);
1009
1025
const char *func_name() const { return "str_to_date"; }
1010
1026
enum_field_types field_type() const { return cached_field_type; }
1011
1027
void fix_length_and_dec();
1022
1038
Item_func_last_day(Item *a) :Item_date(a) {}
1023
1039
const char *func_name() const { return "last_day"; }
1024
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
1040
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);