diff options
author | unknown <konstantin@mysql.com> | 2004-10-16 00:12:59 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2004-10-16 00:12:59 +0400 |
commit | 50129a2088282ec7929cf7b8dcf13f1c00753892 (patch) | |
tree | 49c6d8401938fd8137914328918f5f64de298327 /include | |
parent | deed55179489668c169d0fa0554e8507acf57699 (diff) | |
download | mariadb-git-50129a2088282ec7929cf7b8dcf13f1c00753892.tar.gz |
A fix and test case for Bug#6049 "Loss of sign when using prepared
statements and negative time/date values".
The bug was in wrong sprintf format used in the client library.
The fix moves TIME -> string conversion functions to sql-common and
utilized them in the client library.
include/my_time.h:
Declarations for new functions shared between the client and server.
libmysql/libmysql.c:
Fix for Bug#6049 "Loss of sign when using prepared statements and negative
time/date values": use the same function as the server to convert
date/time/datetime values to strings.
sql-common/my_time.c:
Implementation of my_{time,datetime,date,TIME}_to_str: it's
needed by the client library, so it should be shared.
sql/field.cc:
Don't create String object if it's not needed.
sql/item.cc:
Don't create String object if it's not needed: TIME_to_string was
moved to my_TIME_to_str, with different arguments.
sql/item_timefunc.cc:
Don't create String object if it's not needed.
sql/mysql_priv.h:
TIME_to_string and MAX_DATE_REP_LENGTH moved to the client library.
MAX_DATE_REP_LENGTH was renamed to MAX_DATE_STRING_REP_LENGTH to not
conflict with the same name in libmysql.c
sql/protocol.cc:
Don't create String object if it's not needed.
sql/time.cc:
Implementation of my_{time,date,datetime,TIME}_to_str moved to my_time.c
shared between the client and the server.
tests/client_test.c:
A test case for Bug#6049.
Diffstat (limited to 'include')
-rw-r--r-- | include/my_time.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/my_time.h b/include/my_time.h index d4dbe459c3b..dab17904b2d 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -60,6 +60,20 @@ my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap) void set_zero_time(MYSQL_TIME *tm); +/* + Required buffer length for my_time_to_str, my_date_to_str, + my_datetime_to_str and TIME_to_string functions. Note, that the + caller is still responsible to check that given TIME structure + has values in valid ranges, otherwise size of the buffer could + be not enough. +*/ +#define MAX_DATE_STRING_REP_LENGTH 30 + +int my_time_to_str(const MYSQL_TIME *l_time, char *to); +int my_date_to_str(const MYSQL_TIME *l_time, char *to); +int my_datetime_to_str(const MYSQL_TIME *l_time, char *to); +int my_TIME_to_str(const MYSQL_TIME *l_time, char *to); + C_MODE_END #endif /* _my_time_h_ */ |