Commit e30b6a98 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-11819 NO_ZERO_IN_DATE: Incorrect generated column value

parent bea99275
...@@ -2626,3 +2626,17 @@ DROP TABLE t1; ...@@ -2626,3 +2626,17 @@ DROP TABLE t1;
SELECT 1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2; SELECT 1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2;
1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2 1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2
3 3
#
# MDEV-11819 NO_ZERO_IN_DATE: Incorrect generated column value
#
SET sql_mode='NO_ZERO_IN_DATE';
CREATE TABLE t1 (a TIME(6));
INSERT INTO t1 SELECT timediff(timestamp'2008-12-31 23:59:59.000001',timestamp'2008-12-30 01:01:01.000002');
SELECT * FROM t1;
a
46:58:57.999999
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# End of 5.5 tests
#
...@@ -337,3 +337,22 @@ tsv timestamp as (adddate(ts, interval 1 day)) virtual ...@@ -337,3 +337,22 @@ tsv timestamp as (adddate(ts, interval 1 day)) virtual
); );
drop table t1; drop table t1;
set sql_mode=default; set sql_mode=default;
#
# MDEV-11819 NO_ZERO_IN_DATE: Incorrect generated column value
#
SET sql_mode='NO_ZERO_IN_DATE';
CREATE TABLE t1
(
a datetime DEFAULT NULL,
b datetime DEFAULT NULL,
c time GENERATED ALWAYS AS (timediff(`a`,`b`)) VIRTUAL
);
INSERT INTO t1 VALUES ('2008-12-31 23:59:59.000001','2008-12-30 01:01:01.000002',DEFAULT);
SELECT * FROM t1;
a b c
2008-12-31 23:59:59 2008-12-30 01:01:01 46:58:58
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# End of 5.5 tests
#
...@@ -301,3 +301,23 @@ create table t1 ( ...@@ -301,3 +301,23 @@ create table t1 (
); );
drop table t1; drop table t1;
set sql_mode=default; set sql_mode=default;
--echo #
--echo # MDEV-11819 NO_ZERO_IN_DATE: Incorrect generated column value
--echo #
SET sql_mode='NO_ZERO_IN_DATE';
CREATE TABLE t1
(
a datetime DEFAULT NULL,
b datetime DEFAULT NULL,
c time GENERATED ALWAYS AS (timediff(`a`,`b`)) VIRTUAL
);
INSERT INTO t1 VALUES ('2008-12-31 23:59:59.000001','2008-12-30 01:01:01.000002',DEFAULT);
SELECT * FROM t1;
DROP TABLE t1;
SET sql_mode=DEFAULT;
--echo #
--echo # End of 5.5 tests
--echo #
...@@ -1602,3 +1602,19 @@ DROP TABLE t1; ...@@ -1602,3 +1602,19 @@ DROP TABLE t1;
--echo # MDEV-10524 Assertion `arg1_int >= 0' failed in Item_func_additive_op::result_precision() --echo # MDEV-10524 Assertion `arg1_int >= 0' failed in Item_func_additive_op::result_precision()
--echo # --echo #
SELECT 1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2; SELECT 1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2;
--echo #
--echo # MDEV-11819 NO_ZERO_IN_DATE: Incorrect generated column value
--echo #
SET sql_mode='NO_ZERO_IN_DATE';
CREATE TABLE t1 (a TIME(6));
INSERT INTO t1 SELECT timediff(timestamp'2008-12-31 23:59:59.000001',timestamp'2008-12-30 01:01:01.000002');
SELECT * FROM t1;
DROP TABLE t1;
SET sql_mode=DEFAULT;
--echo #
--echo # End of 5.5 tests
--echo #
...@@ -500,8 +500,16 @@ class Item_temporal_func: public Item_func ...@@ -500,8 +500,16 @@ class Item_temporal_func: public Item_func
{ return val_decimal_from_date(decimal_value); } { return val_decimal_from_date(decimal_value); }
Field *tmp_table_field(TABLE *table) Field *tmp_table_field(TABLE *table)
{ return tmp_table_field_from_field_type(table, 0); } { return tmp_table_field_from_field_type(table, 0); }
#if MARIADB_VERSION_ID > 100300
#error This code should be removed in 10.3, to use the derived save_in_field()
#else
int save_in_field(Field *field, bool no_conversions) int save_in_field(Field *field, bool no_conversions)
{ return save_date_in_field(field); } {
return field_type() == MYSQL_TYPE_TIME ?
save_time_in_field(field) :
save_date_in_field(field);
}
#endif
void fix_length_and_dec(); void fix_length_and_dec();
}; };
......
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