summaryrefslogtreecommitdiff
path: root/mysql-test/suite/vcol/t/index.test
blob: 72eed0a8a407841ce87d36941897dd9192eaa838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--source include/have_innodb.inc
--source include/have_log_bin.inc

--echo #
--echo # Test table with a key that consists of indirect virtual fields
--echo #

CREATE TABLE t1 (a int, b int as (a+1) virtual, c int as (b+1) virtual, index(c)) engine=myisam;
insert into t1 (a) values (1),(2),(3);
update t1 set a=5 where a=3;
delete from t1 where a=1;
select * from t1;
select * from t1 where c=7;
check table t1;
select * from t1;
drop table t1;

CREATE TABLE t1 (a int, b int as (a+1) virtual, c int as (b+1) virtual, index(c)) engine=innodb;
insert into t1 (a) values (1),(2),(3);
update t1 set a=5 where a=3;
delete from t1 where a=1;
select * from t1;
select * from t1 where c=7;
check table t1;
select * from t1;
drop table t1;

--echo #
--echo # MDEV-15114
--echo # ASAN heap-use-after-free in mem_heap_dup or
--echo # dfield_data_is_binary_equal
--echo #

CREATE TABLE t1 (
  pk INT,
  extra tinyint,
  c TEXT,
  vc LONGTEXT AS (c) VIRTUAL,
  i INT,
  PRIMARY KEY(pk),
  UNIQUE(i),
  INDEX(vc(64))
) ENGINE=InnoDB;

INSERT INTO t1 (pk,extra, c, i) VALUES (1, 10, REPEAT('foo ',15000),0);
REPLACE INTO t1 (pk,extra, c,i) SELECT pk,extra+10, c,i FROM t1;
select pk, extra, left(c, 10), length(c), left(vc,10), length(vc), extra from t1;
DROP TABLE t1;

--echo #
--echo # Update of deleted row with binary logging enabled
--echo #

SET BINLOG_FORMAT=row;

CREATE TABLE t1 (
 pk INT,
 c TEXT,
 vc LONGTEXT AS (c) VIRTUAL,
 i INT,
 PRIMARY KEY(pk),
 UNIQUE(i),
 INDEX(vc(64))
) ENGINE=InnoDB;

INSERT INTO t1 (pk,c,i) VALUES (1,REPEAT('foo ',15000),10);
INSERT INTO t1 (pk,c,i) VALUES (2,REPEAT('bar ',15000),11);

--connect (c1,localhost,root,,)
--connection c1
begin;
DELETE from t1 WHERE pk=1;
--connection default
--send update t1 set pk=1 where pk=2
--connection c1
commit;
--connection default
--reap
select pk, left(c, 10), length(c), i from t1;
drop table t1;
disconnect c1;