mariadb/mysql-test/suite/gcol/r/gcol_partition_innodb.result
Nikita Malyavin 7d9ba57da4 [1/2] MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
This is a 10.2+ part of a jira task

The two bugs regarding virtual column marking have been fixed:

1. UPDATE of a partitioned table, where the optimizer has chosen a
 secondary index to make a filesort;
2. INSERT into a table with a nonblob field generated from a blob, with
 binlog enabled and binlog_row_image=noblob.

3. DELETE from a view on a table with virtual column.

Generally the assertion happens from update_virtual_fields() call

These bugs are root-caused by missing field marking for dependant fields
of a virtual column.

Therefore a fix is: mark all the fields involved in the vcol expression by
calling field->register_field_in_read_map() instead just setting a single
bit.

3 was reproducible only on 10.4+, however the problem might has just been
invisible in the earlier versions. The fix is applicable to 10.2-10.3 as
well.
2021-07-12 22:00:39 +03:00

127 lines
3.4 KiB
Text

SET @@session.default_storage_engine = 'InnoDB';
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
drop table if exists t1;
# Case 1. Partitioning by RANGE based on a non-stored generated column.
CREATE TABLE t1 (
a DATE NOT NULL,
b int generated always as (year(a)) virtual
)
PARTITION BY RANGE( b ) (
PARTITION p0 VALUES LESS THAN (2006),
PARTITION p2 VALUES LESS THAN (2008)
);
insert into t1 values ('2006-01-01',default);
insert into t1 values ('2007-01-01',default);
insert into t1 values ('2005-01-01',default);
select * from t1;
a b
2005-01-01 2005
2006-01-01 2006
2007-01-01 2007
# Modify the expression of generated column b
ALTER TABLE t1 modify b int generated always as (year(a)-1) virtual;
select * from t1;
a b
2005-01-01 2004
2006-01-01 2005
2007-01-01 2006
drop table t1;
# Case 2. Partitioning by LIST based on a stored generated column.
CREATE TABLE t1 (a int, b int generated always as (a % 3 ) stored)
PARTITION BY LIST (a+1)
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
insert into t1 values (1,default);
select * from t1;
a b
1 1
select * from t1;
a b
1 1
drop table t1;
# Case 3. Partitioning by HASH based on a non-stored generated column.
CREATE TABLE t1 (
a DATE NOT NULL,
b int generated always as (year(a)) virtual
)
PARTITION BY HASH( b % 3 ) PARTITIONS 3;
insert into t1 values ('2005-01-01',default);
insert into t1 values ('2006-01-01',default);
select * from t1;
a b
2005-01-01 2005
2006-01-01 2006
# Modify the expression of generated column b
ALTER TABLE t1 modify b int generated always as (year(a)-1) virtual;
select * from t1;
a b
2005-01-01 2004
2006-01-01 2005
drop table t1;
#
# Bug#21779011 INVALID READS AND SENDING RANDOM SERVER MEMORY BACK
# TO CLIENT
#
CREATE TABLE t (
c INTEGER GENERATED ALWAYS AS (2) VIRTUAL,
d INTEGER,
KEY (d)
) PARTITION BY KEY (d) PARTITIONS 2;
INSERT INTO t (d) VALUES (1),(1),(2),(2);
SELECT c FROM t WHERE d >= 1 GROUP BY d LIMIT 2;
c
2
2
DROP TABLE t;
#
# Bug#21779554: CHECK_MISPLACED_ROWS BOGUS "FOUND A MISPLACED ROW"
# AND CRASHES
#
CREATE TABLE t(a INT,b INT GENERATED ALWAYS AS (1) VIRTUAL,c INT)
PARTITION BY KEY (b)PARTITIONS 6;
INSERT INTO t VALUES();
CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text
test.t check status OK
FLUSH TABLES;
CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text
test.t check status OK
DROP TABLE t;
#
# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
#
CREATE TABLE t1 (
a INT,
b INT,
c BIT(4) NOT NULL DEFAULT b'0',
pk INTEGER AUTO_INCREMENT,
d BIT(4) AS (c) VIRTUAL,
PRIMARY KEY(pk),
KEY (b,d)
) PARTITION BY HASH(pk);
INSERT INTO t1 () VALUES (),();
UPDATE t1 SET a = 0 WHERE b IS NULL ORDER BY pk;
DROP TABLE t1;
#
# MDEV-16980 Wrongly set tablename len while opening the
# table for purge thread
#
CREATE TABLE t1(pk SERIAL, d DATE, vd DATE AS (d) VIRTUAL,
PRIMARY KEY(pk), KEY (vd))ENGINE=InnoDB
PARTITION BY HASH(pk) PARTITIONS 2;
INSERT IGNORE INTO t1 (d) VALUES ('2015-04-14');
SET sql_mode= '';
REPLACE INTO t1 SELECT * FROM t1;
Warnings:
Warning 1906 The value specified for generated column 'vd' in table 't1' has been ignored
DROP TABLE t1;
InnoDB 0 transactions not purged
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;