35
35
#include <drizzled/sql_locale.h>
36
36
#include <drizzled/session.h>
38
/** Day number for Dec 31st, 9999. */
39
#define MAX_DAY_NUMBER 3652424L
44
- Replace the switch with a function that should be called for each
46
- Remove sprintf and opencode the conversion, like we do in
49
The reason for this functions existence is that as we don't have a
50
way to know if a datetime/time value has microseconds in them
51
we are now only adding microseconds to the output if the
52
value has microseconds.
54
We can't use a standard make_date_time() for this as we don't know
55
if someone will use %f in the format specifier in which case we would get
56
the microseconds twice.
59
static bool make_datetime(date_time_format_types format, DRIZZLE_TIME *ltime,
63
const CHARSET_INFO * const cs= &my_charset_bin;
64
uint32_t length= MAX_DATE_STRING_REP_LENGTH;
66
if (str->alloc(length))
68
buff= (char*) str->ptr();
72
length= cs->cset->snprintf(cs, buff, length, "%s%02d:%02d:%02d",
73
ltime->neg ? "-" : "",
74
ltime->hour, ltime->minute, ltime->second);
76
case TIME_MICROSECOND:
77
length= cs->cset->snprintf(cs, buff, length, "%s%02d:%02d:%02d.%06ld",
78
ltime->neg ? "-" : "",
79
ltime->hour, ltime->minute, ltime->second,
83
length= cs->cset->snprintf(cs, buff, length, "%04d-%02d-%02d",
84
ltime->year, ltime->month, ltime->day);
87
length= cs->cset->snprintf(cs, buff, length,
88
"%04d-%02d-%02d %02d:%02d:%02d",
89
ltime->year, ltime->month, ltime->day,
90
ltime->hour, ltime->minute, ltime->second);
92
case DATE_TIME_MICROSECOND:
93
length= cs->cset->snprintf(cs, buff, length,
94
"%04d-%02d-%02d %02d:%02d:%02d.%06ld",
95
ltime->year, ltime->month, ltime->day,
96
ltime->hour, ltime->minute, ltime->second,
102
str->set_charset(cs);
108
Wrapper over make_datetime() with validation of the input DRIZZLE_TIME value
111
see make_datetime() for more information
114
1 if there was an error during converion
118
static bool make_datetime_with_warn(date_time_format_types format, DRIZZLE_TIME *ltime,
123
if (make_datetime(format, ltime, str))
125
if (check_time_range(ltime, &warning))
130
make_truncated_value_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
131
str->ptr(), str->length(),
132
DRIZZLE_TIMESTAMP_TIME, NULL);
133
return make_datetime(format, ltime, str);
138
Wrapper over make_time() with validation of the input DRIZZLE_TIME value
141
see make_time() for more info
144
1 if there was an error during conversion
148
static bool make_time_with_warn(const DATE_TIME_FORMAT *format,
149
DRIZZLE_TIME *l_time, String *str)
152
make_time(format, l_time, str);
153
if (check_time_range(l_time, &warning))
157
make_truncated_value_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
158
str->ptr(), str->length(),
159
DRIZZLE_TIMESTAMP_TIME, NULL);
160
make_time(format, l_time, str);
168
Convert seconds to DRIZZLE_TIME value with overflow checking
172
seconds number of seconds
173
unsigned_flag 1, if 'seconds' is unsigned, 0, otherwise
174
ltime output DRIZZLE_TIME value
177
If the 'seconds' argument is inside DRIZZLE_TIME data range, convert it to a
179
Otherwise, truncate the resulting value to the nearest endpoint, and
180
produce a warning message.
183
1 if the value was truncated during conversion
187
static bool sec_to_time(int64_t seconds, bool unsigned_flag, DRIZZLE_TIME *ltime)
191
memset(ltime, 0, sizeof(*ltime));
196
if (seconds < -3020399)
200
else if (seconds > 3020399)
203
sec= (uint) ((uint64_t) seconds % 3600);
204
ltime->hour= (uint) (seconds/3600);
205
ltime->minute= sec/60;
206
ltime->second= sec % 60;
211
ltime->hour= TIME_MAX_HOUR;
212
ltime->minute= TIME_MAX_MINUTE;
213
ltime->second= TIME_MAX_SECOND;
216
int len= (int)(int64_t10_to_str(seconds, buf, unsigned_flag ? 10 : -10)
218
make_truncated_value_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
219
buf, len, DRIZZLE_TIMESTAMP_TIME,
227
39
Date formats corresponding to compound %r and %T conversion specifiers
1054
String *Item_func_sec_to_time::val_str(String *str)
1058
int64_t arg_val= args[0]->val_int();
1060
if ((null_value=args[0]->null_value) ||
1061
str->alloc(MAX_DATE_STRING_REP_LENGTH))
1067
sec_to_time(arg_val, args[0]->unsigned_flag, <ime);
1069
make_time((DATE_TIME_FORMAT *) 0, <ime, str);
1074
int64_t Item_func_sec_to_time::val_int()
1078
int64_t arg_val= args[0]->val_int();
1080
if ((null_value=args[0]->null_value))
1083
sec_to_time(arg_val, args[0]->unsigned_flag, <ime);
1085
return (ltime.neg ? -1 : 1) *
1086
((ltime.hour)*10000 + ltime.minute*100 + ltime.second);
1090
void Item_func_date_format::fix_length_and_dec()
1092
Session* session= current_session;
1094
Must use this_item() in case it's a local SP variable
1095
(for ->max_length and ->str_value)
1097
Item *arg1= args[1]->this_item();
1100
const CHARSET_INFO * const cs= session->variables.collation_connection;
1101
uint32_t repertoire= arg1->collation.repertoire;
1102
if (!session->variables.lc_time_names->is_ascii)
1103
repertoire|= MY_REPERTOIRE_EXTENDED;
1104
collation.set(cs, arg1->collation.derivation, repertoire);
1105
if (arg1->type() == STRING_ITEM)
1106
{ // Optimize the normal case
1108
max_length= format_length(&arg1->str_value) *
1109
collation.collation->mbmaxlen;
1114
max_length=cmin(arg1->max_length,(uint32_t) MAX_BLOB_WIDTH) * 10 *
1115
collation.collation->mbmaxlen;
1116
set_if_smaller(max_length,MAX_BLOB_WIDTH);
1118
maybe_null=1; // If wrong date
1122
bool Item_func_date_format::eq(const Item *item, bool binary_cmp) const
1124
Item_func_date_format *item_func;
1126
if (item->type() != FUNC_ITEM)
1128
if (func_name() != ((Item_func*) item)->func_name())
1132
item_func= (Item_func_date_format*) item;
1133
if (!args[0]->eq(item_func->args[0], binary_cmp))
1136
We must compare format string case sensitive.
1137
This needed because format modifiers with different case,
1138
for example %m and %M, have different meaning.
1140
if (!args[1]->eq(item_func->args[1], 1))
1147
uint32_t Item_func_date_format::format_length(const String *format)
1150
const char *ptr=format->ptr();
1151
const char *end=ptr+format->length();
1153
for (; ptr != end ; ptr++)
1155
if (*ptr != '%' || ptr == end-1)
1160
case 'M': /* month, textual */
1161
case 'W': /* day (of the week), textual */
1162
size += 64; /* large for UTF8 locale data */
1164
case 'D': /* day (of the month), numeric plus english suffix */
1165
case 'Y': /* year, numeric, 4 digits */
1166
case 'x': /* Year, used with 'v' */
1167
case 'X': /* Year, used with 'v, where week starts with Monday' */
1170
case 'a': /* locale's abbreviated weekday name (Sun..Sat) */
1171
case 'b': /* locale's abbreviated month name (Jan.Dec) */
1172
size += 32; /* large for UTF8 locale data */
1174
case 'j': /* day of year (001..366) */
1177
case 'U': /* week (00..52) */
1178
case 'u': /* week (00..52), where week starts with Monday */
1179
case 'V': /* week 1..53 used with 'x' */
1180
case 'v': /* week 1..53 used with 'x', where week starts with Monday */
1181
case 'y': /* year, numeric, 2 digits */
1182
case 'm': /* month, numeric */
1183
case 'd': /* day (of the month), numeric */
1184
case 'h': /* hour (01..12) */
1185
case 'I': /* --||-- */
1186
case 'i': /* minutes, numeric */
1187
case 'l': /* hour ( 1..12) */
1188
case 'p': /* locale's AM or PM */
1189
case 'S': /* second (00..61) */
1190
case 's': /* seconds, numeric */
1191
case 'c': /* month (0..12) */
1192
case 'e': /* day (0..31) */
1195
case 'k': /* hour ( 0..23) */
1196
case 'H': /* hour (00..23; value > 23 OK, padding always 2-digit) */
1197
size += 7; /* docs allow > 23, range depends on sizeof(unsigned int) */
1199
case 'r': /* time, 12-hour (hh:mm:ss [AP]M) */
1202
case 'T': /* time, 24-hour (hh:mm:ss) */
1205
case 'f': /* microseconds */
1208
case 'w': /* day (of the week), numeric */
1220
String *Item_func_date_format::val_str(String *str)
1223
DRIZZLE_TIME l_time;
1227
if (!is_time_format)
1229
if (get_arg0_date(&l_time, TIME_FUZZY_DATE))
1235
if (!(res=args[0]->val_str(str)) ||
1236
(str_to_time_with_warn(res->ptr(), res->length(), &l_time)))
1239
l_time.year=l_time.month=l_time.day=0;
1243
if (!(format = args[1]->val_str(str)) || !format->length())
1249
size=format_length(format);
1251
if (size < MAX_DATE_STRING_REP_LENGTH)
1252
size= MAX_DATE_STRING_REP_LENGTH;
1255
str= &value; // Save result here
1256
if (str->alloc(size))
1259
DATE_TIME_FORMAT date_time_format;
1260
date_time_format.format.str= (char*) format->ptr();
1261
date_time_format.format.length= format->length();
1263
/* Create the result string */
1264
str->set_charset(collation.collation);
1265
if (!make_date_time(&date_time_format, &l_time,
1266
is_time_format ? DRIZZLE_TIMESTAMP_TIME :
1267
DRIZZLE_TIMESTAMP_DATE,
1277
void Item_func_from_unixtime::fix_length_and_dec()
1279
session= current_session;
1280
collation.set(&my_charset_bin);
1281
decimals= DATETIME_DEC;
1282
max_length=MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
1284
session->time_zone_used= 1;
1288
String *Item_func_from_unixtime::val_str(String *str)
1290
DRIZZLE_TIME time_tmp;
1294
if (get_date(&time_tmp, 0))
1297
if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
1303
make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str);
1309
int64_t Item_func_from_unixtime::val_int()
1311
DRIZZLE_TIME time_tmp;
1315
if (get_date(&time_tmp, 0))
1318
return (int64_t) TIME_to_uint64_t_datetime(&time_tmp);
1321
bool Item_func_from_unixtime::get_date(DRIZZLE_TIME *ltime,
1322
uint32_t fuzzy_date __attribute__((unused)))
1324
uint64_t tmp= (uint64_t)(args[0]->val_int());
1326
"tmp > TIMESTAMP_MAX_VALUE" check also covers case of negative
1327
from_unixtime() argument since tmp is unsigned.
1329
if ((null_value= (args[0]->null_value || tmp > TIMESTAMP_MAX_VALUE)))
1332
session->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)tmp);
1338
866
void Item_date_add_interval::fix_length_and_dec()
1340
868
enum_field_types arg0_field_type;
1868
MAKEDATE(a,b) is a date function that creates a date value
1869
from a year and day value.
1872
As arguments are integers, we can't know if the year is a 2 digit or 4 digit year.
1873
In this case we treat all years < 100 as 2 digit years. Ie, this is not safe
1874
for dates between 0000-01-01 and 0099-12-31
1877
String *Item_func_makedate::val_str(String *str)
1880
DRIZZLE_TIME l_time;
1881
long daynr= (long) args[1]->val_int();
1882
long year= (long) args[0]->val_int();
1885
if (args[0]->null_value || args[1]->null_value ||
1886
year < 0 || daynr <= 0)
1890
year= year_2000_handling(year);
1892
days= calc_daynr(year,1,1) + daynr - 1;
1893
/* Day number from year 0 to 9999-12-31 */
1894
if (days >= 0 && days <= MAX_DAY_NUMBER)
1897
get_date_from_daynr(days,&l_time.year,&l_time.month,&l_time.day);
1898
if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
1900
make_date((DATE_TIME_FORMAT *) 0, &l_time, str);
1911
MAKEDATE(a,b) is a date function that creates a date value
1912
from a year and day value.
1915
As arguments are integers, we can't know if the year is a 2 digit or 4 digit year.
1916
In this case we treat all years < 100 as 2 digit years. Ie, this is not safe
1917
for dates between 0000-01-01 and 0099-12-31
1920
int64_t Item_func_makedate::val_int()
1923
DRIZZLE_TIME l_time;
1924
long daynr= (long) args[1]->val_int();
1925
long year= (long) args[0]->val_int();
1928
if (args[0]->null_value || args[1]->null_value ||
1929
year < 0 || daynr <= 0)
1933
year= year_2000_handling(year);
1935
days= calc_daynr(year,1,1) + daynr - 1;
1936
/* Day number from year 0 to 9999-12-31 */
1937
if (days >= 0 && days < MAX_DAY_NUMBER)
1940
get_date_from_daynr(days,&l_time.year,&l_time.month,&l_time.day);
1941
return (int64_t) (l_time.year * 10000L + l_time.month * 100 + l_time.day);
1950
void Item_func_add_time::fix_length_and_dec()
1952
enum_field_types arg0_field_type;
1954
max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
1958
The field type for the result of an Item_func_add_time function is defined
1961
- If first arg is a DRIZZLE_TYPE_DATETIME or DRIZZLE_TYPE_TIMESTAMP
1962
result is DRIZZLE_TYPE_DATETIME
1963
- If first arg is a DRIZZLE_TYPE_TIME result is DRIZZLE_TYPE_TIME
1964
- Otherwise the result is DRIZZLE_TYPE_VARCHAR
1967
cached_field_type= DRIZZLE_TYPE_VARCHAR;
1968
arg0_field_type= args[0]->field_type();
1969
if (arg0_field_type == DRIZZLE_TYPE_DATE ||
1970
arg0_field_type == DRIZZLE_TYPE_DATETIME ||
1971
arg0_field_type == DRIZZLE_TYPE_TIMESTAMP)
1972
cached_field_type= DRIZZLE_TYPE_DATETIME;
1973
else if (arg0_field_type == DRIZZLE_TYPE_TIME)
1974
cached_field_type= DRIZZLE_TYPE_TIME;
1978
ADDTIME(t,a) and SUBTIME(t,a) are time functions that calculate a
1981
t: time_or_datetime_expression
1984
Result: Time value or datetime value
1987
String *Item_func_add_time::val_str(String *str)
1990
DRIZZLE_TIME l_time1, l_time2, l_time3;
1992
long days, microseconds;
1997
if (is_date) // TIMESTAMP function
1999
if (get_arg0_date(&l_time1, TIME_FUZZY_DATE) ||
2000
args[1]->get_time(&l_time2) ||
2001
l_time1.time_type == DRIZZLE_TIMESTAMP_TIME ||
2002
l_time2.time_type != DRIZZLE_TIMESTAMP_TIME)
2005
else // ADDTIME function
2007
if (args[0]->get_time(&l_time1) ||
2008
args[1]->get_time(&l_time2) ||
2009
l_time2.time_type == DRIZZLE_TIMESTAMP_DATETIME)
2011
is_time= (l_time1.time_type == DRIZZLE_TIMESTAMP_TIME);
2013
if (l_time1.neg != l_time2.neg)
2016
memset(&l_time3, 0, sizeof(l_time3));
2018
l_time3.neg= calc_time_diff(&l_time1, &l_time2, -l_sign,
2019
&seconds, µseconds);
2022
If first argument was negative and diff between arguments
2023
is non-zero we need to swap sign to get proper result.
2025
if (l_time1.neg && (seconds || microseconds))
2026
l_time3.neg= 1-l_time3.neg; // Swap sign of result
2028
if (!is_time && l_time3.neg)
2031
days= (long)(seconds/86400L);
2033
calc_time_from_sec(&l_time3, (long)(seconds%86400L), microseconds);
2037
get_date_from_daynr(days,&l_time3.year,&l_time3.month,&l_time3.day);
2039
!make_datetime(l_time1.second_part || l_time2.second_part ?
2040
DATE_TIME_MICROSECOND : DATE_TIME,
2046
l_time3.hour+= days*24;
2047
if (!make_datetime_with_warn(l_time1.second_part || l_time2.second_part ?
2048
TIME_MICROSECOND : TIME_ONLY,
2058
void Item_func_add_time::print(String *str, enum_query_type query_type)
2063
str->append(STRING_WITH_LEN("timestamp("));
2068
str->append(STRING_WITH_LEN("addtime("));
2070
str->append(STRING_WITH_LEN("subtime("));
2072
args[0]->print(str, query_type);
2074
args[1]->print(str, query_type);
2080
TIMEDIFF(t,s) is a time function that calculates the
2081
time value between a start and end time.
2083
t and s: time_or_datetime_expression
2087
String *Item_func_timediff::val_str(String *str)
2093
DRIZZLE_TIME l_time1 ,l_time2, l_time3;
2096
if (args[0]->get_time(&l_time1) ||
2097
args[1]->get_time(&l_time2) ||
2098
l_time1.time_type != l_time2.time_type)
2101
if (l_time1.neg != l_time2.neg)
2104
memset(&l_time3, 0, sizeof(l_time3));
2106
l_time3.neg= calc_time_diff(&l_time1, &l_time2, l_sign,
2107
&seconds, µseconds);
2110
For DRIZZLE_TIMESTAMP_TIME only:
2111
If first argument was negative and diff between arguments
2112
is non-zero we need to swap sign to get proper result.
2114
if (l_time1.neg && (seconds || microseconds))
2115
l_time3.neg= 1-l_time3.neg; // Swap sign of result
2117
calc_time_from_sec(&l_time3, (long) seconds, microseconds);
2119
if (!make_datetime_with_warn(l_time1.second_part || l_time2.second_part ?
2120
TIME_MICROSECOND : TIME_ONLY,
2130
MAKETIME(h,m,s) is a time function that calculates a time value
2131
from the total number of hours, minutes, and seconds.
2135
String *Item_func_maketime::val_str(String *str)
2141
int64_t hour= args[0]->val_int();
2142
int64_t minute= args[1]->val_int();
2143
int64_t second= args[2]->val_int();
2145
if ((null_value=(args[0]->null_value ||
2146
args[1]->null_value ||
2147
args[2]->null_value ||
2148
minute < 0 || minute > 59 ||
2149
second < 0 || second > 59 ||
2150
str->alloc(MAX_DATE_STRING_REP_LENGTH))))
2153
memset(<ime, 0, sizeof(ltime));
2156
/* Check for integer overflows */
2160
if (-hour > UINT_MAX || hour > UINT_MAX)
2165
ltime.hour= (uint) ((hour < 0 ? -hour : hour));
2166
ltime.minute= (uint) minute;
2167
ltime.second= (uint) second;
2171
ltime.hour= TIME_MAX_HOUR;
2172
ltime.minute= TIME_MAX_MINUTE;
2173
ltime.second= TIME_MAX_SECOND;
2175
char *ptr= int64_t10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10);
2176
int len = (int)(ptr - buf) +
2177
sprintf(ptr, ":%02u:%02u", (uint)minute, (uint)second);
2178
make_truncated_value_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2179
buf, len, DRIZZLE_TIMESTAMP_TIME,
2183
if (make_time_with_warn((DATE_TIME_FORMAT *) 0, <ime, str))
2193
MICROSECOND(a) is a function ( extraction) that extracts the microseconds
2196
a: Datetime or time value
2200
int64_t Item_func_microsecond::val_int()
2204
if (!get_arg0_time(<ime))
2205
return ltime.second_part;
2210
int64_t Item_func_timestamp_diff::val_int()
2212
DRIZZLE_TIME ltime1, ltime2;
2219
if (args[0]->get_date(<ime1, TIME_NO_ZERO_DATE) ||
2220
args[1]->get_date(<ime2, TIME_NO_ZERO_DATE))
2223
if (calc_time_diff(<ime2,<ime1, 1,
2224
&seconds, µseconds))
2227
if (int_type == INTERVAL_YEAR ||
2228
int_type == INTERVAL_QUARTER ||
2229
int_type == INTERVAL_MONTH)
2231
uint32_t year_beg, year_end, month_beg, month_end, day_beg, day_end;
2233
uint32_t second_beg, second_end, microsecond_beg, microsecond_end;
2237
year_beg= ltime2.year;
2238
year_end= ltime1.year;
2239
month_beg= ltime2.month;
2240
month_end= ltime1.month;
2241
day_beg= ltime2.day;
2242
day_end= ltime1.day;
2243
second_beg= ltime2.hour * 3600 + ltime2.minute * 60 + ltime2.second;
2244
second_end= ltime1.hour * 3600 + ltime1.minute * 60 + ltime1.second;
2245
microsecond_beg= ltime2.second_part;
2246
microsecond_end= ltime1.second_part;
2250
year_beg= ltime1.year;
2251
year_end= ltime2.year;
2252
month_beg= ltime1.month;
2253
month_end= ltime2.month;
2254
day_beg= ltime1.day;
2255
day_end= ltime2.day;
2256
second_beg= ltime1.hour * 3600 + ltime1.minute * 60 + ltime1.second;
2257
second_end= ltime2.hour * 3600 + ltime2.minute * 60 + ltime2.second;
2258
microsecond_beg= ltime1.second_part;
2259
microsecond_end= ltime2.second_part;
2263
years= year_end - year_beg;
2264
if (month_end < month_beg || (month_end == month_beg && day_end < day_beg))
2269
if (month_end < month_beg || (month_end == month_beg && day_end < day_beg))
2270
months+= 12 - (month_beg - month_end);
2272
months+= (month_end - month_beg);
2274
if (day_end < day_beg)
2276
else if ((day_end == day_beg) &&
2277
((second_end < second_beg) ||
2278
(second_end == second_beg && microsecond_end < microsecond_beg)))
2284
return months/12*neg;
2285
case INTERVAL_QUARTER:
2286
return months/3*neg;
2287
case INTERVAL_MONTH:
2290
return seconds/86400L/7L*neg;
2292
return seconds/86400L*neg;
2294
return seconds/3600L*neg;
2295
case INTERVAL_MINUTE:
2296
return seconds/60L*neg;
2297
case INTERVAL_SECOND:
2299
case INTERVAL_MICROSECOND:
2301
In MySQL difference between any two valid datetime values
2302
in microseconds fits into int64_t.
2304
return (seconds*1000000L+microseconds)*neg;
2315
void Item_func_timestamp_diff::print(String *str, enum_query_type query_type)
2317
str->append(func_name());
2322
str->append(STRING_WITH_LEN("YEAR"));
2324
case INTERVAL_QUARTER:
2325
str->append(STRING_WITH_LEN("QUARTER"));
2327
case INTERVAL_MONTH:
2328
str->append(STRING_WITH_LEN("MONTH"));
2331
str->append(STRING_WITH_LEN("WEEK"));
2334
str->append(STRING_WITH_LEN("DAY"));
2337
str->append(STRING_WITH_LEN("HOUR"));
2339
case INTERVAL_MINUTE:
2340
str->append(STRING_WITH_LEN("MINUTE"));
2342
case INTERVAL_SECOND:
2343
str->append(STRING_WITH_LEN("SECOND"));
2345
case INTERVAL_MICROSECOND:
2346
str->append(STRING_WITH_LEN("SECOND_FRAC"));
2352
for (uint32_t i=0 ; i < 2 ; i++)
2355
args[i]->print(str, query_type);
2361
String *Item_func_get_format::val_str(String *str)
2364
const char *format_name;
2365
KNOWN_DATE_TIME_FORMAT *format;
2366
String *val= args[0]->val_str(str);
2369
if ((null_value= args[0]->null_value))
2372
val_len= val->length();
2373
for (format= &known_date_time_formats[0];
2374
(format_name= format->format_name);
2377
uint32_t format_name_len;
2378
format_name_len= strlen(format_name);
2379
if (val_len == format_name_len &&
2380
!my_strnncoll(&my_charset_utf8_general_ci,
2381
(const unsigned char *) val->ptr(), val_len,
2382
(const unsigned char *) format_name, val_len))
2384
const char *format_str= get_date_time_format_str(format, type);
2385
str->set(format_str, strlen(format_str), &my_charset_bin);
2395
void Item_func_get_format::print(String *str, enum_query_type query_type)
2397
str->append(func_name());
2401
case DRIZZLE_TIMESTAMP_DATE:
2402
str->append(STRING_WITH_LEN("DATE, "));
2404
case DRIZZLE_TIMESTAMP_DATETIME:
2405
str->append(STRING_WITH_LEN("DATETIME, "));
2407
case DRIZZLE_TIMESTAMP_TIME:
2408
str->append(STRING_WITH_LEN("TIME, "));
2413
args[0]->print(str, query_type);
2419
1396
Get type of datetime value (DATE/TIME/...) which will be produced
2420
1397
according to format string.