Commit 030d080d authored by unknown's avatar unknown

bug #19491 (5.0-related additional fixes)


include/my_time.h:
  we need to use it outside the my_time.cc
mysql-test/r/gis-rtree.result:
  result fixed
sql-common/my_time.c:
  'static' removed
sql/field.cc:
  checks for invalid datetimes added
parent 10dd1a37
......@@ -49,6 +49,8 @@ typedef long my_time_t;
#define TIME_NO_ZERO_DATE (TIME_NO_ZERO_IN_DATE*2)
#define TIME_INVALID_DATES (TIME_NO_ZERO_DATE*2)
my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
ulong flags, int *was_cut);
enum enum_mysql_timestamp_type
str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
uint flags, int *was_cut);
......
......@@ -862,13 +862,6 @@ CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1(foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
INSERT INTO t1(foo) VALUES (NULL);
ERROR 23000: Column 'foo' cannot be null
INSERT INTO t1() VALUES ();
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
INSERT INTO t1(foo) VALUES ('');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
CREATE TABLE t1 (foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,1)));
INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,0)));
......@@ -880,3 +873,11 @@ SELECT 1 FROM t1 WHERE foo != PointFromWKB(POINT(0,0));
1
1
DROP TABLE t1;
CREATE TABLE t1(foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
INSERT INTO t1(foo) VALUES (NULL);
ERROR 23000: Column 'foo' cannot be null
INSERT INTO t1() VALUES ();
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
INSERT INTO t1(foo) VALUES ('');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
DROP TABLE t1;
......@@ -76,7 +76,7 @@ uint calc_days_in_year(uint year)
1 error
*/
static my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
ulong flags, int *was_cut)
{
if (not_zero_date)
......
......@@ -5407,7 +5407,21 @@ int Field_newdate::store_time(TIME *ltime,timestamp_type type)
long tmp;
int error= 0;
if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME)
{
tmp=ltime->year*16*32+ltime->month*32+ltime->day;
if ((my_bool)check_date(ltime, tmp,
(TIME_FUZZY_DATE |
(current_thd->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
MODE_INVALID_DATES))), &error))
{
char buff[12];
String str(buff, sizeof(buff), &my_charset_latin1);
make_date((DATE_TIME_FORMAT *) 0, ltime, &str);
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1);
}
}
else
{
tmp=0;
......@@ -5616,8 +5630,22 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type type)
structure always fit into DATETIME range.
*/
if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME)
{
tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*LL(1000000)+
(ltime->hour*10000L+ltime->minute*100+ltime->second));
if ((my_bool)check_date(ltime, tmp,
(TIME_FUZZY_DATE |
(current_thd->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
MODE_INVALID_DATES))), &error))
{
char buff[12];
String str(buff, sizeof(buff), &my_charset_latin1);
make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str);
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
str.ptr(), str.length(), MYSQL_TIMESTAMP_DATETIME,1);
}
}
else
{
tmp=0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment