1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-29021 ALTER TABLE fails when a stored virtual column is dropped+added

We shouldn't rely on `fill_extra_persistent_columns`, as it only updates
fields which have an index > cols->n_bits (replication bitmap width).
Actually, it should never be used, as its approach is error-prone.

Normal update_virtual_fields+update_default_fields should be done.
This commit is contained in:
Nikita Malyavin
2022-07-04 15:13:51 +03:00
committed by Sergei Golubchik
parent ea46fdcea4
commit 93fb92d3f9
6 changed files with 241 additions and 95 deletions

View File

@@ -32,8 +32,24 @@ a z1 z2
4 5 6
5 6 7
6 7 8
#UPDATE query
alter table t1 add column z3 int default(a+2);
connection master;
insert into t1 values(7);
insert into t1 values(8);
connection slave;
select * from t1 order by a;
a z1 z2 z3
1 2 3 3
2 3 4 4
3 4 5 5
4 5 6 6
5 6 7 7
6 7 8 8
7 8 9 9
8 9 10 10
connection master;
delete from t1 where a > 6;
#UPDATE query
update t1 set a = a+10;
select * from t1 order by a;
a
@@ -45,13 +61,13 @@ a
16
connection slave;
select * from t1 order by a;
a z1 z2
11 12 13
12 13 14
13 14 15
14 15 16
15 16 17
16 17 18
a z1 z2 z3
11 12 13 13
12 13 14 14
13 14 15 15
14 15 16 16
15 16 17 17
16 17 18 18
connection master;
update t1 set a = a-10;
select * from t1 order by a;
@@ -64,13 +80,13 @@ a
6
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
a z1 z2 z3
1 2 3 3
2 3 4 4
3 4 5 5
4 5 6 6
5 6 7 7
6 7 8 8
#DELETE quert
connection master;
delete from t1 where a > 2 and a < 4;
@@ -83,12 +99,12 @@ a
6
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
4 5 6
5 6 7
6 7 8
a z1 z2 z3
1 2 3 3
2 3 4 4
4 5 6 6
5 6 7 7
6 7 8 8
#REPLACE query
connection master;
replace into t1 values(1);
@@ -96,13 +112,13 @@ replace into t1 values(3);
replace into t1 values(1);
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
a z1 z2 z3
1 2 3 3
2 3 4 4
3 4 5 5
4 5 6 6
5 6 7 7
6 7 8 8
#SELECT query
connection master;
select * from t1 where a > 2 and a < 4;
@@ -110,8 +126,8 @@ a
3
connection slave;
select * from t1 where a > 2 and a < 4;
a z1 z2
3 4 5
a z1 z2 z3
3 4 5 5
#UPDATE with SELECT query
connection master;
update t1 set a = a + 10 where a > 2 and a < 4;
@@ -125,13 +141,13 @@ a
13
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
4 5 6
5 6 7
6 7 8
13 14 15
a z1 z2 z3
1 2 3 3
2 3 4 4
4 5 6 6
5 6 7 7
6 7 8 8
13 14 15 15
connection master;
update t1 set a = a - 10 where a = 13;
select * from t1 order by a;
@@ -144,13 +160,13 @@ a
6
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
a z1 z2 z3
1 2 3 3
2 3 4 4
3 4 5 5
4 5 6 6
5 6 7 7
6 7 8 8
#Break Unique Constraint
alter table t1 add column z4 int as (a % 6) persistent unique;
connection master;
@@ -168,27 +184,27 @@ a
connection slave;
include/wait_for_slave_sql_error.inc [errno=1062]
select * from t1 order by a;
a z1 z2 z4
1 2 3 1
2 3 4 2
3 4 5 3
4 5 6 4
5 6 7 5
6 7 8 0
a z1 z2 z3 z4
1 2 3 3 1
2 3 4 4 2
3 4 5 5 3
4 5 6 6 4
5 6 7 7 5
6 7 8 8 0
alter table t1 drop column z4;
start slave;
include/wait_for_slave_sql_to_start.inc
connection master;
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
a z1 z2 z3
1 2 3 3
2 3 4 4
3 4 5 5
4 5 6 6
5 6 7 7
6 7 8 8
7 8 9 9
connection master;
select * from t1 order by a;
a