mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge from 5.3
modified: mysql-test/r/type_date.result mysql-test/r/type_datetime.result mysql-test/r/type_time.result mysql-test/t/type_date.test mysql-test/t/type_datetime.test mysql-test/t/type_time.test sql/item_func.cc sql/item_timefunc.cc sql/sql_time.cc sql/sql_time.h pending merges: Alexander Barkov 2013-06-28 MDEV-4634 Crash in CONVERT_TZ
This commit is contained in:
@ -303,6 +303,17 @@ Warnings:
|
|||||||
Warning 1265 Data truncated for column 'f1' at row 1
|
Warning 1265 Data truncated for column 'f1' at row 1
|
||||||
drop table t1;
|
drop table t1;
|
||||||
#
|
#
|
||||||
|
# MDEV-4634 Crash in CONVERT_TZ
|
||||||
|
#
|
||||||
|
SELECT CONVERT_TZ(GREATEST(DATE('2021-00-00'),DATE('2022-00-00')),'+00:00','+7:5');
|
||||||
|
CONVERT_TZ(GREATEST(DATE('2021-00-00'),DATE('2022-00-00')),'+00:00','+7:5')
|
||||||
|
NULL
|
||||||
|
Warnings:
|
||||||
|
Warning 1292 Incorrect datetime value: '2022-00-00 00:00:00'
|
||||||
|
#
|
||||||
|
# End of 5.3 tests
|
||||||
|
#
|
||||||
|
#
|
||||||
# Bug #33629: last_day function can return null, but has 'not null'
|
# Bug #33629: last_day function can return null, but has 'not null'
|
||||||
# flag set for result
|
# flag set for result
|
||||||
#
|
#
|
||||||
|
@ -681,6 +681,14 @@ c a b
|
|||||||
1 1 0000-00-00
|
1 1 0000-00-00
|
||||||
3 NULL NULL
|
3 NULL NULL
|
||||||
drop table t1,t2;
|
drop table t1,t2;
|
||||||
|
#
|
||||||
|
# MDEV-4634 Crash in CONVERT_TZ
|
||||||
|
#
|
||||||
|
SELECT CONVERT_TZ(GREATEST(TIMESTAMP('2021-00-00'),TIMESTAMP('2022-00-00')),'+00:00','+7:5');
|
||||||
|
CONVERT_TZ(GREATEST(TIMESTAMP('2021-00-00'),TIMESTAMP('2022-00-00')),'+00:00','+7:5')
|
||||||
|
NULL
|
||||||
|
Warnings:
|
||||||
|
Warning 1292 Incorrect datetime value: '2022-00-00 00:00:00'
|
||||||
End of 5.3 tests
|
End of 5.3 tests
|
||||||
#
|
#
|
||||||
# Start of 5.5 tests
|
# Start of 5.5 tests
|
||||||
|
@ -174,6 +174,17 @@ select f1, f1 = '2010-10-11 23:38:57' from t1;
|
|||||||
f1 f1 = '2010-10-11 23:38:57'
|
f1 f1 = '2010-10-11 23:38:57'
|
||||||
23:38:57 0
|
23:38:57 0
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
#
|
||||||
|
# MDEV-4634 Crash in CONVERT_TZ
|
||||||
|
#
|
||||||
|
SELECT CONVERT_TZ(GREATEST(TIME('00:00:00'),TIME('00:00:00')),'+00:00','+7:5');
|
||||||
|
CONVERT_TZ(GREATEST(TIME('00:00:00'),TIME('00:00:00')),'+00:00','+7:5')
|
||||||
|
NULL
|
||||||
|
Warnings:
|
||||||
|
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
|
||||||
|
#
|
||||||
|
# End of 5.3 tests
|
||||||
|
#
|
||||||
CREATE TABLE t1 (f1 TIME);
|
CREATE TABLE t1 (f1 TIME);
|
||||||
INSERT INTO t1 VALUES ('24:00:00');
|
INSERT INTO t1 VALUES ('24:00:00');
|
||||||
SELECT '24:00:00' = (SELECT f1 FROM t1);
|
SELECT '24:00:00' = (SELECT f1 FROM t1);
|
||||||
|
@ -294,6 +294,15 @@ create table t1 (f1 date, key (f1));
|
|||||||
insert t1 values ('2010-10-10 15:foobar');
|
insert t1 values ('2010-10-10 15:foobar');
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-4634 Crash in CONVERT_TZ
|
||||||
|
--echo #
|
||||||
|
SELECT CONVERT_TZ(GREATEST(DATE('2021-00-00'),DATE('2022-00-00')),'+00:00','+7:5');
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # End of 5.3 tests
|
||||||
|
--echo #
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # Bug #33629: last_day function can return null, but has 'not null'
|
--echo # Bug #33629: last_day function can return null, but has 'not null'
|
||||||
--echo # flag set for result
|
--echo # flag set for result
|
||||||
|
@ -486,6 +486,11 @@ select * from t2 left join t1 on t1.a=t2.c where t1.b is null;
|
|||||||
|
|
||||||
drop table t1,t2;
|
drop table t1,t2;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-4634 Crash in CONVERT_TZ
|
||||||
|
--echo #
|
||||||
|
SELECT CONVERT_TZ(GREATEST(TIMESTAMP('2021-00-00'),TIMESTAMP('2022-00-00')),'+00:00','+7:5');
|
||||||
|
|
||||||
--echo End of 5.3 tests
|
--echo End of 5.3 tests
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
|
@ -123,6 +123,15 @@ insert into t1 values ('23:38:57');
|
|||||||
select f1, f1 = '2010-10-11 23:38:57' from t1;
|
select f1, f1 = '2010-10-11 23:38:57' from t1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-4634 Crash in CONVERT_TZ
|
||||||
|
--echo #
|
||||||
|
SELECT CONVERT_TZ(GREATEST(TIME('00:00:00'),TIME('00:00:00')),'+00:00','+7:5');
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # End of 5.3 tests
|
||||||
|
--echo #
|
||||||
|
|
||||||
#
|
#
|
||||||
# Bug#42664 - Sign ignored for TIME types when not comparing as longlong
|
# Bug#42664 - Sign ignored for TIME types when not comparing as longlong
|
||||||
#
|
#
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "sql_acl.h" // EXECUTE_ACL
|
#include "sql_acl.h" // EXECUTE_ACL
|
||||||
#include "mysqld.h" // LOCK_short_uuid_generator
|
#include "mysqld.h" // LOCK_short_uuid_generator
|
||||||
#include "rpl_mi.h"
|
#include "rpl_mi.h"
|
||||||
|
#include "sql_time.h"
|
||||||
#include <m_ctype.h>
|
#include <m_ctype.h>
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -2779,6 +2780,12 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
|
|||||||
min_max= res;
|
min_max= res;
|
||||||
}
|
}
|
||||||
unpack_time(min_max, ltime);
|
unpack_time(min_max, ltime);
|
||||||
|
|
||||||
|
if (!(fuzzy_date & TIME_TIME_ONLY) &&
|
||||||
|
((null_value= check_date_with_warn(ltime, fuzzy_date,
|
||||||
|
MYSQL_TIMESTAMP_ERROR))))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (compare_as_dates->field_type() == MYSQL_TYPE_DATE)
|
if (compare_as_dates->field_type() == MYSQL_TYPE_DATE)
|
||||||
{
|
{
|
||||||
ltime->time_type= MYSQL_TIMESTAMP_DATE;
|
ltime->time_type= MYSQL_TIMESTAMP_DATE;
|
||||||
|
@ -2429,16 +2429,8 @@ bool Item_date_typecast::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
|
|||||||
|
|
||||||
ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
|
ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
|
||||||
ltime->time_type= MYSQL_TIMESTAMP_DATE;
|
ltime->time_type= MYSQL_TIMESTAMP_DATE;
|
||||||
|
return (null_value= check_date_with_warn(ltime, fuzzy_date,
|
||||||
int unused;
|
MYSQL_TIMESTAMP_DATE));
|
||||||
if (check_date(ltime, fuzzy_date, &unused))
|
|
||||||
{
|
|
||||||
ErrConvTime str(ltime);
|
|
||||||
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
|
||||||
&str, MYSQL_TIMESTAMP_DATE, 0);
|
|
||||||
return (null_value= 1);
|
|
||||||
}
|
|
||||||
return (null_value= 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,6 +214,22 @@ ulong convert_month_to_period(ulong month)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
check_date_with_warn(const MYSQL_TIME *ltime, ulonglong fuzzy_date,
|
||||||
|
timestamp_type ts_type)
|
||||||
|
{
|
||||||
|
int dummy_warnings;
|
||||||
|
if (check_date(ltime, fuzzy_date, &dummy_warnings))
|
||||||
|
{
|
||||||
|
ErrConvTime str(ltime);
|
||||||
|
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||||
|
&str, ts_type, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Convert a string to 8-bit representation,
|
Convert a string to 8-bit representation,
|
||||||
for use in str_to_time/str_to_date/str_to_date.
|
for use in str_to_time/str_to_date/str_to_date.
|
||||||
|
@ -121,5 +121,7 @@ check_date(const MYSQL_TIME *ltime, ulonglong flags, int *was_cut)
|
|||||||
{
|
{
|
||||||
return check_date(ltime, non_zero_date(ltime), flags, was_cut);
|
return check_date(ltime, non_zero_date(ltime), flags, was_cut);
|
||||||
}
|
}
|
||||||
|
bool check_date_with_warn(const MYSQL_TIME *ltime, ulonglong fuzzy_date,
|
||||||
|
timestamp_type ts_type);
|
||||||
|
|
||||||
#endif /* SQL_TIME_INCLUDED */
|
#endif /* SQL_TIME_INCLUDED */
|
||||||
|
Reference in New Issue
Block a user