~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_timefunc.h

Coupla small include cleanups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
345
345
    decimals=0;
346
346
    max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
347
347
  }
348
 
  Field *tmp_table_field(Table *table)
 
348
  Field *tmp_table_field(TABLE *table)
349
349
  {
350
350
    return tmp_table_field_from_field_type(table, 0);
351
351
  }
371
371
  Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {}
372
372
  Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {}
373
373
  enum_field_types field_type() const { return DRIZZLE_TYPE_DATETIME; }
374
 
  Field *tmp_table_field(Table *table)
 
374
  Field *tmp_table_field(TABLE *table)
375
375
  {
376
376
    return tmp_table_field_from_field_type(table, 0);
377
377
  }
403
403
    decimals= DATETIME_DEC;
404
404
    max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
405
405
  }
406
 
  Field *tmp_table_field(Table *table)
 
406
  Field *tmp_table_field(TABLE *table)
407
407
  {
408
408
    return tmp_table_field_from_field_type(table, 0);
409
409
  }
438
438
  /* 
439
439
    Abstract method that defines which time zone is used for conversion.
440
440
    Converts time current time in my_time_t representation to broken-down
441
 
    DRIZZLE_TIME representation using UTC-SYSTEM or per-thread time zone.
 
441
    MYSQL_TIME representation using UTC-SYSTEM or per-thread time zone.
442
442
  */
443
 
  virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
 
443
  virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
444
444
  bool result_as_int64_t() { return true; }
445
445
};
446
446
 
451
451
  Item_func_curtime_local() :Item_func_curtime() {}
452
452
  Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
453
453
  const char *func_name() const { return "curtime"; }
454
 
  virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
 
454
  virtual void store_now_in_TIME(MYSQL_TIME *now_time);
455
455
};
456
456
 
457
457
 
461
461
  Item_func_curtime_utc() :Item_func_curtime() {}
462
462
  Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
463
463
  const char *func_name() const { return "utc_time"; }
464
 
  virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
 
464
  virtual void store_now_in_TIME(MYSQL_TIME *now_time);
465
465
};
466
466
 
467
467
 
470
470
class Item_func_curdate :public Item_date
471
471
{
472
472
  int64_t value;
473
 
  DRIZZLE_TIME ltime;
 
473
  MYSQL_TIME ltime;
474
474
public:
475
475
  Item_func_curdate() :Item_date() {}
476
476
  int64_t val_int() { assert(fixed == 1); return (value) ; }
477
477
  String *val_str(String *str);
478
478
  void fix_length_and_dec();
479
 
  bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
480
 
  virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
 
479
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
 
480
  virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
481
481
};
482
482
 
483
483
 
486
486
public:
487
487
  Item_func_curdate_local() :Item_func_curdate() {}
488
488
  const char *func_name() const { return "curdate"; }
489
 
  void store_now_in_TIME(DRIZZLE_TIME *now_time);
 
489
  void store_now_in_TIME(MYSQL_TIME *now_time);
490
490
};
491
491
 
492
492
 
495
495
public:
496
496
  Item_func_curdate_utc() :Item_func_curdate() {}
497
497
  const char *func_name() const { return "utc_date"; }
498
 
  void store_now_in_TIME(DRIZZLE_TIME *now_time);
 
498
  void store_now_in_TIME(MYSQL_TIME *now_time);
499
499
};
500
500
 
501
501
 
507
507
  int64_t value;
508
508
  char buff[20*2+32];   // +32 to make my_snprintf_{8bit|ucs2} happy
509
509
  uint buff_length;
510
 
  DRIZZLE_TIME ltime;
 
510
  MYSQL_TIME ltime;
511
511
public:
512
512
  Item_func_now() :Item_date_func() {}
513
513
  Item_func_now(Item *a) :Item_date_func(a) {}
516
516
  int save_in_field(Field *to, bool no_conversions);
517
517
  String *val_str(String *str);
518
518
  void fix_length_and_dec();
519
 
  bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
520
 
  virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
 
519
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
 
520
  virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
521
521
};
522
522
 
523
523
 
527
527
  Item_func_now_local() :Item_func_now() {}
528
528
  Item_func_now_local(Item *a) :Item_func_now(a) {}
529
529
  const char *func_name() const { return "now"; }
530
 
  virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
 
530
  virtual void store_now_in_TIME(MYSQL_TIME *now_time);
531
531
  virtual enum Functype functype() const { return NOW_FUNC; }
532
532
};
533
533
 
538
538
  Item_func_now_utc() :Item_func_now() {}
539
539
  Item_func_now_utc(Item *a) :Item_func_now(a) {}
540
540
  const char *func_name() const { return "utc_timestamp"; }
541
 
  virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
 
541
  virtual void store_now_in_TIME(MYSQL_TIME *now_time);
542
542
};
543
543
 
544
544
 
553
553
  Item_func_sysdate_local(Item *a) :Item_func_now(a) {}
554
554
  bool const_item() const { return 0; }
555
555
  const char *func_name() const { return "sysdate"; }
556
 
  void store_now_in_TIME(DRIZZLE_TIME *now_time);
 
556
  void store_now_in_TIME(MYSQL_TIME *now_time);
557
557
  double val_real();
558
558
  int64_t val_int();
559
559
  int save_in_field(Field *to, bool no_conversions);
560
560
  String *val_str(String *str);
561
561
  void fix_length_and_dec();
562
 
  bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
 
562
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
563
563
  void update_used_tables()
564
564
  {
565
565
    Item_func_now::update_used_tables();
573
573
public:
574
574
  Item_func_from_days(Item *a) :Item_date(a) {}
575
575
  const char *func_name() const { return "from_days"; }
576
 
  bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
 
576
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
577
577
};
578
578
 
579
579
 
603
603
  String *val_str(String *str);
604
604
  const char *func_name() const { return "from_unixtime"; }
605
605
  void fix_length_and_dec();
606
 
  bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
 
606
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
607
607
};
608
608
 
609
609
 
638
638
  String *val_str(String *str);
639
639
  const char *func_name() const { return "convert_tz"; }
640
640
  void fix_length_and_dec();
641
 
  bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
 
641
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
642
642
  void cleanup();
643
643
};
644
644
 
680
680
  void fix_length_and_dec();
681
681
  enum_field_types field_type() const { return cached_field_type; }
682
682
  int64_t val_int();
683
 
  bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
 
683
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
684
684
  bool eq(const Item *item, bool binary_cmp) const;
685
685
  virtual void print(String *str, enum_query_type query_type);
686
686
};
742
742
class Item_char_typecast :public Item_typecast
743
743
{
744
744
  int cast_length;
745
 
  const CHARSET_INFO *cast_cs, *from_cs;
 
745
  CHARSET_INFO *cast_cs, *from_cs;
746
746
  bool charset_conversion;
747
747
  String tmp_value;
748
748
public:
749
 
  Item_char_typecast(Item *a, int length_arg, const CHARSET_INFO * const cs_arg)
 
749
  Item_char_typecast(Item *a, int length_arg, CHARSET_INFO *cs_arg)
750
750
    :Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {}
751
751
  enum Functype functype() const { return CHAR_TYPECAST_FUNC; }
752
752
  bool eq(const Item *item, bool binary_cmp) const;
764
764
  Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
765
765
  const char *func_name() const { return "cast_as_date"; }
766
766
  String *val_str(String *str);
767
 
  bool get_date(DRIZZLE_TIME *ltime, uint fuzzy_date);
768
 
  bool get_time(DRIZZLE_TIME *ltime);
 
767
  bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
 
768
  bool get_time(MYSQL_TIME *ltime);
769
769
  const char *cast_type() const { return "date"; }
770
770
  enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDATE; }
771
 
  Field *tmp_table_field(Table *table)
 
771
  Field *tmp_table_field(TABLE *table)
772
772
  {
773
773
    return tmp_table_field_from_field_type(table, 0);
774
774
  }  
800
800
  Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
801
801
  const char *func_name() const { return "cast_as_time"; }
802
802
  String *val_str(String *str);
803
 
  bool get_time(DRIZZLE_TIME *ltime);
 
803
  bool get_time(MYSQL_TIME *ltime);
804
804
  const char *cast_type() const { return "time"; }
805
805
  enum_field_types field_type() const { return DRIZZLE_TYPE_TIME; }
806
 
  Field *tmp_table_field(Table *table)
 
806
  Field *tmp_table_field(TABLE *table)
807
807
  {
808
808
    return tmp_table_field_from_field_type(table, 0);
809
809
  }
831
831
  String *val_str(String *str);
832
832
  const char *cast_type() const { return "datetime"; }
833
833
  enum_field_types field_type() const { return DRIZZLE_TYPE_DATETIME; }
834
 
  Field *tmp_table_field(Table *table)
 
834
  Field *tmp_table_field(TABLE *table)
835
835
  {
836
836
    return tmp_table_field_from_field_type(table, 0);
837
837
  }
887
887
  enum_field_types field_type() const { return cached_field_type; }
888
888
  void fix_length_and_dec();
889
889
 
890
 
  Field *tmp_table_field(Table *table)
 
890
  Field *tmp_table_field(TABLE *table)
891
891
  {
892
892
    return tmp_table_field_from_field_type(table, 0);
893
893
  }
1005
1005
    :Item_str_func(a, b), const_item(false)
1006
1006
  {}
1007
1007
  String *val_str(String *str);
1008
 
  bool get_date(DRIZZLE_TIME *ltime, uint fuzzy_date);
 
1008
  bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
1009
1009
  const char *func_name() const { return "str_to_date"; }
1010
1010
  enum_field_types field_type() const { return cached_field_type; }
1011
1011
  void fix_length_and_dec();
1012
 
  Field *tmp_table_field(Table *table)
 
1012
  Field *tmp_table_field(TABLE *table)
1013
1013
  {
1014
1014
    return tmp_table_field_from_field_type(table, 1);
1015
1015
  }
1021
1021
public:
1022
1022
  Item_func_last_day(Item *a) :Item_date(a) {}
1023
1023
  const char *func_name() const { return "last_day"; }
1024
 
  bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
 
1024
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
1025
1025
};