mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
lp:923429 Crash in decimal_cmp on using UNIX_TIMESTAMP with a wrongly formatted timestamp
UNIX_TIMESTAMP() can be null, and returns null for invalid values
This commit is contained in:
@@ -587,3 +587,16 @@ Variable_name Value
|
|||||||
Handler_read_next 1
|
Handler_read_next 1
|
||||||
DROP TABLE t1, t2;
|
DROP TABLE t1, t2;
|
||||||
End of 5.1 tests
|
End of 5.1 tests
|
||||||
|
#
|
||||||
|
# lp:923429 Crash in decimal_cmp on using UNIX_TIMESTAMP with a wrongly formatted timestamp
|
||||||
|
#
|
||||||
|
SELECT UNIX_TIMESTAMP('abc') > 0;
|
||||||
|
UNIX_TIMESTAMP('abc') > 0
|
||||||
|
NULL
|
||||||
|
Warnings:
|
||||||
|
Warning 1292 Incorrect datetime value: 'abc'
|
||||||
|
SELECT UNIX_TIMESTAMP('abc');
|
||||||
|
UNIX_TIMESTAMP('abc')
|
||||||
|
NULL
|
||||||
|
Warnings:
|
||||||
|
Warning 1292 Incorrect datetime value: 'abc'
|
||||||
|
@@ -410,3 +410,10 @@ SHOW STATUS LIKE 'Handler_read_next';
|
|||||||
DROP TABLE t1, t2;
|
DROP TABLE t1, t2;
|
||||||
|
|
||||||
--echo End of 5.1 tests
|
--echo End of 5.1 tests
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # lp:923429 Crash in decimal_cmp on using UNIX_TIMESTAMP with a wrongly formatted timestamp
|
||||||
|
--echo #
|
||||||
|
SELECT UNIX_TIMESTAMP('abc') > 0;
|
||||||
|
SELECT UNIX_TIMESTAMP('abc');
|
||||||
|
|
||||||
|
@@ -1134,15 +1134,7 @@ bool Item_func_unix_timestamp::get_timestamp_value(my_time_t *seconds,
|
|||||||
|
|
||||||
MYSQL_TIME ltime;
|
MYSQL_TIME ltime;
|
||||||
if (get_arg0_date(<ime, 0))
|
if (get_arg0_date(<ime, 0))
|
||||||
{
|
|
||||||
/*
|
|
||||||
We have to set null_value again because get_arg0_date will also set it
|
|
||||||
to true if we have wrong datetime parameter (and we should return 0 in
|
|
||||||
this case).
|
|
||||||
*/
|
|
||||||
null_value= args[0]->null_value;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
uint error_code;
|
uint error_code;
|
||||||
*seconds= TIME_to_timestamp(current_thd, <ime, &error_code);
|
*seconds= TIME_to_timestamp(current_thd, <ime, &error_code);
|
||||||
|
@@ -385,11 +385,6 @@ public:
|
|||||||
Item_func_unix_timestamp(Item *a) :Item_func_seconds_hybrid(a) {}
|
Item_func_unix_timestamp(Item *a) :Item_func_seconds_hybrid(a) {}
|
||||||
const char *func_name() const { return "unix_timestamp"; }
|
const char *func_name() const { return "unix_timestamp"; }
|
||||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||||
void fix_num_length_and_dec()
|
|
||||||
{
|
|
||||||
maybe_null= false;
|
|
||||||
Item_func_seconds_hybrid::fix_num_length_and_dec();
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
UNIX_TIMESTAMP() depends on the current timezone
|
UNIX_TIMESTAMP() depends on the current timezone
|
||||||
(and thus may not be used as a partitioning function)
|
(and thus may not be used as a partitioning function)
|
||||||
|
Reference in New Issue
Block a user