mirror of
https://github.com/MariaDB/server.git
synced 2025-11-28 17:36:30 +03:00
If we instantly change the size of a fixed-length field
and treat it as kind-of variable-length, then we will need
conversions between old column values and new ones.
I tried adding such a conversion to row_build(), but then I
noticed that more conversions would be needed, because
old values still appeared in a freshly rebuilt secondary index,
causing a mismatch when trying to search with the correct
longer value that was converted in my provisional fix to row_build().
So, we will revert the essential part of
MDEV-15563: Instant ROW_FORMAT=REDUNDANT column extension
(commit 22feb179ae), but not
remove any tests.
306 lines
8.5 KiB
Plaintext
306 lines
8.5 KiB
Plaintext
#
|
||
# MDEV-15563: Instant ROW_FORMAT=REDUNDANT column type change&extension
|
||
# (reverted in MDEV-18627)
|
||
#
|
||
create or replace database test;
|
||
use test;
|
||
set default_storage_engine=innodb;
|
||
set @bigval= repeat('0123456789', 30);
|
||
create or replace procedure check_table(table_name varchar(255))
|
||
begin
|
||
select table_id into @table_id
|
||
from information_schema.innodb_sys_tables
|
||
where name = concat('test/', table_name);
|
||
select name, mtype, hex(prtype) as prtype, len
|
||
from information_schema.innodb_sys_columns
|
||
where table_id = @table_id;
|
||
end~~
|
||
# VARCHAR -> CHAR, VARBINARY -> BINARY conversion
|
||
set @bigval= repeat('0123456789', 20);
|
||
create or replace table t (a varchar(300));
|
||
alter table t modify a char(255), algorithm=instant;
|
||
ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
|
||
alter table t modify a char(255), algorithm=copy;
|
||
create or replace table t (a varchar(200));
|
||
insert into t values (@bigval);
|
||
insert into t values ('z');
|
||
alter table t modify a char(200);
|
||
affected rows: 2
|
||
info: Records: 2 Duplicates: 0 Warnings: 0
|
||
select count(a) from t where a = @bigval;
|
||
count(a)
|
||
1
|
||
select a, length(a) from t where a = 'z';
|
||
a length(a)
|
||
z 1
|
||
check table t extended;
|
||
Table Op Msg_type Msg_text
|
||
test.t check status OK
|
||
call check_table('t');
|
||
name mtype prtype len
|
||
a 2 800FE 200
|
||
# CHAR enlargement
|
||
alter table t modify a char(220);
|
||
affected rows: 2
|
||
info: Records: 2 Duplicates: 0 Warnings: 0
|
||
select count(a) from t where a = @bigval;
|
||
count(a)
|
||
1
|
||
select a, length(a) from t where a = 'z';
|
||
a length(a)
|
||
z 1
|
||
check table t extended;
|
||
Table Op Msg_type Msg_text
|
||
test.t check status OK
|
||
call check_table('t');
|
||
name mtype prtype len
|
||
a 2 800FE 220
|
||
# Convert from VARCHAR to a bigger CHAR
|
||
alter table t modify a varchar(200);
|
||
affected rows: 2
|
||
info: Records: 2 Duplicates: 0 Warnings: 0
|
||
alter table t modify a char(255);
|
||
affected rows: 2
|
||
info: Records: 2 Duplicates: 0 Warnings: 0
|
||
select count(a) from t where a = @bigval;
|
||
count(a)
|
||
1
|
||
select a, length(a) from t where a = 'z';
|
||
a length(a)
|
||
z 1
|
||
select * from t;
|
||
a
|
||
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
|
||
z
|
||
check table t extended;
|
||
Table Op Msg_type Msg_text
|
||
test.t check status OK
|
||
call check_table('t');
|
||
name mtype prtype len
|
||
a 2 800FE 255
|
||
# BINARY/VARBINARY test
|
||
create or replace table t (a varbinary(300));
|
||
insert into t values(NULL);
|
||
alter table t modify a binary(255);
|
||
affected rows: 1
|
||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||
create or replace table t (a varbinary(200));
|
||
insert into t values (@bigval);
|
||
insert into t values ('z');
|
||
alter table t modify a binary(200);
|
||
affected rows: 2
|
||
info: Records: 2 Duplicates: 0 Warnings: 0
|
||
select count(a) from t where a = @bigval;
|
||
count(a)
|
||
1
|
||
select length(a) from t where left(a, 1) = 'z';
|
||
length(a)
|
||
200
|
||
check table t extended;
|
||
Table Op Msg_type Msg_text
|
||
test.t check status OK
|
||
call check_table('t');
|
||
name mtype prtype len
|
||
a 3 3F04FE 200
|
||
# BINARY enlargement
|
||
alter table t modify a binary(220);
|
||
affected rows: 2
|
||
info: Records: 2 Duplicates: 0 Warnings: 0
|
||
check table t extended;
|
||
Table Op Msg_type Msg_text
|
||
test.t check status OK
|
||
call check_table('t');
|
||
name mtype prtype len
|
||
a 3 3F04FE 220
|
||
# Convert from VARBINARY to a bigger BINARY
|
||
alter table t modify a varbinary(220);
|
||
affected rows: 2
|
||
info: Records: 2 Duplicates: 0 Warnings: 0
|
||
alter table t modify a binary(255);
|
||
affected rows: 2
|
||
info: Records: 2 Duplicates: 0 Warnings: 0
|
||
select count(a) from t where a = @bigval;
|
||
count(a)
|
||
0
|
||
select a, length(a) from t where a = 'z';
|
||
a length(a)
|
||
select * from t;
|
||
a
|
||
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |