#include <item_timefunc.h>
Inheritance diagram for Item_func_add_time:


Public Member Functions | |
| Item_func_add_time (Item *a, Item *b, bool type_arg, bool neg_arg) | |
| String * | val_str (String *str) |
| enum_field_types | field_type () const |
| void | fix_length_and_dec () |
| Field * | tmp_table_field (TABLE *table) |
| void | print (String *str) |
| const char * | func_name () const |
| bool | check_partition_func_processor (byte *bool_arg) |
Private Attributes | |
| const bool | is_date |
| int | sign |
| enum_field_types | cached_field_type |
Definition at line 836 of file item_timefunc.h.
Definition at line 843 of file item_timefunc.h.
References sign.
00844 :Item_str_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
| enum_field_types Item_func_add_time::field_type | ( | ) | const [inline, virtual] |
Reimplemented from Item.
Definition at line 846 of file item_timefunc.h.
References cached_field_type.
00846 { return cached_field_type; }
| void Item_func_add_time::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 2509 of file item_timefunc.cc.
References Item_func::args, cached_field_type, Item::decimals, Item::field_type(), MAX_DATETIME_FULL_WIDTH, Item::max_length, Item::maybe_null, MY_CHARSET_BIN_MB_MAXLEN, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_STRING, MYSQL_TYPE_TIME, and MYSQL_TYPE_TIMESTAMP.
02510 { 02511 enum_field_types arg0_field_type; 02512 decimals=0; 02513 max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; 02514 maybe_null= 1; 02515 02516 /* 02517 The field type for the result of an Item_func_add_time function is defined 02518 as follows: 02519 02520 - If first arg is a MYSQL_TYPE_DATETIME or MYSQL_TYPE_TIMESTAMP 02521 result is MYSQL_TYPE_DATETIME 02522 - If first arg is a MYSQL_TYPE_TIME result is MYSQL_TYPE_TIME 02523 - Otherwise the result is MYSQL_TYPE_STRING 02524 */ 02525 02526 cached_field_type= MYSQL_TYPE_STRING; 02527 arg0_field_type= args[0]->field_type(); 02528 if (arg0_field_type == MYSQL_TYPE_DATE || 02529 arg0_field_type == MYSQL_TYPE_DATETIME || 02530 arg0_field_type == MYSQL_TYPE_TIMESTAMP) 02531 cached_field_type= MYSQL_TYPE_DATETIME; 02532 else if (arg0_field_type == MYSQL_TYPE_TIME) 02533 cached_field_type= MYSQL_TYPE_TIME; 02534 }
Here is the call graph for this function:

| const char* Item_func_add_time::func_name | ( | ) | const [inline, virtual] |
| void Item_func_add_time::print | ( | String * | str | ) | [virtual] |
Reimplemented from Item_func.
Definition at line 2614 of file item_timefunc.cc.
References String::append(), Item_func::args, DBUG_ASSERT, is_date, Item::print(), sign, and STRING_WITH_LEN.
02615 { 02616 if (is_date) 02617 { 02618 DBUG_ASSERT(sign > 0); 02619 str->append(STRING_WITH_LEN("timestamp(")); 02620 } 02621 else 02622 { 02623 if (sign > 0) 02624 str->append(STRING_WITH_LEN("addtime(")); 02625 else 02626 str->append(STRING_WITH_LEN("subtime(")); 02627 } 02628 args[0]->print(str); 02629 str->append(','); 02630 args[1]->print(str); 02631 str->append(')'); 02632 }
Here is the call graph for this function:

Reimplemented from Item_func.
Definition at line 849 of file item_timefunc.h.
References Item::tmp_table_field_from_field_type().
00850 { 00851 return tmp_table_field_from_field_type(table, 0); 00852 }
Here is the call graph for this function:

Implements Item.
Definition at line 2546 of file item_timefunc.cc.
References Item_func::args, calc_time_diff(), calc_time_from_sec(), DATE_TIME, DATE_TIME_MICROSECOND, st_mysql_time::day, DBUG_ASSERT, Item::fixed, Item_func::get_arg0_date(), get_date_from_daynr(), Item::get_time(), st_mysql_time::hour, is_date, make_datetime(), st_mysql_time::month, MYSQL_TIMESTAMP_DATETIME, MYSQL_TIMESTAMP_TIME, st_mysql_time::neg, Item::null_value, st_mysql_time::second_part, sign, TIME_FUZZY_DATE, TIME_MICROSECOND, TIME_ONLY, st_mysql_time::time_type, and st_mysql_time::year.
02547 { 02548 DBUG_ASSERT(fixed == 1); 02549 TIME l_time1, l_time2, l_time3; 02550 bool is_time= 0; 02551 long days, microseconds; 02552 longlong seconds; 02553 int l_sign= sign; 02554 02555 null_value=0; 02556 if (is_date) // TIMESTAMP function 02557 { 02558 if (get_arg0_date(&l_time1, TIME_FUZZY_DATE) || 02559 args[1]->get_time(&l_time2) || 02560 l_time1.time_type == MYSQL_TIMESTAMP_TIME || 02561 l_time2.time_type != MYSQL_TIMESTAMP_TIME) 02562 goto null_date; 02563 } 02564 else // ADDTIME function 02565 { 02566 if (args[0]->get_time(&l_time1) || 02567 args[1]->get_time(&l_time2) || 02568 l_time2.time_type == MYSQL_TIMESTAMP_DATETIME) 02569 goto null_date; 02570 is_time= (l_time1.time_type == MYSQL_TIMESTAMP_TIME); 02571 } 02572 if (l_time1.neg != l_time2.neg) 02573 l_sign= -l_sign; 02574 02575 l_time3.neg= calc_time_diff(&l_time1, &l_time2, -l_sign, 02576 &seconds, µseconds); 02577 02578 /* 02579 If first argument was negative and diff between arguments 02580 is non-zero we need to swap sign to get proper result. 02581 */ 02582 if (l_time1.neg && (seconds || microseconds)) 02583 l_time3.neg= 1-l_time3.neg; // Swap sign of result 02584 02585 if (!is_time && l_time3.neg) 02586 goto null_date; 02587 02588 days= (long)(seconds/86400L); 02589 02590 calc_time_from_sec(&l_time3, (long)(seconds%86400L), microseconds); 02591 if (!is_time) 02592 { 02593 get_date_from_daynr(days,&l_time3.year,&l_time3.month,&l_time3.day); 02594 if (l_time3.day && 02595 !make_datetime(l_time1.second_part || l_time2.second_part ? 02596 DATE_TIME_MICROSECOND : DATE_TIME, 02597 &l_time3, str)) 02598 return str; 02599 goto null_date; 02600 } 02601 02602 l_time3.hour+= days*24; 02603 if (!make_datetime(l_time1.second_part || l_time2.second_part ? 02604 TIME_MICROSECOND : TIME_ONLY, 02605 &l_time3, str)) 02606 return str; 02607 02608 null_date: 02609 null_value=1; 02610 return 0; 02611 }
Here is the call graph for this function:

Definition at line 840 of file item_timefunc.h.
Referenced by field_type(), and fix_length_and_dec().
const bool Item_func_add_time::is_date [private] |
int Item_func_add_time::sign [private] |
Definition at line 839 of file item_timefunc.h.
Referenced by Item_func_add_time(), print(), and val_str().
1.4.7

