summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-09-12 18:31:12 +0200
committerSergei Golubchik <serg@mariadb.org>2017-09-18 10:12:23 +0200
commit3e5cdfae935d371f155aba6cc32cb22fb19680ea (patch)
tree8c5eee740ab64b5b63064ac0fcb0930999ec84da /sql/item_timefunc.cc
parent3878baddf13efcee656ce2ad970a8326c7305fba (diff)
downloadmariadb-git-3e5cdfae935d371f155aba6cc32cb22fb19680ea.tar.gz
bugfix: TIME_FORMAT() allowed some non-time format specifiers
it contradicted the manual and was inconsistent
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 599d818cf3f..6e476dfa746 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -477,14 +477,14 @@ static bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
{
switch (*++ptr) {
case 'M':
- if (!l_time->month)
+ if (type == MYSQL_TIMESTAMP_TIME || !l_time->month)
return 1;
str->append(locale->month_names->type_names[l_time->month-1],
(uint) strlen(locale->month_names->type_names[l_time->month-1]),
system_charset_info);
break;
case 'b':
- if (!l_time->month)
+ if (type == MYSQL_TIMESTAMP_TIME || !l_time->month)
return 1;
str->append(locale->ab_month_names->type_names[l_time->month-1],
(uint) strlen(locale->ab_month_names->type_names[l_time->month-1]),
@@ -534,26 +534,38 @@ static bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
}
break;
case 'Y':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->year, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 4, '0');
break;
case 'y':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->year%100, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'm':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->month, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'c':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->month, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 1, '0');
break;
case 'd':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'e':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 1, '0');
break;