mariadb/mysql-test/suite/vcol/t/vcol_sql_mode_time.test
Alexander Barkov c924e39fab MDEV-18153 Assertion 0' or Assertion btr_validate_index(index, 0)' failed in row_upd_sec_index_entry or error code 126: Index is corrupted upon UPDATE with TIME_ROUND_FRACTIONAL
Conversion to a temporal data type resulting into a lower precision
depends on TIME_ROUND_FRACTIONAL. Taking into account this dependency in:
- indexed generated virtual column expressions
- persistent virtual column expressions

A warning is now issued if conversion from the generation expression
to the column data type depends on TIME_ROUND_FRACTIONAL.

The warning will be changed to error in 10.5
2019-09-13 11:47:43 +04:00

112 lines
2 KiB
Text

--echo #
--echo # Start of 10.4 tests
--echo #
--echo #
--echo # MDEV-18153 Assertion `0' or Assertion `btr_validate_index(index, 0)' failed in row_upd_sec_index_entry or error code 126: Index is corrupted upon UPDATE with TIME_ROUND_FRACTIONAL
--echo #
SET sql_mode=DEFAULT;
--echo # OK: same FSP + virtual index
CREATE TABLE t1 (
t TIME(4),
d TIME,
v TIME(4) AS (t) VIRTUAL,
KEY(v,d)
);
DROP TABLE t1;
CREATE TABLE t1 (
t TIME(4),
d TIME,
v TIME(4) AS ('10:20:30.1234') VIRTUAL,
KEY(v,d)
);
DROP TABLE t1;
--echo # OK: lower FSP + no virtual index
CREATE TABLE t1 (
t TIME(4),
d TIME,
v TIME(3) AS (t) VIRTUAL
);
DROP TABLE t1;
CREATE TABLE t1 (
t TIME(4),
d TIME,
v TIME(3) AS ('2001-01-01 10:20:30.1234') VIRTUAL
);
DROP TABLE t1;
--echo # NOT OK: lower FSP + virtual index
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
t TIME(4),
d TIME,
v TIME(3) AS (t) VIRTUAL,
KEY(v,d)
);
DROP TABLE t1;
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
t TIME(4),
d TIME,
v TIME(3) AS (COALESCE(t)) VIRTUAL,
KEY(v,d)
);
DROP TABLE t1;
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
t TIME(4),
d TIME,
v TIME(3) AS ('2001-01-01 10:20:30.1234') VIRTUAL,
KEY(v,d)
);
DROP TABLE t1;
--echo # OK: lower FSP + ROUND + virtual index
SET sql_mode=DEFAULT;
CREATE TABLE t1 (
t TIME(4),
d TIME,
v TIME(3) AS (ROUND(t,3)) VIRTUAL,
KEY(v,d)
);
INSERT IGNORE INTO t1 (t,d) VALUES ('12:44:34.0496','21:27:53');
SELECT * FROM t1;
SET SQL_MODE= 'TIME_ROUND_FRACTIONAL';
UPDATE IGNORE t1 SET d = CURRENT_TIME;
DROP TABLE t1;
SET sql_mode=DEFAULT;
--echo # OK: lower FSP + TRUNCATE + virtual index
SET sql_mode=DEFAULT;
CREATE TABLE t1 (
t TIME(4),
d TIME,
v TIME(3) AS (TRUNCATE(t,3)) VIRTUAL,
KEY(v,d)
);
INSERT IGNORE INTO t1 (t,d) VALUES ('12:44:34.0496','21:27:53');
SELECT * FROM t1;
SET SQL_MODE= 'TIME_ROUND_FRACTIONAL';
UPDATE IGNORE t1 SET d = CURRENT_TIME;
DROP TABLE t1;
SET sql_mode=DEFAULT;
--echo #
--echo # End of 10.4 tests
--echo #