~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_timefunc.h

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB
2
 
 
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.
6
 
 
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.
11
 
 
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:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 */
15
19
 
16
20
 
17
21
/* Function items used by mysql */
18
22
 
19
 
#ifdef USE_PRAGMA_INTERFACE
20
 
#pragma interface                       /* gcc class implementation */
21
 
#endif
22
 
 
23
23
enum date_time_format_types 
24
24
25
25
  TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND
69
69
  }
70
70
  enum_monotonicity_info get_monotonicity_info() const;
71
71
  int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
 
72
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
 
73
  { return false; }
72
74
};
73
75
 
74
76
 
84
86
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
85
87
    maybe_null=1; 
86
88
  }
 
89
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
 
90
  { return false; }
87
91
};
88
92
 
89
93
 
108
112
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
109
113
    maybe_null=1; 
110
114
  }
 
115
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
 
116
  { return false; }
111
117
};
112
118
 
113
119
 
307
313
    decimals=0;
308
314
    max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
309
315
  }
 
316
  bool check_vcol_func_processor(unsigned char *int_arg  __attribute__((unused)))
 
317
  { return true; }
310
318
};
311
319
 
312
320
 
427
435
{
428
436
  int64_t value;
429
437
  char buff[9*2+32];
430
 
  uint buff_length;
 
438
  uint32_t buff_length;
431
439
public:
432
440
  Item_func_curtime() :Item_str_timefunc() {}
433
441
  Item_func_curtime(Item *a) :Item_str_timefunc(a) {}
442
450
  */
443
451
  virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
444
452
  bool result_as_int64_t() { return true; }
 
453
  bool check_vcol_func_processor(unsigned char *int_arg  __attribute__((unused)))
 
454
  { return true; }
445
455
};
446
456
 
447
457
 
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)))
 
492
  { return true; }
481
493
};
482
494
 
483
495
 
506
518
protected:
507
519
  int64_t value;
508
520
  char buff[20*2+32];   // +32 to make my_snprintf_{8bit|ucs2} happy
509
 
  uint buff_length;
 
521
  uint32_t buff_length;
510
522
  DRIZZLE_TIME ltime;
511
523
public:
512
524
  Item_func_now() :Item_date_func() {}
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)))
 
534
  { return true; }
521
535
};
522
536
 
523
537
 
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()
564
578
  {
565
579
    Item_func_now::update_used_tables();
573
587
public:
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)))
 
592
  { return false; }
577
593
};
578
594
 
579
595
 
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;
594
610
};
595
611
 
596
612
 
597
613
class Item_func_from_unixtime :public Item_date_func
598
614
{
599
 
  THD *thd;
 
615
  Session *session;
600
616
 public:
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);
607
623
};
608
624
 
609
625
 
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);
642
658
  void cleanup();
643
659
};
644
660
 
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);
686
702
};
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
979
995
{
980
996
public:
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)
984
1000
  {}
985
1001
  String *val_str(String *str);
998
1014
{
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;
1003
1019
public:
1004
1020
  Item_func_str_to_date(Item *a, Item *b)
1005
1021
    :Item_str_func(a, b), const_item(false)
1006
1022
  {}
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();
1021
1037
public:
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);
1025
1041
};