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


Public Member Functions | |
| Item_func_date_format (Item *a, Item *b, bool is_time_format_arg) | |
| String * | val_str (String *str) |
| const char * | func_name () const |
| void | fix_length_and_dec () |
| uint | format_length (const String *format) |
| bool | eq (const Item *item, bool binary_cmp) const |
| bool | check_partition_func_processor (byte *bool_arg) |
Private Attributes | |
| int | fixed_length |
| const bool | is_time_format |
| String | value |
Definition at line 552 of file item_timefunc.h.
| Item_func_date_format::Item_func_date_format | ( | Item * | a, | |
| Item * | b, | |||
| bool | is_time_format_arg | |||
| ) | [inline] |
Definition at line 558 of file item_timefunc.h.
00559 :Item_str_func(a,b),is_time_format(is_time_format_arg) {}
Reimplemented from Item_func.
Definition at line 1624 of file item_timefunc.cc.
References Item_func::args, Item::FUNC_ITEM, func_name(), and Item::type().
01625 { 01626 Item_func_date_format *item_func; 01627 01628 if (item->type() != FUNC_ITEM) 01629 return 0; 01630 if (func_name() != ((Item_func*) item)->func_name()) 01631 return 0; 01632 if (this == item) 01633 return 1; 01634 item_func= (Item_func_date_format*) item; 01635 if (!args[0]->eq(item_func->args[0], binary_cmp)) 01636 return 0; 01637 /* 01638 We must compare format string case sensitive. 01639 This needed because format modifiers with different case, 01640 for example %m and %M, have different meaning. 01641 */ 01642 if (!args[1]->eq(item_func->args[1], 1)) 01643 return 0; 01644 return 1; 01645 }
Here is the call graph for this function:

| void Item_func_date_format::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 1593 of file item_timefunc.cc.
References Item_func::args, Item::collation, Item::decimals, fixed_length, format_length(), MAX_BLOB_WIDTH, Item::max_length, Item::maybe_null, min, my_charset_bin, DTCollation::set(), set_if_smaller, Item::str_value, Item::STRING_ITEM, Item::this_item(), and Item::type().
01594 { 01595 /* 01596 Must use this_item() in case it's a local SP variable 01597 (for ->max_length and ->str_value) 01598 */ 01599 Item *arg1= args[1]->this_item(); 01600 01601 decimals=0; 01602 collation.set(&my_charset_bin); 01603 if (arg1->type() == STRING_ITEM) 01604 { // Optimize the normal case 01605 fixed_length=1; 01606 01607 /* 01608 The result is a binary string (no reason to use collation->mbmaxlen 01609 This is becasue make_date_time() only returns binary strings 01610 */ 01611 max_length= format_length(&arg1->str_value); 01612 } 01613 else 01614 { 01615 fixed_length=0; 01616 /* The result is a binary string (no reason to use collation->mbmaxlen */ 01617 max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10; 01618 set_if_smaller(max_length,MAX_BLOB_WIDTH); 01619 } 01620 maybe_null=1; // If wrong date 01621 }
Here is the call graph for this function:

Definition at line 1649 of file item_timefunc.cc.
References format().
Referenced by fix_length_and_dec(), and val_str().
01650 { 01651 uint size=0; 01652 const char *ptr=format->ptr(); 01653 const char *end=ptr+format->length(); 01654 01655 for (; ptr != end ; ptr++) 01656 { 01657 if (*ptr != '%' || ptr == end-1) 01658 size++; 01659 else 01660 { 01661 switch(*++ptr) { 01662 case 'M': /* month, textual */ 01663 case 'W': /* day (of the week), textual */ 01664 size += 64; /* large for UTF8 locale data */ 01665 break; 01666 case 'D': /* day (of the month), numeric plus english suffix */ 01667 case 'Y': /* year, numeric, 4 digits */ 01668 case 'x': /* Year, used with 'v' */ 01669 case 'X': /* Year, used with 'v, where week starts with Monday' */ 01670 size += 4; 01671 break; 01672 case 'a': /* locale's abbreviated weekday name (Sun..Sat) */ 01673 case 'b': /* locale's abbreviated month name (Jan.Dec) */ 01674 size += 32; /* large for UTF8 locale data */ 01675 break; 01676 case 'j': /* day of year (001..366) */ 01677 size += 3; 01678 break; 01679 case 'U': /* week (00..52) */ 01680 case 'u': /* week (00..52), where week starts with Monday */ 01681 case 'V': /* week 1..53 used with 'x' */ 01682 case 'v': /* week 1..53 used with 'x', where week starts with Monday */ 01683 case 'y': /* year, numeric, 2 digits */ 01684 case 'm': /* month, numeric */ 01685 case 'd': /* day (of the month), numeric */ 01686 case 'h': /* hour (01..12) */ 01687 case 'I': /* --||-- */ 01688 case 'i': /* minutes, numeric */ 01689 case 'l': /* hour ( 1..12) */ 01690 case 'p': /* locale's AM or PM */ 01691 case 'S': /* second (00..61) */ 01692 case 's': /* seconds, numeric */ 01693 case 'c': /* month (0..12) */ 01694 case 'e': /* day (0..31) */ 01695 size += 2; 01696 break; 01697 case 'k': /* hour ( 0..23) */ 01698 case 'H': /* hour (00..23; value > 23 OK, padding always 2-digit) */ 01699 size += 7; /* docs allow > 23, range depends on sizeof(unsigned int) */ 01700 break; 01701 case 'r': /* time, 12-hour (hh:mm:ss [AP]M) */ 01702 size += 11; 01703 break; 01704 case 'T': /* time, 24-hour (hh:mm:ss) */ 01705 size += 8; 01706 break; 01707 case 'f': /* microseconds */ 01708 size += 6; 01709 break; 01710 case 'w': /* day (of the week), numeric */ 01711 case '%': 01712 default: 01713 size++; 01714 break; 01715 } 01716 } 01717 } 01718 return size; 01719 }
Here is the call graph for this function:

Here is the caller graph for this function:

| const char* Item_func_date_format::func_name | ( | ) | const [inline, virtual] |
Implements Item_func.
Definition at line 561 of file item_timefunc.h.
References is_time_format.
Referenced by eq().
00562 { return is_time_format ? "time_format" : "date_format"; }
Here is the caller graph for this function:

Implements Item.
Definition at line 1722 of file item_timefunc.cc.
References String::alloc(), Item_func::args, st_mysql_time::day, DBUG_ASSERT, Item::fixed, fixed_length, format(), format_length(), Item_func::get_arg0_date(), is_time_format, String::length(), make_date_time(), Item::max_length, st_mysql_time::month, MYSQL_TIMESTAMP_DATE, MYSQL_TIMESTAMP_TIME, Item::null_value, String::ptr(), str_to_time_with_warn(), TIME_FUZZY_DATE, value, and st_mysql_time::year.
01723 { 01724 String *format; 01725 TIME l_time; 01726 uint size; 01727 DBUG_ASSERT(fixed == 1); 01728 01729 if (!is_time_format) 01730 { 01731 if (get_arg0_date(&l_time, TIME_FUZZY_DATE)) 01732 return 0; 01733 } 01734 else 01735 { 01736 String *res; 01737 if (!(res=args[0]->val_str(str)) || 01738 (str_to_time_with_warn(res->ptr(), res->length(), &l_time))) 01739 goto null_date; 01740 01741 l_time.year=l_time.month=l_time.day=0; 01742 null_value=0; 01743 } 01744 01745 if (!(format = args[1]->val_str(str)) || !format->length()) 01746 goto null_date; 01747 01748 if (fixed_length) 01749 size=max_length; 01750 else 01751 size=format_length(format); 01752 if (format == str) 01753 str= &value; // Save result here 01754 if (str->alloc(size)) 01755 goto null_date; 01756 01757 DATE_TIME_FORMAT date_time_format; 01758 date_time_format.format.str= (char*) format->ptr(); 01759 date_time_format.format.length= format->length(); 01760 01761 /* Create the result string */ 01762 if (!make_date_time(&date_time_format, &l_time, 01763 is_time_format ? MYSQL_TIMESTAMP_TIME : 01764 MYSQL_TIMESTAMP_DATE, 01765 str)) 01766 return str; 01767 01768 null_date: 01769 null_value=1; 01770 return 0; 01771 }
Here is the call graph for this function:

int Item_func_date_format::fixed_length [private] |
const bool Item_func_date_format::is_time_format [private] |
String Item_func_date_format::value [private] |
1.4.7

