#include <field.h>
Inheritance diagram for Field_timestamp:


Public Member Functions | |
| Field_timestamp (char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, TABLE_SHARE *share, CHARSET_INFO *cs) | |
| Field_timestamp (bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) | |
| enum_field_types | type () const |
| enum ha_base_keytype | key_type () const |
| enum Item_result | cmp_type () const |
| int | store (const char *to, uint length, CHARSET_INFO *charset) |
| int | store (double nr) |
| int | store (longlong nr, bool unsigned_val) |
| void | reset (void) |
| double | val_real (void) |
| longlong | val_int (void) |
| String * | val_str (String *, String *) |
| bool | send_binary (Protocol *protocol) |
| int | cmp (const char *, const char *) |
| void | sort_string (char *buff, uint length) |
| uint32 | pack_length () const |
| void | sql_type (String &str) const |
| bool | can_be_compared_as_longlong () const |
| bool | zero_pack () const |
| void | set_time () |
| virtual void | set_default () |
| long | get_timestamp (my_bool *null_value) |
| bool | get_date (TIME *ltime, uint fuzzydate) |
| bool | get_time (TIME *ltime) |
| timestamp_auto_set_type | get_auto_set_type () const |
Definition at line 800 of file field.h.
| Field_timestamp::Field_timestamp | ( | char * | ptr_arg, | |
| uint32 | len_arg, | |||
| uchar * | null_ptr_arg, | |||
| uchar | null_bit_arg, | |||
| enum utype | unireg_check_arg, | |||
| const char * | field_name_arg, | |||
| TABLE_SHARE * | share, | |||
| CHARSET_INFO * | cs | |||
| ) |
Definition at line 4470 of file field.cc.
References Field::flags, Field::NONE, st_table_share::timestamp_field, TIMESTAMP_FLAG, Field::unireg_check, UNSIGNED_FLAG, and ZEROFILL_FLAG.
04476 :Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg, 04477 unireg_check_arg, field_name_arg, cs) 04478 { 04479 /* For 4.0 MYD and 4.0 InnoDB compatibility */ 04480 flags|= ZEROFILL_FLAG | UNSIGNED_FLAG; 04481 if (!share->timestamp_field && unireg_check != NONE) 04482 { 04483 /* This timestamp has auto-update */ 04484 share->timestamp_field= this; 04485 flags|= TIMESTAMP_FLAG; 04486 } 04487 }
| Field_timestamp::Field_timestamp | ( | bool | maybe_null_arg, | |
| const char * | field_name_arg, | |||
| CHARSET_INFO * | cs | |||
| ) |
Definition at line 4490 of file field.cc.
References Field::flags, UNSIGNED_FLAG, and ZEROFILL_FLAG.
04493 :Field_str((char*) 0, 19, maybe_null_arg ? (uchar*) "": 0, 0, 04494 NONE, field_name_arg, cs) 04495 { 04496 /* For 4.0 MYD and 4.0 InnoDB compatibility */ 04497 flags|= ZEROFILL_FLAG | UNSIGNED_FLAG; 04498 }
| bool Field_timestamp::can_be_compared_as_longlong | ( | ) | const [inline, virtual] |
| int Field_timestamp::cmp | ( | const char * | , | |
| const char * | ||||
| ) | [virtual] |
Implements Field.
Definition at line 4806 of file field.cc.
References st_table_share::db_low_byte_first, longget, st_table::s, sint4korr, and Field::table.
04807 { 04808 int32 a,b; 04809 #ifdef WORDS_BIGENDIAN 04810 if (table && table->s->db_low_byte_first) 04811 { 04812 a=sint4korr(a_ptr); 04813 b=sint4korr(b_ptr); 04814 } 04815 else 04816 #endif 04817 { 04818 longget(a,a_ptr); 04819 longget(b,b_ptr); 04820 } 04821 return ((uint32) a < (uint32) b) ? -1 : ((uint32) a > (uint32) b) ? 1 : 0; 04822 }
| enum Item_result Field_timestamp::cmp_type | ( | ) | const [inline, virtual] |
Reimplemented from Field.
Definition at line 810 of file field.h.
References INT_RESULT.
00810 { return INT_RESULT; }
| timestamp_auto_set_type Field_timestamp::get_auto_set_type | ( | ) | const |
Definition at line 4511 of file field.cc.
References DBUG_ASSERT, Field::table, TIMESTAMP_AUTO_SET_ON_BOTH, TIMESTAMP_AUTO_SET_ON_INSERT, TIMESTAMP_AUTO_SET_ON_UPDATE, Field::TIMESTAMP_DN_FIELD, Field::TIMESTAMP_DNUN_FIELD, st_table::timestamp_field, TIMESTAMP_NO_AUTO_SET, Field::TIMESTAMP_OLD_FIELD, Field::TIMESTAMP_UN_FIELD, and Field::unireg_check.
04512 { 04513 switch (unireg_check) 04514 { 04515 case TIMESTAMP_DN_FIELD: 04516 return TIMESTAMP_AUTO_SET_ON_INSERT; 04517 case TIMESTAMP_UN_FIELD: 04518 return TIMESTAMP_AUTO_SET_ON_UPDATE; 04519 case TIMESTAMP_OLD_FIELD: 04520 /* 04521 Although we can have several such columns in legacy tables this 04522 function should be called only for first of them (i.e. the one 04523 having auto-set property). 04524 */ 04525 DBUG_ASSERT(table->timestamp_field == this); 04526 /* Fall-through */ 04527 case TIMESTAMP_DNUN_FIELD: 04528 return TIMESTAMP_AUTO_SET_ON_BOTH; 04529 default: 04530 /* 04531 Normally this function should not be called for TIMESTAMPs without 04532 auto-set property. 04533 */ 04534 DBUG_ASSERT(0); 04535 return TIMESTAMP_NO_AUTO_SET; 04536 } 04537 }
Reimplemented from Field.
Definition at line 4768 of file field.cc.
References bzero, current_thd, st_table_share::db_low_byte_first, st_table::in_use, longget, st_table::s, Field::table, TIME_NO_ZERO_DATE, and uint4korr.
Referenced by get_time(), and send_binary().
04769 { 04770 long temp; 04771 THD *thd= table ? table->in_use : current_thd; 04772 #ifdef WORDS_BIGENDIAN 04773 if (table && table->s->db_low_byte_first) 04774 temp=uint4korr(ptr); 04775 else 04776 #endif 04777 longget(temp,ptr); 04778 if (temp == 0L) 04779 { /* Zero time is "000000" */ 04780 if (fuzzydate & TIME_NO_ZERO_DATE) 04781 return 1; 04782 bzero((char*) ltime,sizeof(*ltime)); 04783 } 04784 else 04785 { 04786 thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)temp); 04787 thd->time_zone_used= 1; 04788 } 04789 return 0; 04790 }
Here is the caller graph for this function:

Reimplemented from Field.
Definition at line 4792 of file field.cc.
References get_date().
04793 { 04794 return Field_timestamp::get_date(ltime,0); 04795 }
Here is the call graph for this function:

| long Field_timestamp::get_timestamp | ( | my_bool * | null_value | ) | [inline] |
Definition at line 835 of file field.h.
References st_table_share::db_low_byte_first, Field::is_null(), longget, Field::ptr, st_table::s, sint4korr, and Field::table.
00836 { 00837 if ((*null_value= is_null())) 00838 return 0; 00839 #ifdef WORDS_BIGENDIAN 00840 if (table && table->s->db_low_byte_first) 00841 return sint4korr(ptr); 00842 #endif 00843 long tmp; 00844 longget(tmp,ptr); 00845 return tmp; 00846 }
Here is the call graph for this function:

| enum ha_base_keytype Field_timestamp::key_type | ( | ) | const [inline, virtual] |
Reimplemented from Field.
Definition at line 809 of file field.h.
References HA_KEYTYPE_ULONG_INT.
00809 { return HA_KEYTYPE_ULONG_INT; }
| uint32 Field_timestamp::pack_length | ( | ) | const [inline, virtual] |
| void Field_timestamp::reset | ( | void | ) | [inline, virtual] |
Reimplemented from Field.
Definition at line 4798 of file field.cc.
References get_date(), and Protocol::store().
04799 { 04800 TIME tm; 04801 Field_timestamp::get_date(&tm, 0); 04802 return protocol->store(&tm); 04803 }
Here is the call graph for this function:

| virtual void Field_timestamp::set_default | ( | ) | [inline, virtual] |
Reimplemented from Field.
Definition at line 826 of file field.h.
References Field::set_default(), set_time(), Field::table, st_table::timestamp_field, Field::TIMESTAMP_UN_FIELD, and Field::unireg_check.
00827 { 00828 if (table->timestamp_field == this && 00829 unireg_check != TIMESTAMP_UN_FIELD) 00830 set_time(); 00831 else 00832 Field::set_default(); 00833 }
Here is the call graph for this function:

| void Field_timestamp::set_time | ( | ) |
Definition at line 4852 of file field.cc.
References current_thd, st_table_share::db_low_byte_first, st_table::in_use, int4store, longstore, st_table::s, Field::set_notnull(), and Field::table.
Referenced by set_default(), ha_tina::update_row(), ha_myisammrg::update_row(), ha_myisam::update_row(), ha_heap::update_row(), ha_tina::write_row(), ha_archive::write_row(), ha_myisammrg::write_row(), ha_myisam::write_row(), and ha_heap::write_row().
04853 { 04854 THD *thd= table ? table->in_use : current_thd; 04855 long tmp= (long) thd->query_start(); 04856 set_notnull(); 04857 #ifdef WORDS_BIGENDIAN 04858 if (table && table->s->db_low_byte_first) 04859 { 04860 int4store(ptr,tmp); 04861 } 04862 else 04863 #endif 04864 longstore(ptr,tmp); 04865 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void Field_timestamp::sql_type | ( | String & | str | ) | const [virtual] |
Implements Field.
Definition at line 4846 of file field.cc.
References String::set_ascii(), and STRING_WITH_LEN.
04847 { 04848 res.set_ascii(STRING_WITH_LEN("timestamp")); 04849 }
Here is the call graph for this function:

Implements Field_str.
Definition at line 4611 of file field.cc.
References ASSERT_COLUMN_MARKED_FOR_WRITE, current_thd, st_table_share::db_low_byte_first, ER_WARN_INVALID_TIMESTAMP, st_table::in_use, int4store, LL, longstore, MODE_NO_ZERO_DATE, MODE_NO_ZERO_IN_DATE, MYSQL_TIMESTAMP_DATETIME, number_to_datetime(), st_table::s, Field::set_datetime_warning(), Field::table, TIME_to_timestamp(), WARN_DATA_TRUNCATED, and MYSQL_ERROR::WARN_LEVEL_WARN.
04612 { 04613 ASSERT_COLUMN_MARKED_FOR_WRITE; 04614 TIME l_time; 04615 my_time_t timestamp= 0; 04616 int error; 04617 my_bool in_dst_time_gap; 04618 THD *thd= table ? table->in_use : current_thd; 04619 04620 /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */ 04621 longlong tmp= number_to_datetime(nr, &l_time, (thd->variables.sql_mode & 04622 MODE_NO_ZERO_DATE) | 04623 MODE_NO_ZERO_IN_DATE, &error); 04624 if (tmp == LL(-1)) 04625 { 04626 error= 2; 04627 } 04628 04629 if (!error && tmp) 04630 { 04631 if (!(timestamp= TIME_to_timestamp(thd, &l_time, &in_dst_time_gap))) 04632 { 04633 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 04634 ER_WARN_DATA_OUT_OF_RANGE, 04635 nr, MYSQL_TIMESTAMP_DATETIME, 1); 04636 error= 1; 04637 } 04638 if (in_dst_time_gap) 04639 { 04640 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 04641 ER_WARN_INVALID_TIMESTAMP, 04642 nr, MYSQL_TIMESTAMP_DATETIME, 1); 04643 error= 1; 04644 } 04645 } else if (error) 04646 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 04647 WARN_DATA_TRUNCATED, 04648 nr, MYSQL_TIMESTAMP_DATETIME, 1); 04649 04650 #ifdef WORDS_BIGENDIAN 04651 if (table && table->s->db_low_byte_first) 04652 { 04653 int4store(ptr,timestamp); 04654 } 04655 else 04656 #endif 04657 longstore(ptr,(uint32) timestamp); 04658 04659 return error; 04660 }
Here is the call graph for this function:

| int Field_timestamp::store | ( | double | nr | ) | [virtual] |
Reimplemented from Field_str.
Definition at line 4595 of file field.cc.
References FALSE, MYSQL_TIMESTAMP_DATETIME, rint, Field::set_datetime_warning(), store(), and MYSQL_ERROR::WARN_LEVEL_WARN.
04596 { 04597 int error= 0; 04598 if (nr < 0 || nr > 99991231235959.0) 04599 { 04600 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 04601 ER_WARN_DATA_OUT_OF_RANGE, 04602 nr, MYSQL_TIMESTAMP_DATETIME); 04603 nr= 0; // Avoid overflow on buff 04604 error= 1; 04605 } 04606 error|= Field_timestamp::store((longlong) rint(nr), FALSE); 04607 return error; 04608 }
Here is the call graph for this function:

| int Field_timestamp::store | ( | const char * | to, | |
| uint | length, | |||
| CHARSET_INFO * | charset | |||
| ) | [virtual] |
Implements Field_str.
Definition at line 4540 of file field.cc.
References ASSERT_COLUMN_MARKED_FOR_WRITE, current_thd, st_table_share::db_low_byte_first, ER_WARN_INVALID_TIMESTAMP, st_table::in_use, int4store, longstore, MODE_NO_ZERO_DATE, MODE_NO_ZERO_IN_DATE, st_mysql_time::month, MYSQL_TIMESTAMP_DATETIME, MYSQL_TIMESTAMP_ERROR, st_table::s, Field::set_datetime_warning(), str_to_datetime(), Field::table, TIME_to_timestamp(), WARN_DATA_TRUNCATED, and MYSQL_ERROR::WARN_LEVEL_WARN.
Referenced by store().
04541 { 04542 ASSERT_COLUMN_MARKED_FOR_WRITE; 04543 TIME l_time; 04544 my_time_t tmp= 0; 04545 int error; 04546 bool have_smth_to_conv; 04547 my_bool in_dst_time_gap; 04548 THD *thd= table ? table->in_use : current_thd; 04549 04550 /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */ 04551 have_smth_to_conv= (str_to_datetime(from, len, &l_time, 04552 (thd->variables.sql_mode & 04553 MODE_NO_ZERO_DATE) | 04554 MODE_NO_ZERO_IN_DATE, &error) > 04555 MYSQL_TIMESTAMP_ERROR); 04556 04557 if (error || !have_smth_to_conv) 04558 { 04559 error= 1; 04560 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 04561 from, len, MYSQL_TIMESTAMP_DATETIME, 1); 04562 } 04563 04564 /* Only convert a correct date (not a zero date) */ 04565 if (have_smth_to_conv && l_time.month) 04566 { 04567 if (!(tmp= TIME_to_timestamp(thd, &l_time, &in_dst_time_gap))) 04568 { 04569 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 04570 ER_WARN_DATA_OUT_OF_RANGE, 04571 from, len, MYSQL_TIMESTAMP_DATETIME, !error); 04572 error= 1; 04573 } 04574 else if (in_dst_time_gap) 04575 { 04576 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 04577 ER_WARN_INVALID_TIMESTAMP, 04578 from, len, MYSQL_TIMESTAMP_DATETIME, !error); 04579 error= 1; 04580 } 04581 } 04582 04583 #ifdef WORDS_BIGENDIAN 04584 if (table && table->s->db_low_byte_first) 04585 { 04586 int4store(ptr,tmp); 04587 } 04588 else 04589 #endif 04590 longstore(ptr,tmp); 04591 return error; 04592 }
Here is the call graph for this function:

Here is the caller graph for this function:

| enum_field_types Field_timestamp::type | ( | ) | const [inline, virtual] |
Implements Field.
Definition at line 808 of file field.h.
References FIELD_TYPE_TIMESTAMP.
00808 { return FIELD_TYPE_TIMESTAMP;}
| longlong Field_timestamp::val_int | ( | void | ) | [virtual] |
Implements Field.
Definition at line 4669 of file field.cc.
References ASSERT_COLUMN_MARKED_FOR_READ, current_thd, st_mysql_time::day, st_table_share::db_low_byte_first, st_mysql_time::hour, st_table::in_use, LL, longget, st_mysql_time::minute, st_mysql_time::month, st_table::s, st_mysql_time::second, Field::table, uint4korr, and st_mysql_time::year.
Referenced by val_real().
04670 { 04671 ASSERT_COLUMN_MARKED_FOR_READ; 04672 uint32 temp; 04673 TIME time_tmp; 04674 THD *thd= table ? table->in_use : current_thd; 04675 04676 #ifdef WORDS_BIGENDIAN 04677 if (table && table->s->db_low_byte_first) 04678 temp=uint4korr(ptr); 04679 else 04680 #endif 04681 longget(temp,ptr); 04682 04683 if (temp == 0L) // No time 04684 return(0); /* purecov: inspected */ 04685 04686 thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, (my_time_t)temp); 04687 thd->time_zone_used= 1; 04688 04689 return time_tmp.year * LL(10000000000) + time_tmp.month * LL(100000000) + 04690 time_tmp.day * 1000000L + time_tmp.hour * 10000L + 04691 time_tmp.minute * 100 + time_tmp.second; 04692 }
Here is the caller graph for this function:

| double Field_timestamp::val_real | ( | void | ) | [virtual] |
Implements Field.
Definition at line 4663 of file field.cc.
References ASSERT_COLUMN_MARKED_FOR_READ, and val_int().
04664 { 04665 ASSERT_COLUMN_MARKED_FOR_READ; 04666 return (double) Field_timestamp::val_int(); 04667 }
Here is the call graph for this function:

Implements Field.
Definition at line 4695 of file field.cc.
References String::alloc(), ASSERT_COLUMN_MARKED_FOR_READ, current_thd, st_mysql_time::day, st_table_share::db_low_byte_first, Field::field_length, st_mysql_time::hour, st_table::in_use, String::length(), longget, st_mysql_time::minute, st_mysql_time::month, String::ptr(), st_table::s, st_mysql_time::second, String::set(), String::set_charset(), STRING_WITH_LEN, Field::table, uint4korr, st_mysql_time::year, and YY_PART_YEAR.
04696 { 04697 ASSERT_COLUMN_MARKED_FOR_READ; 04698 uint32 temp, temp2; 04699 TIME time_tmp; 04700 THD *thd= table ? table->in_use : current_thd; 04701 char *to; 04702 04703 val_buffer->alloc(field_length+1); 04704 to= (char*) val_buffer->ptr(); 04705 val_buffer->length(field_length); 04706 04707 #ifdef WORDS_BIGENDIAN 04708 if (table && table->s->db_low_byte_first) 04709 temp=uint4korr(ptr); 04710 else 04711 #endif 04712 longget(temp,ptr); 04713 04714 if (temp == 0L) 04715 { /* Zero time is "000000" */ 04716 val_ptr->set(STRING_WITH_LEN("0000-00-00 00:00:00"), &my_charset_bin); 04717 return val_ptr; 04718 } 04719 val_buffer->set_charset(&my_charset_bin); // Safety 04720 04721 thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,(my_time_t)temp); 04722 thd->time_zone_used= 1; 04723 04724 temp= time_tmp.year % 100; 04725 if (temp < YY_PART_YEAR - 1) 04726 { 04727 *to++= '2'; 04728 *to++= '0'; 04729 } 04730 else 04731 { 04732 *to++= '1'; 04733 *to++= '9'; 04734 } 04735 temp2=temp/10; temp=temp-temp2*10; 04736 *to++= (char) ('0'+(char) (temp2)); 04737 *to++= (char) ('0'+(char) (temp)); 04738 *to++= '-'; 04739 temp=time_tmp.month; 04740 temp2=temp/10; temp=temp-temp2*10; 04741 *to++= (char) ('0'+(char) (temp2)); 04742 *to++= (char) ('0'+(char) (temp)); 04743 *to++= '-'; 04744 temp=time_tmp.day; 04745 temp2=temp/10; temp=temp-temp2*10; 04746 *to++= (char) ('0'+(char) (temp2)); 04747 *to++= (char) ('0'+(char) (temp)); 04748 *to++= ' '; 04749 temp=time_tmp.hour; 04750 temp2=temp/10; temp=temp-temp2*10; 04751 *to++= (char) ('0'+(char) (temp2)); 04752 *to++= (char) ('0'+(char) (temp)); 04753 *to++= ':'; 04754 temp=time_tmp.minute; 04755 temp2=temp/10; temp=temp-temp2*10; 04756 *to++= (char) ('0'+(char) (temp2)); 04757 *to++= (char) ('0'+(char) (temp)); 04758 *to++= ':'; 04759 temp=time_tmp.second; 04760 temp2=temp/10; temp=temp-temp2*10; 04761 *to++= (char) ('0'+(char) (temp2)); 04762 *to++= (char) ('0'+(char) (temp)); 04763 *to= 0; 04764 return val_buffer; 04765 }
Here is the call graph for this function:

| bool Field_timestamp::zero_pack | ( | ) | const [inline, virtual] |
1.4.7

