mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-5800 InnoDB support for indexed vcols
* remove old 5.2+ InnoDB support for virtual columns * enable corresponding parts of the innodb-5.7 sources * copy corresponding test cases from 5.7 * copy detailed Alter_inplace_info::HA_ALTER_FLAGS flags from 5.7 - and more detailed detection of changes in fill_alter_inplace_info() * more "innodb compatibility hooks" in sql_class.cc to - create/destroy/reset a THD (used by background purge threads) - find a prelocked table by name - open a table (from a background purge thread) * different from 5.7: - new service thread "thd_destructor_proxy" to make sure all THDs are destroyed at the correct point in time during the server shutdown - proper opening/closing of tables for vcol evaluations in + FK checks (use already opened prelocked tables) + purge threads (open the table, MDLock it, add it to tdc, close when not needed) - cache open tables in vc_templ - avoid unnecessary allocations, reuse table->record[0] and table->s->default_values - not needed in 5.7, because it overcalculates: + tell the server to calculate vcols for an on-going inline ADD INDEX + calculate vcols for correct error messages * update other engines (mroonga/tokudb) accordingly
This commit is contained in:
227
mysql-test/suite/gcol/r/innodb_virtual_debug.result
Normal file
227
mysql-test/suite/gcol/r/innodb_virtual_debug.result
Normal file
@@ -0,0 +1,227 @@
|
||||
set default_storage_engine=innodb;
|
||||
CREATE TABLE `t` (
|
||||
`a` VARCHAR(100),
|
||||
`b` VARCHAR(100),
|
||||
`c` VARCHAR(200) GENERATED ALWAYS AS (CONCAT(a,b)) VIRTUAL,
|
||||
`h` VARCHAR(10) DEFAULT NULL,
|
||||
`i` int
|
||||
) ENGINE=InnoDB;
|
||||
INSERT INTO t VALUES (REPEAT('g', 100), REPEAT('x', 10), DEFAULT, "kk", 1);
|
||||
INSERT INTO t VALUES (REPEAT('a', 100), REPEAT('b', 100), DEFAULT, "mm", 2);
|
||||
CREATE INDEX idx ON t(c(100));
|
||||
SET session debug_dbug="+d,ib_alter_add_virtual_fail";
|
||||
ALTER TABLE t ADD COLUMN x VARCHAR(200) GENERATED ALWAYS AS (a) VIRTUAL,
|
||||
ALGORITHM = INPLACE;
|
||||
ERROR 42000: The storage engine InnoDB can't index column `x`
|
||||
ALTER TABLE t DROP COLUMN c, ALGORITHM = INPLACE;
|
||||
ERROR 42000: The storage engine InnoDB can't index column `c`
|
||||
SET session debug_dbug="";
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (a INT, b INT, c INT GENERATED ALWAYS AS(a+b), h VARCHAR(10));
|
||||
INSERT INTO t VALUES (11, 3, DEFAULT, 'mm');
|
||||
INSERT INTO t VALUES (18, 1, DEFAULT, 'mm');
|
||||
INSERT INTO t VALUES (28, 1, DEFAULT, 'mm');
|
||||
INSERT INTO t VALUES (null, null, DEFAULT, "mx");
|
||||
SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter SIGNAL start_create WAIT_FOR go_ahead';
|
||||
CREATE INDEX idx ON t(c);
|
||||
connect con1,localhost,root,,;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR start_create';
|
||||
update t set a=0 where a = 11;
|
||||
start transaction;
|
||||
update t set a=1 where a = 0;
|
||||
ROLLBACK;
|
||||
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
|
||||
connection default;
|
||||
SELECT c FROM t;
|
||||
c
|
||||
NULL
|
||||
3
|
||||
19
|
||||
29
|
||||
SHOW CREATE TABLE t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` int(11) AS ((`a` + `b`)) VIRTUAL,
|
||||
`h` varchar(10) DEFAULT NULL,
|
||||
KEY `idx` (`c`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SELECT * FROM t;
|
||||
a b c h
|
||||
0 3 3 mm
|
||||
18 1 19 mm
|
||||
28 1 29 mm
|
||||
NULL NULL NULL mx
|
||||
SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter SIGNAL start_create WAIT_FOR go_ahead';
|
||||
ALTER TABLE t ADD COLUMN x INT;
|
||||
connection con1;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR start_create';
|
||||
start transaction;
|
||||
update t set a=1 where a = 0;
|
||||
rollback;
|
||||
start transaction;
|
||||
delete from t;
|
||||
insert into t values(1,null,default,null);
|
||||
rollback;
|
||||
start transaction;
|
||||
update t set b=b+1;
|
||||
rollback;
|
||||
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
|
||||
connection default;
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
SELECT c FROM t;
|
||||
c
|
||||
NULL
|
||||
3
|
||||
19
|
||||
29
|
||||
SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter SIGNAL start_create WAIT_FOR go_ahead';
|
||||
ALTER TABLE t ADD COLUMN x2 INT;
|
||||
connection con1;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR start_create';
|
||||
start transaction;
|
||||
DELETE FROM t WHERE a = 0;
|
||||
ROLLBACK;
|
||||
DELETE FROM t WHERE a = 0;
|
||||
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
|
||||
connection default;
|
||||
SELECT c FROM t;
|
||||
c
|
||||
NULL
|
||||
19
|
||||
29
|
||||
disconnect con1;
|
||||
DROP TABLE t;
|
||||
SET DEBUG_SYNC = 'RESET';
|
||||
CREATE TABLE t (a INT, b INT, c INT GENERATED ALWAYS AS(a+b), h VARCHAR(10));
|
||||
INSERT INTO t VALUES (11, 3, DEFAULT, 'mm');
|
||||
INSERT INTO t VALUES (18, 1, DEFAULT, 'mm');
|
||||
INSERT INTO t VALUES (28, 1, DEFAULT, 'mm');
|
||||
INSERT INTO t VALUES (null, null, DEFAULT, 'mm');
|
||||
CREATE INDEX idx_1 on t(c);
|
||||
SET SESSION debug_dbug="+d,create_index_fail";
|
||||
ALTER TABLE t ADD COLUMN x INT GENERATED ALWAYS AS(a+b), ADD INDEX idx (x);
|
||||
ERROR 23000: Duplicate entry '' for key '*UNKNOWN*'
|
||||
SET SESSION debug_dbug="";
|
||||
affected rows: 0
|
||||
SHOW CREATE TABLE t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` int(11) AS ((`a` + `b`)) VIRTUAL,
|
||||
`h` varchar(10) DEFAULT NULL,
|
||||
KEY `idx_1` (`c`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SELECT c FROM t;
|
||||
c
|
||||
NULL
|
||||
14
|
||||
19
|
||||
29
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#22018532 ASSERTION WHEN ONLINE REAPPLY REBUILD LOG ON
|
||||
# MULTIPLE INDEXED VIRTUAL COLUMNS
|
||||
#
|
||||
create table t (
|
||||
a int as (1) virtual,
|
||||
b int,
|
||||
c int as (1) virtual,
|
||||
unique(b),
|
||||
unique(c),
|
||||
key(a)
|
||||
) engine=innodb;
|
||||
insert ignore into t values();
|
||||
SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter SIGNAL start_create WAIT_FOR go_ahead';
|
||||
optimize table t;
|
||||
connect con1,localhost,root,,;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR start_create';
|
||||
insert ignore into t values();
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '1' for key 'c'
|
||||
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
|
||||
connection default;
|
||||
/* connection default */ optimize table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t optimize note Table does not support optimize, doing recreate + analyze instead
|
||||
test.t optimize error Duplicate entry '1' for key 'a'
|
||||
test.t optimize status Operation failed
|
||||
Warnings:
|
||||
Error 1062 Duplicate entry '1' for key 'a'
|
||||
SELECT c FROM t;
|
||||
c
|
||||
1
|
||||
SHOW CREATE TABLE t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) AS (1) VIRTUAL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` int(11) AS (1) VIRTUAL,
|
||||
UNIQUE KEY `b` (`b`),
|
||||
UNIQUE KEY `c` (`c`),
|
||||
KEY `a` (`a`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SELECT * FROM t;
|
||||
a b c
|
||||
1 NULL 1
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (a INT, b INT, c INT GENERATED ALWAYS AS(a+b), h VARCHAR(10));
|
||||
INSERT INTO t VALUES (11, 3, DEFAULT, 'mm');
|
||||
INSERT INTO t VALUES (18, 1, DEFAULT, 'mm');
|
||||
INSERT INTO t VALUES (28, 1, DEFAULT, 'mm');
|
||||
INSERT INTO t VALUES (null, null, DEFAULT, 'mm');
|
||||
CREATE INDEX idx ON t(c);
|
||||
SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter SIGNAL start_rebuild WAIT_FOR go_ahead';
|
||||
optimize table t;
|
||||
connection con1;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR start_rebuild';
|
||||
INSERT INTO t VALUES (48, 2, DEFAULT, 'xx');
|
||||
INSERT INTO t VALUES (68, 3, DEFAULT, 'sx');
|
||||
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
|
||||
connection default;
|
||||
/* connection default */ optimize table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t optimize note Table does not support optimize, doing recreate + analyze instead
|
||||
test.t optimize status OK
|
||||
SELECT c FROM t;
|
||||
c
|
||||
NULL
|
||||
14
|
||||
19
|
||||
29
|
||||
50
|
||||
71
|
||||
disconnect con1;
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#22951879 - ASSERTS RELATED TO ONLINE DDL AND GCOL
|
||||
#
|
||||
create table ibstd_14 (a int not null, d int not null, b varchar(198) not null, c char(181), vadcol int as (a+length(d)) stored, vbcol char(2) as (substr(b,2,2)) virtual, vbidxcol char(3) as (substr(b,1,3)) virtual , index(d), index(a), index(vbidxcol), index(a,vbidxcol), index(vbidxcol,d), unique key (b(10), a, d), index(c(99), b(31)), index(b(5), c(10), a) , index(a,d)) engine=InnoDB stats_persistent=1 row_format=dynamic;
|
||||
SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter SIGNAL start_create WAIT_FOR go_ahead';
|
||||
alter table ibstd_14 row_format=compressed key_block_size=4,add key kn3 (d,c,vbcol,b);
|
||||
connect con1,localhost,root;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR start_create';
|
||||
insert into ibstd_14 (a,d,b,c, vbidxcol, vbcol) values ('118','6',repeat('oacolaarlruoacuroauurloraarucoooarcooauoolacalllaulrruarrrucruuooclacuoouccarrcoocloccorrrrarourcooalloocooccouruolaorlcaocualolc','1'),repeat('lolrrlalcocroraaulauclaaucolcorcuooaolruaooooluooooouaoorlarucorullalcrrloccououaooaorluorraclrcooouuolocoaolcocaaculruoocucoocoooauuolarcoraraocaoolulolarru','1'),default,default);
|
||||
insert into ibstd_14 (a,d,b,c, vbidxcol, vbcol) values ('118','6', 'aaaa', 'lll', default, default);
|
||||
update ibstd_14 set b='11111' where b='aaaa';
|
||||
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
|
||||
connection default;
|
||||
select * from ibstd_14;
|
||||
a d b c vadcol vbcol vbidxcol
|
||||
118 6 oacolaarlruoacuroauurloraarucoooarcooauoolacalllaulrruarrrucruuooclacuoouccarrcoocloccorrrrarourcooalloocooccouruolaorlcaocualolc lolrrlalcocroraaulauclaaucolcorcuooaolruaooooluooooouaoorlarucorullalcrrloccououaooaorluorraclrcooouuolocoaolcocaaculruoocucoocoooauuolarcoraraocaoolulolarru 119 ac oac
|
||||
118 6 11111 lll 119 11 111
|
||||
select d,c,vbcol,b from ibstd_14;
|
||||
d c vbcol b
|
||||
6 lll 11 11111
|
||||
6 lolrrlalcocroraaulauclaaucolcorcuooaolruaooooluooooouaoorlarucorullalcrrloccououaooaorluorraclrcooouuolocoaolcocaaculruoocucoocoooauuolarcoraraocaoolulolarru ac oacolaarlruoacuroauurloraarucoooarcooauoolacalllaulrruarrrucruuooclacuoouccarrcoocloccorrrrarourcooalloocooccouruolaorlcaocualolc
|
||||
select vbcol from ibstd_14;
|
||||
vbcol
|
||||
11
|
||||
ac
|
||||
drop table ibstd_14;
|
||||
disconnect con1;
|
||||
SET DEBUG_SYNC = 'RESET';
|
Reference in New Issue
Block a user