From 81d9bed3a492c21fae0d821fd65bae5078a85be3 Mon Sep 17 00:00:00 2001 From: Monty Date: Sun, 24 Jan 2021 23:56:43 +0200 Subject: MDEV-20017 Implement TO_CHAR() Oracle compatible function TO_CHAR(expr, fmt) - expr: required parameter, data/time/timestamp type expression - fmt: optional parameter, format string, supports YYYY/YYY/YY/RRRR/RR/MM/MON/MONTH/MI/DD/DY/HH/HH12/HH24/SS and special characters. The default value is "YYYY-MM-DD HH24:MI:SS" In Oracle, TO_CHAR() can also be used to convert numbers to strings, but this is not supported. This will gave an error in this patch. Other things: - If format strings is a constant, it's evaluated only once and if there is any errors in it, they are given at once and the statement will abort. Original author: woqutech Lots of optimizations and cleanups done as part of review --- sql/sql_string.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sql/sql_string.cc') diff --git a/sql/sql_string.cc b/sql/sql_string.cc index c9117451374..c5f0c74528b 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -502,16 +502,16 @@ bool String::set_ascii(const char *str, size_t arg_length) /* This is used by mysql.cc */ -bool Binary_string::fill(uint32 max_length,char fill_char) +bool Binary_string::fill(size_t max_length,char fill_char) { if (str_length > max_length) - Ptr[str_length=max_length]=0; + Ptr[str_length= (uint32) max_length]=0; else { if (realloc(max_length)) return TRUE; bfill(Ptr+str_length,max_length-str_length,fill_char); - str_length=max_length; + str_length= (uint32) max_length; } return FALSE; } -- cgit v1.2.1