diff options
author | unknown <dlenev@brandersnatch.localdomain> | 2004-11-15 15:44:29 +0300 |
---|---|---|
committer | unknown <dlenev@brandersnatch.localdomain> | 2004-11-15 15:44:29 +0300 |
commit | 5d9f7edd6dfb0d6759a5374ac61c0153db48b1f7 (patch) | |
tree | aff5a1316b48a5f38063f5b0a42141d52f545d81 /libmysql | |
parent | 7fd0cc2d1265ac425e602f24894005539468c429 (diff) | |
download | mariadb-git-5d9f7edd6dfb0d6759a5374ac61c0153db48b1f7.tar.gz |
Fix for bug #6266 "Invalid DATETIME value is not handled properly".
In server we assume that datetime values stored in MYSQL_TIME struct
are normalized (and year is not greater than 9999), so we should
perform range checks in all places then we convert something to
MYSQL_TIME.
include/my_time.h:
Added one more argument to set_zero_time() function to make it more
convinient.
Added comment clarifying why MAX_DATE_STRING_REP_LENGTH value is 30.
include/mysql_time.h:
Documented MySQL's internal assumptions for members of MYSQL_TIME
structure.
libmysql/libmysql.c:
It does not make sense to set MYSQL_TIME::time_type twice in case of
errors.
mysql-test/r/type_datetime.result:
Added test for bug #6266 "Invalid DATETIME value not handled properly".
mysql-test/t/type_datetime.test:
Added test for bug #6266 "Invalid DATETIME value not handled properly".
sql-common/my_time.c:
str_to_datetime(): Added missing check for too big year values.
set_zero_time(): added time_type argument, since MYSQL_TIMESTAMP_NONE
is not the value that we want in most cases.
sql/field.cc:
Field_datetime::store_time():
clarified why we don't perform any range checks here.
sql/item.cc:
Item_param::set_time():
Added comment describing this method and range checking for TIME
values.
sql/sql_prepare.cc:
Removed comments about range checking for TIME values in prepared
statements, which are no longer true.
set_zero_time() has one more argument now.
tests/client_test.c:
Added test for bug #6266 "Invalid DATETIME value not handled properly"
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/libmysql.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 88f46ce19e7..bfbfd9670ca 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3256,11 +3256,12 @@ static void read_binary_time(MYSQL_TIME *tm, uchar **pos) tm->hour+= tm->day*24; tm->day= 0; } + tm->time_type= MYSQL_TIMESTAMP_TIME; + *pos+= length; } else - set_zero_time(tm); - tm->time_type= MYSQL_TIMESTAMP_TIME; + set_zero_time(tm, MYSQL_TIMESTAMP_TIME); } static void read_binary_datetime(MYSQL_TIME *tm, uchar **pos) @@ -3285,12 +3286,12 @@ static void read_binary_datetime(MYSQL_TIME *tm, uchar **pos) else tm->hour= tm->minute= tm->second= 0; tm->second_part= (length > 7) ? (ulong) sint4korr(to+7) : 0; + tm->time_type= MYSQL_TIMESTAMP_DATETIME; *pos+= length; } else - set_zero_time(tm); - tm->time_type= MYSQL_TIMESTAMP_DATETIME; + set_zero_time(tm, MYSQL_TIMESTAMP_DATETIME); } static void read_binary_date(MYSQL_TIME *tm, uchar **pos) @@ -3307,12 +3308,12 @@ static void read_binary_date(MYSQL_TIME *tm, uchar **pos) tm->hour= tm->minute= tm->second= 0; tm->second_part= 0; tm->neg= 0; + tm->time_type= MYSQL_TIMESTAMP_DATE; *pos+= length; } else - set_zero_time(tm); - tm->time_type= MYSQL_TIMESTAMP_DATE; + set_zero_time(tm, MYSQL_TIMESTAMP_DATE); } |