MDEV-20423 Assertion 0' failed or btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL

This commit is contained in:
Alexander Barkov 2019-09-18 09:51:13 +04:00
parent efefafd02f
commit bf617c3654
6 changed files with 119 additions and 0 deletions

View File

@ -97,5 +97,29 @@ UPDATE IGNORE t1 SET d = NOW();
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# MDEV-20423 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL
#
CREATE TABLE t1 (
a DATETIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS DATETIME(3))) VIRTUAL,
KEY (v)
);
Warnings:
Warning 1901 Function or expression 'cast(`a` as datetime(3))' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value TIME_ROUND_FRACTIONAL
DROP TABLE t1;
CREATE TABLE t1 (
a DATETIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL,
KEY (v)
);
DROP TABLE t1;
CREATE TABLE t1 (
a DATETIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL,
KEY (v)
);
DROP TABLE t1;
#
# End of 10.4 tests
#

View File

@ -97,5 +97,29 @@ UPDATE IGNORE t1 SET d = CURRENT_TIME;
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# MDEV-20423 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL
#
CREATE TABLE t1 (
a TIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS TIME(3))) VIRTUAL,
KEY (v)
);
Warnings:
Warning 1901 Function or expression 'cast(`a` as time(3))' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value TIME_ROUND_FRACTIONAL
DROP TABLE t1;
CREATE TABLE t1 (
a TIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL,
KEY (v)
);
DROP TABLE t1;
CREATE TABLE t1 (
a TIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL,
KEY (v)
);
DROP TABLE t1;
#
# End of 10.4 tests
#

View File

@ -106,6 +106,32 @@ UPDATE IGNORE t1 SET d = NOW();
DROP TABLE t1;
SET sql_mode=DEFAULT;
--echo #
--echo # MDEV-20423 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL
--echo #
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a DATETIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS DATETIME(3))) VIRTUAL,
KEY (v)
);
DROP TABLE t1;
CREATE TABLE t1 (
a DATETIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL,
KEY (v)
);
DROP TABLE t1;
CREATE TABLE t1 (
a DATETIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL,
KEY (v)
);
DROP TABLE t1;
--echo #
--echo # End of 10.4 tests

View File

@ -107,6 +107,33 @@ DROP TABLE t1;
SET sql_mode=DEFAULT;
--echo #
--echo # MDEV-20423 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL
--echo #
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a TIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS TIME(3))) VIRTUAL,
KEY (v)
);
DROP TABLE t1;
CREATE TABLE t1 (
a TIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL,
KEY (v)
);
DROP TABLE t1;
CREATE TABLE t1 (
a TIME(6),
v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL,
KEY (v)
);
DROP TABLE t1;
--echo #
--echo # End of 10.4 tests
--echo #

View File

@ -2446,6 +2446,14 @@ bool Item_time_typecast::get_date(THD *thd, MYSQL_TIME *to, date_mode_t mode)
}
Sql_mode_dependency Item_time_typecast::value_depends_on_sql_mode() const
{
return Item_timefunc::value_depends_on_sql_mode() |
Sql_mode_dependency(decimals < args[0]->decimals ?
MODE_TIME_ROUND_FRACTIONAL : 0, 0);
}
bool Item_date_typecast::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
date_mode_t tmp= (fuzzydate | sql_mode_for_dates(thd)) & ~TIME_TIME_ONLY;
@ -2466,6 +2474,14 @@ bool Item_datetime_typecast::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t f
}
Sql_mode_dependency Item_datetime_typecast::value_depends_on_sql_mode() const
{
return Item_datetimefunc::value_depends_on_sql_mode() |
Sql_mode_dependency(decimals < args[0]->decimals ?
MODE_TIME_ROUND_FRACTIONAL : 0, 0);
}
/**
MAKEDATE(a,b) is a date function that creates a date value
from a year and day value.

View File

@ -1162,6 +1162,7 @@ public:
return args[0]->type_handler()->
Item_time_typecast_fix_length_and_dec(this);
}
Sql_mode_dependency value_depends_on_sql_mode() const;
Item *get_copy(THD *thd)
{ return get_item_copy<Item_time_typecast>(thd, this); }
};
@ -1183,6 +1184,7 @@ public:
return args[0]->type_handler()->
Item_datetime_typecast_fix_length_and_dec(this);
}
Sql_mode_dependency value_depends_on_sql_mode() const;
Item *get_copy(THD *thd)
{ return get_item_copy<Item_datetime_typecast>(thd, this); }
};