maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #05790
Re: Review request: mdev-4634
Hi Sergei,
Please review a small patch that fixes the exact problem reported
in 4634 (and nothing else).
Thanks.
(the other problems from the original big patch are now
reported separately, with some of them already fixed).
On 06/13/2013 12:08 PM, Sergei Golubchik wrote:
Hi, Alexander!
On Jun 13, Alexander Barkov wrote:
Hi, Alexander!
This looks like a lot of changes for what you explained the reason of
the bug was. There will be lots of "whys" below...
The fix itself was quite small. However, an attempt
to write a reasonable test case revealed a few other bugs.
I just tried to fixing everything in a single patch.
I understood this and it was okay.
But I still wanted to know what change fixes what bug and what test
case.
Okey. Let's do everything separately.
These are separate reports for the problems
found during writing a test case for 4634:
https://mariadb.atlassian.net/browse/MDEV-4652
https://mariadb.atlassian.net/browse/MDEV-4653
https://mariadb.atlassian.net/browse/MDEV-4654
Here's a new one, found today:
https://mariadb.atlassian.net/browse/MDEV-4651
Okay, as you prefer :)
Regards,
Sergei
=== modified file 'mysql-test/r/type_date.result'
--- mysql-test/r/type_date.result 2013-03-17 06:41:22 +0000
+++ mysql-test/r/type_date.result 2013-06-26 11:14:20 +0000
@@ -298,3 +298,14 @@ insert t1 values ('2010-10-10 15:foobar'
Warnings:
Warning 1265 Data truncated for column 'f1' at row 1
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
+#
=== modified file 'mysql-test/r/type_datetime.result'
--- mysql-test/r/type_datetime.result 2013-05-04 01:45:20 +0000
+++ mysql-test/r/type_datetime.result 2013-06-26 11:14:41 +0000
@@ -681,4 +681,12 @@ c a b
1 1 0000-00-00
3 NULL NULL
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
=== modified file 'mysql-test/r/type_time.result'
--- mysql-test/r/type_time.result 2011-06-07 16:13:02 +0000
+++ mysql-test/r/type_time.result 2013-06-26 11:14:12 +0000
@@ -173,3 +173,14 @@ select f1, f1 = '2010-10-11 23:38:57' fr
f1 f1 = '2010-10-11 23:38:57'
23:38:57 0
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
+#
=== modified file 'mysql-test/t/type_date.test'
--- mysql-test/t/type_date.test 2012-05-02 15:04:28 +0000
+++ mysql-test/t/type_date.test 2013-06-26 11:13:25 +0000
@@ -282,3 +282,11 @@ create table t1 (f1 date, key (f1));
insert t1 values ('2010-10-10 15:foobar');
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 #
=== modified file 'mysql-test/t/type_datetime.test'
--- mysql-test/t/type_datetime.test 2013-05-04 01:45:20 +0000
+++ mysql-test/t/type_datetime.test 2013-06-26 11:13:36 +0000
@@ -486,5 +486,10 @@ select * from t2 left join t1 on t1.a=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
=== modified file 'mysql-test/t/type_time.test'
--- mysql-test/t/type_time.test 2011-05-19 17:01:46 +0000
+++ mysql-test/t/type_time.test 2013-06-26 11:13:04 +0000
@@ -123,3 +123,11 @@ insert into t1 values ('23:38:57');
select f1, f1 = '2010-10-11 23:38:57' from 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 #
=== modified file 'sql/item_func.cc'
--- sql/item_func.cc 2013-04-06 13:14:46 +0000
+++ sql/item_func.cc 2013-06-26 11:07:27 +0000
@@ -2469,6 +2469,12 @@ bool Item_func_min_max::get_date(MYSQL_T
min_max= res;
}
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)
{
ltime->time_type= MYSQL_TIMESTAMP_DATE;
=== modified file 'sql/item_timefunc.cc'
--- sql/item_timefunc.cc 2013-06-17 15:25:55 +0000
+++ sql/item_timefunc.cc 2013-06-26 11:33:50 +0000
@@ -2306,16 +2306,8 @@ bool Item_date_typecast::get_date(MYSQL_
return 1;
ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
ltime->time_type= MYSQL_TIMESTAMP_DATE;
-
- int unused;
- if (check_date(ltime, fuzzy_date, &unused))
- {
- Lazy_string_time 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);
+ return (null_value= check_date_with_warn(ltime, fuzzy_date,
+ MYSQL_TIMESTAMP_DATE));
}
=== modified file 'sql/mysql_priv.h'
--- sql/mysql_priv.h 2013-06-17 15:25:55 +0000
+++ sql/mysql_priv.h 2013-06-26 11:02:37 +0000
@@ -2568,6 +2568,8 @@ check_date(const MYSQL_TIME *ltime, ulon
{
return check_date(ltime, non_zero_date(ltime), flags, was_cut);
}
+bool check_date_with_warn(const MYSQL_TIME *ltime, uint fuzzy_date,
+ timestamp_type ts_type);
int test_if_number(char *str,int *res,bool allow_wildcards);
void change_byte(uchar *,uint,char,char);
bool init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
=== modified file 'sql/time.cc'
--- sql/time.cc 2013-01-08 20:23:03 +0000
+++ sql/time.cc 2013-06-26 11:01:54 +0000
@@ -213,6 +213,22 @@ ulong convert_month_to_period(ulong mont
}
+bool
+check_date_with_warn(const MYSQL_TIME *ltime, uint fuzzy_date,
+ timestamp_type ts_type)
+{
+ int dummy_warnings;
+ if (check_date(ltime, fuzzy_date, &dummy_warnings))
+ {
+ Lazy_string_time str(ltime);
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ &str, MYSQL_TIMESTAMP_ERROR, 0);
+ return true;
+ }
+ return false;
+}
+
+
/*
Convert a timestamp string to a MYSQL_TIME value and produce a warning
if string was truncated during conversion.
Follow ups
References