Skip to content

Commit bf617c3

Browse files
committed
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
1 parent efefafd commit bf617c3

File tree

6 files changed

+119
-0
lines changed

6 files changed

+119
-0
lines changed

mysql-test/suite/vcol/r/vcol_sql_mode_datetime.result

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,29 @@ UPDATE IGNORE t1 SET d = NOW();
9797
DROP TABLE t1;
9898
SET sql_mode=DEFAULT;
9999
#
100+
# 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
101+
#
102+
CREATE TABLE t1 (
103+
a DATETIME(6),
104+
v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS DATETIME(3))) VIRTUAL,
105+
KEY (v)
106+
);
107+
Warnings:
108+
Warning 1901 Function or expression 'cast(`a` as datetime(3))' cannot be used in the GENERATED ALWAYS AS clause of `v`
109+
Warning 1105 Expression depends on the @@sql_mode value TIME_ROUND_FRACTIONAL
110+
DROP TABLE t1;
111+
CREATE TABLE t1 (
112+
a DATETIME(6),
113+
v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL,
114+
KEY (v)
115+
);
116+
DROP TABLE t1;
117+
CREATE TABLE t1 (
118+
a DATETIME(6),
119+
v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL,
120+
KEY (v)
121+
);
122+
DROP TABLE t1;
123+
#
100124
# End of 10.4 tests
101125
#

mysql-test/suite/vcol/r/vcol_sql_mode_time.result

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,29 @@ UPDATE IGNORE t1 SET d = CURRENT_TIME;
9797
DROP TABLE t1;
9898
SET sql_mode=DEFAULT;
9999
#
100+
# 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
101+
#
102+
CREATE TABLE t1 (
103+
a TIME(6),
104+
v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS TIME(3))) VIRTUAL,
105+
KEY (v)
106+
);
107+
Warnings:
108+
Warning 1901 Function or expression 'cast(`a` as time(3))' cannot be used in the GENERATED ALWAYS AS clause of `v`
109+
Warning 1105 Expression depends on the @@sql_mode value TIME_ROUND_FRACTIONAL
110+
DROP TABLE t1;
111+
CREATE TABLE t1 (
112+
a TIME(6),
113+
v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL,
114+
KEY (v)
115+
);
116+
DROP TABLE t1;
117+
CREATE TABLE t1 (
118+
a TIME(6),
119+
v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL,
120+
KEY (v)
121+
);
122+
DROP TABLE t1;
123+
#
100124
# End of 10.4 tests
101125
#

mysql-test/suite/vcol/t/vcol_sql_mode_datetime.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,32 @@ UPDATE IGNORE t1 SET d = NOW();
106106
DROP TABLE t1;
107107
SET sql_mode=DEFAULT;
108108

109+
--echo #
110+
--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
111+
--echo #
112+
113+
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
114+
CREATE TABLE t1 (
115+
a DATETIME(6),
116+
v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS DATETIME(3))) VIRTUAL,
117+
KEY (v)
118+
);
119+
DROP TABLE t1;
120+
121+
CREATE TABLE t1 (
122+
a DATETIME(6),
123+
v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL,
124+
KEY (v)
125+
);
126+
DROP TABLE t1;
127+
128+
CREATE TABLE t1 (
129+
a DATETIME(6),
130+
v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL,
131+
KEY (v)
132+
);
133+
DROP TABLE t1;
134+
109135

110136
--echo #
111137
--echo # End of 10.4 tests

mysql-test/suite/vcol/t/vcol_sql_mode_time.test

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,33 @@ DROP TABLE t1;
107107
SET sql_mode=DEFAULT;
108108

109109

110+
--echo #
111+
--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
112+
--echo #
113+
114+
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
115+
CREATE TABLE t1 (
116+
a TIME(6),
117+
v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS TIME(3))) VIRTUAL,
118+
KEY (v)
119+
);
120+
DROP TABLE t1;
121+
122+
CREATE TABLE t1 (
123+
a TIME(6),
124+
v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL,
125+
KEY (v)
126+
);
127+
DROP TABLE t1;
128+
129+
CREATE TABLE t1 (
130+
a TIME(6),
131+
v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL,
132+
KEY (v)
133+
);
134+
DROP TABLE t1;
135+
136+
110137
--echo #
111138
--echo # End of 10.4 tests
112139
--echo #

sql/item_timefunc.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,6 +2446,14 @@ bool Item_time_typecast::get_date(THD *thd, MYSQL_TIME *to, date_mode_t mode)
24462446
}
24472447

24482448

2449+
Sql_mode_dependency Item_time_typecast::value_depends_on_sql_mode() const
2450+
{
2451+
return Item_timefunc::value_depends_on_sql_mode() |
2452+
Sql_mode_dependency(decimals < args[0]->decimals ?
2453+
MODE_TIME_ROUND_FRACTIONAL : 0, 0);
2454+
}
2455+
2456+
24492457
bool Item_date_typecast::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
24502458
{
24512459
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
24662474
}
24672475

24682476

2477+
Sql_mode_dependency Item_datetime_typecast::value_depends_on_sql_mode() const
2478+
{
2479+
return Item_datetimefunc::value_depends_on_sql_mode() |
2480+
Sql_mode_dependency(decimals < args[0]->decimals ?
2481+
MODE_TIME_ROUND_FRACTIONAL : 0, 0);
2482+
}
2483+
2484+
24692485
/**
24702486
MAKEDATE(a,b) is a date function that creates a date value
24712487
from a year and day value.

sql/item_timefunc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ class Item_time_typecast :public Item_timefunc
11621162
return args[0]->type_handler()->
11631163
Item_time_typecast_fix_length_and_dec(this);
11641164
}
1165+
Sql_mode_dependency value_depends_on_sql_mode() const;
11651166
Item *get_copy(THD *thd)
11661167
{ return get_item_copy<Item_time_typecast>(thd, this); }
11671168
};
@@ -1183,6 +1184,7 @@ class Item_datetime_typecast :public Item_datetimefunc
11831184
return args[0]->type_handler()->
11841185
Item_datetime_typecast_fix_length_and_dec(this);
11851186
}
1187+
Sql_mode_dependency value_depends_on_sql_mode() const;
11861188
Item *get_copy(THD *thd)
11871189
{ return get_item_copy<Item_datetime_typecast>(thd, this); }
11881190
};

0 commit comments

Comments
 (0)